Esempio n. 1
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="event"></param>
 /// <param name="handler"></param>
 public EventWithHandler(Object @event, EventHandler handler)
 {
     Preconditions.CheckArgument(@event != null, "Event object is null.");
     Preconditions.CheckArgument(@event != null, "EventHandler is null.");
     this.@event = @event;
     this.handler = handler;
     
 }
 /// <summary>
 /// This getting an object and extract all the methods marked with Subscribe attribute.
 /// </summary>
 /// <param name="subscriber">The object whose methods are desired to be event handlers</param>
 /// <returns>MultiMap between a key which is event type and a value which is the event handler contains a target object and methodInfo</returns>
 public IMultiMap<Type, EventHandler> FindAllHandlers(Object subscriber)
 {
     IMultiMap<Type, EventHandler> methodsInSubscriber = HashMultiMap<Type, EventHandler>.Create();
     foreach (MethodInfo method in GetMarkedMethods(subscriber))
     {
         ParameterInfo[] parmetersTypes = method.GetParameters();
         Type eventType = parmetersTypes[0].ParameterType;
         EventHandler handler = new EventHandler(subscriber, method);
         methodsInSubscriber.Add(eventType, handler);
         
     }
     return methodsInSubscriber;
 }
Esempio n. 3
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="event"></param>
 /// <param name="eventHandler"></param>
 private void DispatchWithOutExceptionThrown(Object @event , EventHandler eventHandler)
 {
     try
     {
         eventHandler.HandleEvent(@event);
     }
     catch (Exception e)
     {
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Entering event and handler to the queue of current  thread.
 /// </summary>
 /// <param name="event">Event to enter to queue.</param>
 /// <param name="handler">Handler to enter to queue.</param>
 private void EnqueueEvent(Object @event, EventHandler handler)
 {
     eventsToDispatch.Value.Enqueue(new EventWithHandler(@event , handler));
 }