示例#1
0
        public virtual void TriggerEvent <R>(R eventData) where R : TEventInfo
        {
            var eventList = new List <TBindingInfo>();

            eventList.AddRange(_registedInfoList);

            HashSet <TBindingInfo> toDeleteBindingInfoList = new HashSet <TBindingInfo>();

            using (var itr = eventList.GetEnumerator())
            {
                var control   = new EventControl();
                var eventType = eventData.GetType();

                while (itr.MoveNext())
                {
                    var m = itr.Current;
                    if (toDeleteBindingInfoList.Contains(m))
                    {
                        continue;
                    }

                    if (eventType == m.BindingType || eventType.IsSubclassOf(m.BindingType))
                    {
                        CallEventDelegate(eventData, m, control);

                        if (control.RemoveThisBinding)
                        {
                            toDeleteBindingInfoList.Add(m);
                            control.RemoveThisBinding = false;
                        }

                        if (control.CancelFollowingFiring)
                        {
                            break;
                        }
                    }
                }
            }

            if (toDeleteBindingInfoList.Count != 0)
            {
                _registedInfoList.RemoveAll(info => toDeleteBindingInfoList.Contains(info));
                toDeleteBindingInfoList.Clear();
            }
        }
示例#2
0
 protected abstract void CallEventDelegate(TEventInfo eventInfo, TBindingInfo bindingInfo, EventControl control);
示例#3
0
 protected override void CallEventDelegate(GlobalEventInfo eventInfo, EventBindingInfo bindingInfo, EventControl control)
 {
     bindingInfo.Callback.DynamicInvoke(eventInfo, control);
 }