Introduction to MVC Architecture-event mechanism and mvc Architecture event mechanism

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.