Exemplo n.º 1
0
        /// <summary>
        /// 移除观察者
        /// </summary>
        /// <param name="notifyid"></param>
        /// <param name="observer"></param>
        public virtual void RemoveObserver(NotifyDefine notifyid, IObserver observer)
        {
            lock (m_syncRoot)
            {
                if (!m_notifiMap.ContainsKey(notifyid))
                {
                    return;
                }

                IList <IObserver> observers = m_notifiMap[notifyid];
                // find the observer for the notifyContext
                for (int i = 0; i < observers.Count; i++)
                {
                    if (observers[i].Equals(observer))
                    {
                        observers.RemoveAt(i);
                        break;
                    }
                }

                if (observers.Count == 0)
                {
                    m_notifiMap.Remove(notifyid);
                }
            }
        }
Exemplo n.º 2
0
 public virtual bool HasCommand(NotifyDefine notifyid)
 {
     lock (m_syncRoot)
     {
         return(m_commandMap.ContainsKey(notifyid));
     }
 }
Exemplo n.º 3
0
        public void SendNotification <SendEntity, Param>(NotifyDefine notifiid, SendEntity send, Param body)
        {
            Notification <SendEntity, Param> notification = Notification <SendEntity, Param> .createObject();

            notification.InitData(notifiid, send, body);
            NotifyObservers(notification);
        }
Exemplo n.º 4
0
        public void SendNotification <Param>(NotifyDefine notifiid, Param body)
        {
            Notification <object, Param> notification = Notification <object, Param> .createObject();

            notification.InitData(notifiid, null, body);
            NotifyObservers(notification);
        }
Exemplo n.º 5
0
        public void SendNotification(NotifyDefine notifiid)
        {
            Notification <object, object> notification = Notification <object, object> .createObject();

            notification.InitData(notifiid, null, null);
            NotifyObservers(notification);
        }
Exemplo n.º 6
0
 public virtual ICommand GetCommand(NotifyDefine notifyid)
 {
     if (!m_commandMap.ContainsKey(notifyid))
     {
         return(null);
     }
     return(m_commandMap[notifyid]);
 }
Exemplo n.º 7
0
 public virtual void RemoveCommand(NotifyDefine notifyid)
 {
     lock (m_syncRoot)
     {
         if (m_commandMap.ContainsKey(notifyid))
         {
             m_commandMap.Remove(notifyid);
         }
     }
 }
Exemplo n.º 8
0
        /// <summary>
        ///  添加观察者
        /// </summary>
        /// <param name="notifi"></param>
        /// <param name="observer"></param>
        public virtual void RegisterObserver(NotifyDefine notifi, IObserver observer)
        {
            lock (m_syncRoot)
            {
                if (!m_notifiMap.ContainsKey(notifi))
                {
                    m_notifiMap[notifi] = new List <IObserver>();
                }

                m_notifiMap[notifi].Add(observer);
            }
        }
Exemplo n.º 9
0
 public void SendNotification <SendEntity, Param>(NotifyDefine notifiid, SendEntity send, Param body)
 {
     m_notifier.SendNotification(notifiid, send, body);
 }
Exemplo n.º 10
0
 public void SendNotification <Param>(NotifyDefine notifiid, Param body)
 {
     m_notifier.SendNotification(notifiid, body);
 }
Exemplo n.º 11
0
 public void SendNotification(NotifyDefine notifi)
 {
     m_notifier.SendNotification(notifi);
 }
Exemplo n.º 12
0
 public void RemoveObserver(NotifyDefine notifi, IObserver observer)
 {
     m_notifier.RemoveObserver(notifi, observer);
 }
Exemplo n.º 13
0
 /// <summary>
 /// Constructs a new notification with the specified name and body, with the default type
 /// </summary>
 /// <param name="name">The name of the <c>Notification</c> instance</param>
 /// <param name="body">The <c>Notification</c>s body</param>
 public Notification(NotifyDefine notifi, Param body)
     : this(notifi)
 {
     m_body = body;
 }
Exemplo n.º 14
0
 public ICommand GetCommand(NotifyDefine notifyid)
 {
     return(m_controller.GetCommand(notifyid));
 }
Exemplo n.º 15
0
 public void RemoveCommand(NotifyDefine notiid)
 {
     m_controller.RemoveCommand(notiid);
 }
Exemplo n.º 16
0
 /// <summary>
 /// 初始化变量
 /// </summary>
 /// <param name="notifi"></param>
 /// <param name="send"></param>
 /// <param name="body"></param>
 public void InitData(NotifyDefine notifi, SendEntity send, Param body)
 {
     m_notifi = notifi;
     m_send   = send;
     m_body   = body;
 }
Exemplo n.º 17
0
 /// <summary>
 /// Constructs a new notification with the specified name, body and type
 /// </summary>
 /// <param name="name">The name of the <c>Notification</c> instance</param>
 /// <param name="body">The <c>Notification</c>s body</param>
 /// <param name="type">The type of the <c>Notification</c></param>
 public Notification(NotifyDefine notifi, SendEntity send, Param body)
     : this(notifi, body)
 {
     m_send = send;
 }
Exemplo n.º 18
0
 public bool HasCommand(NotifyDefine notiid)
 {
     return(m_controller.HasCommand(notiid));
 }
Exemplo n.º 19
0
 public virtual void RegisterCommand(NotifyDefine notifyid, ICommand command)
 {
     m_commandMap[notifyid] = command;
 }
Exemplo n.º 20
0
 public void RegisterCommand(NotifyDefine notiid, ICommand command)
 {
     m_controller.RegisterCommand(notiid, command);
 }
Exemplo n.º 21
0
 /// <summary>
 /// Constructs a new notification with the specified name, default body and type
 /// </summary>
 /// <param name="name">The name of the <c>Notification</c> instance</param>
 public Notification(NotifyDefine notifi)
 {
     m_notifi = notifi;
 }