Answer the question
In order to leave comments, you need to log in
C# how to organize a subscription to an event of one service in another in ASP.NET?
Hello.
There are at least two services (class with business logic). One of them (Class A) executes a method for adding data. When this happens, it is necessary to call a special method of the remaining classes, which each perform their own part of the logic, and the number of such classes may change over time. In addition, the application must work in the asp.net mvc environment
. I see the implementation of this task as follows:
- describe the interfaces and implement them (to reduce communications)
- implement class A, in which to describe the delegate and the event (here it seems to me that you can use what something more modern ...)
- at the level of a web application, create instances of classes using the singleton pattern
- classes that should respond to adding data in class A subscribe to class A event
Now the question is: how good is this approach and what can be improved to improve the design?
Thank you.
Answer the question
In order to leave comments, you need to log in
The solution looks like a crutch, what task should have been solved initially?
In the task "service 1" should use "service 2" do not need events
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question