currently there is no automatic registration. each service must be registered via an api call. you could define an interface used to register a component. each component that wants to be registered could implement this interface. at startup use reflection to find all classes with the interface then call the interface for each class.
How Can I Register and Manage Services in a Large C# Project?
Hello
I will start developing a new C# WPF project. I need your information on something while planning.
I will use the MVVM pattern in the project. I will create a large number of services to perform some tasks and use them in the relevant classes. I am thinking of using the Microsoft.Extension package as a container while doing this. However, in my research I found that the created services should be registered in the container as a dependency and at the same time the classes that request the service should be registered in the container. As this project grows, managing dependencies can cause problems.
How should I structure service management to handle this situation? What is the most trouble-free approach to this? I want the dependencies to be managed automatically.
Thank you.
2 answers
Sort by: Most helpful
-
-
Shubham Kahar 0 Reputation points
2024-10-03T09:18:49.25+00:00 Hi Fatih,
Use constructor infusion for administrations, bunch them into modules, and influence Scrutor for programmed enrollment. Oversee administration lifetimes cautiously, and consider Lazy<T> for asset weighty administrations. This guarantees adaptable and proficient help the board.