If you use picture to load and manage assemblies, you simply cannot need language services much like the C# += operator or even the optical fundamental AddHandler account to connect functions. All of the following surgery reveal strategy to hook up a current solution to a celebration by obtaining all of the needed sorts through picture, and ways to produce a dynamic method utilizing expression give off and hook it up to a meeting.
For the next method to attach an event-handling delegate, begin to see the code model towards AddEventHandler way of the EventInfo classroom.
To hook-up a delegate using picture
Load a system comprising a type that elevates activities. Assemblies are usually laden with the system.Load process. To keep this instance painless, a derived type in this forum is employed, therefore, the GetExecutingAssembly strategy is accustomed fill the existing meeting.
Receive a Type subject presenting the sort, and develop an example associated with the kinds. The CreateInstance(sort) technique is in the below signal since the kind offers a parameterless constructor. There are several some other overloads belonging to the CreateInstance process that you can use when sort you might be developing lacks a parameterless constructor. The newest circumstances is definitely saved as kind thing hold the literary composition that nothing is understood the system. (representation lets you have the sorts in an assembly without knowing their unique names in advance.)
Put an EventInfo thing standing for case, and employ the EventHandlerType property to have the kind of delegate utilized to deal with case. When you look at the preceding signal, an EventInfo towards push function happens to be received.
Collect a MethodInfo subject stage the method that deals with case. Lees verder