Exemplo n.º 1
0
        internal virtual void HandleEvent(EventPublication publication, object sender, EventArgs args)
        {
            Delegate handler = Delegate.CreateDelegate(
                publication.EventHandleType, Target, methodName);

            handler.DynamicInvoke(sender, args);
        }
Exemplo n.º 2
0
 internal void OnEventFired(EventPublication publication, object sender, EventArgs args)
 {
     CheckInvalidPublications();
     CheckInvalidSubscriptions();
     foreach (var subscriber in subscribers)
     {
         subscriber.HandleEvent(publication, sender, args);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// 注册发布者
 /// </summary>
 private void RegisterPublication(object target, BindingFlags bindings)
 {
     foreach (var info in target.GetType().GetEvents(bindings))
     {
         foreach (EventPublicationAttribute attr in
                  info.GetCustomAttributes(typeof(EventPublicationAttribute), false))
         {
             var        publisher = new EventPublication(target, info.Name);
             var        topicName = attr.Topic;
             EventTopic topic     = Topics[topicName] ?? Topics.Add(topicName);
             topic.AddPublication(publisher);
         }
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// 注册发布者
 /// </summary>
 private void RegisterPublication(object target, BindingFlags bindings)
 {
     foreach (var info in target.GetType().GetEvents(bindings))
     {
         foreach (EventPublicationAttribute attr in
             info.GetCustomAttributes(typeof(EventPublicationAttribute), false))
         {
             var publisher = new EventPublication(target, info.Name);
             var topicName = attr.Topic;
             EventTopic topic = Topics[topicName] ?? Topics.Add(topicName);
             topic.AddPublication(publisher);
         }
     }
 }
Exemplo n.º 5
0
        internal virtual void HandleEvent(EventPublication publication, object sender, EventArgs args)
        {
            Delegate handler = Delegate.CreateDelegate(
                publication.EventHandleType, Target, methodName);

            handler.DynamicInvoke(sender, args);
        }
Exemplo n.º 6
0
 /// <summary>
 /// 移除发布者
 /// </summary>
 internal void RemovePublication(EventPublication publisher)
 {
     EventContext.Instance.WriteTo("主题:{0} 移除发布者{1}", Name, publisher);
     publishers.Remove(publisher);
 }
Exemplo n.º 7
0
 /// <summary>
 /// 增加发布者
 /// </summary>
 internal void AddPublication(EventPublication publisher)
 {
     EventContext.Instance.WriteTo("主题:{0} 添加发布者{1}", Name, publisher);
     publisher.EventFired += OnEventFired;
     publishers.Add(publisher);
 }