Esempio n. 1
0
 /// <summary>
 /// 注册订阅者
 /// </summary>
 /// <param name="target"></param>
 /// <param name="bindings"></param>
 private void RegisterSubscription(object target, BindingFlags bindings)
 {
     foreach (var info in target.GetType().GetMethods(bindings))
     {
         foreach (EventSubscriptionAttribute attr in
             info.GetCustomAttributes(typeof(EventSubscriptionAttribute), true))
         {
             var subscriber = new EventSubscription(target, info.Name);
             var topicName = attr.Topic;
             EventTopic topic = Topics[topicName] ?? Topics.Add(topicName);
             topic.AddSubscription(subscriber);
         }
     }
 }
Esempio n. 2
0
 /// <summary>
 /// 移除订阅者
 /// </summary>
 internal void RemoveSubscription(EventSubscription subscriber)
 {
     EventContext.Instance.WriteTo("主题:{0} 移除订阅者{1}", Name, subscriber);
     subscribers.Remove(subscriber);
 }
Esempio n. 3
0
 /// <summary>
 /// 增加订阅者
 /// </summary>
 internal void AddSubscription(EventSubscription subscriber)
 {
     EventContext.Instance.WriteTo("主题:{0} 添加订阅者{1}", Name, subscriber);
     subscribers.Add(subscriber);
 }