Introduction to MVC Architecture-event mechanism and mvc Architecture event mechanism
Instance product based on asp.net mvc 5.0 framework, source code: http://www.jinhusns.com/Products/Download
In. in the. net Framework, an event is a proxy class that associates the event sender (the object that triggers the event) with the event receiver (the method used to process the event, that is, the event mechanism is implemented through the proxy class. When an event is triggered, the event proxy notifies (CALLS) the corresponding method to process the event.
There is a switch on the wall. When we open it, we trigger an event and handle it, that is, the light is turned on or the air conditioner is turned on, when we close it, another event is triggered, and the light is turned off. There are many ways to handle the event, however, the event is triggered only when the switch is enabled or disabled.
When an event is generated, object 2 needs to execute an action. This is the event mechanism. The object is the producer or sender of the event, and the object is the receiver or subscriber of the event. When an object generates a message, it must respond to and process the message. This is the essence of an event.
EventBus is a class that almost processes events. There will be some processing operations on events.
Event calling mechanism:
In the RegisterEventHandler function, add the After function to the Evenbus.
Use OnBefore and OnAfter to trigger the event.