Ejemplo n.º 1
0
 /// <summary>
 /// 通过指定EvnetItem移除一个事件
 /// </summary>
 /// <param name="_eventItem"></param>
 public static void RemoveEvent(IEventSystemItem _eventItem)
 {
     if (null == _eventItem)
     {
         return;
     }
     EventSystemDispatcherCenter.Instance.RemoveEventItem(_eventItem.EventName);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 添加event item
        /// </summary>
        /// <param name="_eventItem"></param>
        /// <param name="_eventChannel"></param>
        /// <returns></returns>
        public IEventSystemItem AddEventItem(IEventSystemItem _eventItem, IEventSystemChannel _eventChannel)
        {
            if (null == _eventItem || null == _eventChannel)
            {
                return(null);
            }

            return(AddEventItem(_eventItem, _eventChannel));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 添加event item
        /// </summary>
        /// <param name="_eventItem"></param>
        /// <param name="_channelName"></param>
        /// <returns></returns>
        public IEventSystemItem AddEventItem(IEventSystemItem _eventItem, string _channelName = null)
        {
            if (null == _eventItem)
            {
                return(null);
            }

            return(AddEventItem(_eventItem.EventName, _channelName));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 添加一个事件对象
        /// </summary>
        /// <param name="_eventtem"></param>
        public void AddEventItem(IEventSystemItem _eventtem)
        {
            if (null == _eventtem)
            {
                return;
            }

            if (false == eventItems.ContainsKey(_eventtem.EventName))
            {
                eventItems.Add(_eventtem.EventName, _eventtem);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 移除event item
        /// </summary>
        /// <param name="_eventItem"></param>
        public void RemoveEventItem(IEventSystemItem _eventItem)
        {
            if (null == _eventItem)
            {
                return;
            }

            // 从队列中移除
            if (true == eventItems.ContainsKey(_eventItem.EventName))
            {
                eventItems.Remove(_eventItem.EventName);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 从所有Channel里遍历当前要移除的EventItem
        /// </summary>
        /// <param name="_eventItem"></param>
        private void RemoveEventItemInChannels(IEventSystemItem _eventItem)
        {
            if (null == _eventItem)
            {
                return;
            }

            foreach (var eventSystemChannel in channelDic)
            {
                if (null != eventSystemChannel.Value)
                {
                    eventSystemChannel.Value.RemoveEventItem(_eventItem);
                }
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 删除一个event
        /// </summary>
        /// <param name="_eventItemName"></param>
        public void RemoveEventItem(string _eventItemName)
        {
            if (true == string.IsNullOrEmpty(_eventItemName))
            {
                return;
            }

            if (true == eventItemDic.ContainsKey(_eventItemName))
            {
                IEventSystemItem eventItem = eventItemDic[_eventItemName];
                if (null != eventItem)
                {
                    RemoveEventItemInChannels(eventItem);
                    ((IEventDispose)eventItem).Dispose();
                }
                eventItemDic.Remove(_eventItemName);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 创建Event Item时检测,将自己的tag加入到对应的队列中
        /// </summary>
        /// <param name="_eventSystemItem"></param>
        private void EventItemCheck(IEventSystemItem _eventSystemItem)
        {
            if (null == _eventSystemItem)
            {
                return;
            }

            foreach (var channelTag in _eventSystemItem.GetChannelTags())
            {
                if (false == string.IsNullOrEmpty(channelTag))
                {
                    var channel = GetEventChannel(channelTag);
                    if (null != channel)
                    {
                        channel.AddEventItem(_eventSystemItem);
                    }
                }
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 根据 事件名字,和事件频道,添加一个具体的事件
        /// </summary>
        /// <param name="_eventItemName"></param>
        /// <param name="_channelNames"></param>
        /// <returns></returns>
        public IEventSystemItem AddEventItem(string _eventItemName, params string[] _channelNames)
        {
            if (true == string.IsNullOrEmpty(_eventItemName))
            {
                return(null);
            }

            if (null == _channelNames)
            {
                return(null);
            }

            // 检测是否已经存在event item
            IEventSystemItem eventItem = GetEventItem(_eventItemName);

            if (null != eventItem)
            {
                return(eventItem);
            }

            // 检测 chanenl
            foreach (var channelName in _channelNames)
            {
                IEventSystemChannel eventSystemChannel = GetEventChannel(channelName);
                if (null == eventSystemChannel)
                {
                    var channel = AddEventChannel(channelName);
                    if (null == channel)
                    {
                        this.Error(string.Format("创建Event Item[{0}]时,对应的Channel[{1}]创建失败", _eventItemName, channelName));
                    }
                }
            }

            // 创建event item
            eventItem = new EventSystemItem(_eventItemName, _channelNames);
            eventItemDic.Add(eventItem.EventName, eventItem);
            EventItemCheck(eventItem);
            return(eventItem);
        }