示例#1
0
        public void AddEventListener(ChimeraEvent type, object data, EventDelegat callback)
        {
            ChimeraEventResponce        result   = new ChimeraEventResponce();
            List <ChimeraEventResponce> listener = null;

            string key = StringEnum.GetStringValue(type);

            if (!listeners.ContainsKey(key))
            {
                listeners.Add(StringEnum.GetStringValue(type), null);
            }

            listeners.TryGetValue(StringEnum.GetStringValue(type), out listener);

            if (listener == null)
            {
                listener = new List <ChimeraEventResponce>();
            }

            if (!HasEventListener(type, callback))
            {
                result.Type     = type;
                result.Data     = data;
                result.Callback = callback;
                listener.Add(result);
                listeners[StringEnum.GetStringValue(type)] = listener;
            }
        }
示例#2
0
        public bool HasEventListener(ChimeraEvent type, EventDelegat callback)
        {
            bool result = false;
            List <ChimeraEventResponce> listener = null;

            if (listeners.ContainsKey(StringEnum.GetStringValue(type)))
            {
                listeners.TryGetValue(StringEnum.GetStringValue(type), out listener);

                if (listener != null)
                {
                    for (int i = 0; i < listener.Count; i++)
                    {
                        //				System.Runtime.Serialization.SerializationInfo info;
                        //				System.Runtime.Serialization.StreamingContext contex;
                        //				callback.GetObjectData(info,contex);

                        ChimeraEventResponce responce = listener[i];
                        if (responce.Callback == callback)
                        {
                            result = true;
                            break;
                        }
                    }
                }
            }
            return(result);
        }
示例#3
0
        public void AddEventListener(ChimeraEvent type, object data, EventDelegat callback)
        {
            ChimeraEventResponce result = new ChimeraEventResponce();
            List<ChimeraEventResponce> listener = null;

            string key = StringEnum.GetStringValue(type);

            if (!listeners.ContainsKey(key))
            {
                listeners.Add(StringEnum.GetStringValue(type), null);
            }

            listeners.TryGetValue(StringEnum.GetStringValue(type), out listener);

            if (listener == null)
            {
                listener = new List<ChimeraEventResponce>();
            }

            if (!HasEventListener(type, callback))
            {
                result.Type = type;
                result.Data = data;
                result.Callback = callback;
                listener.Add(result);
                listeners[StringEnum.GetStringValue(type)] = listener;
            }
        }
示例#4
0
        public static ChimeraEvent StringToChimeraEvent(string value)
        {
            ChimeraEvent result = ChimeraEvent.Default;

            foreach (ChimeraEvent type in Enum.GetValues(typeof(ChimeraEvent)))
            {
                if (StringEnum.GetStringValue((ChimeraEvent)type) == value)
                {
                    result = (ChimeraEvent)type;
                    break;
                }
            }
            return(result);
        }
示例#5
0
        public void RemoveEventListener(ChimeraEvent type, EventDelegat callback)
        {
            List <ChimeraEventResponce> listener = null;

            if (listeners.ContainsKey(StringEnum.GetStringValue(type)))
            {
                listeners.TryGetValue(StringEnum.GetStringValue(type), out listener);

                for (int i = 0; i < listener.Count; i++)
                {
                    ChimeraEventResponce responce = listener[i];
                    if (responce.Callback == callback)
                    {
                        listener.Remove(responce);
                        listeners[StringEnum.GetStringValue(type)] = listener;
                        break;
                    }
                }
            }
        }
示例#6
0
        public void DispatchEvent(ChimeraEvent type)
        {
            List <ChimeraEventResponce> listener = null;

            if (listeners.ContainsKey(StringEnum.GetStringValue(type)))
            {
                listeners.TryGetValue(StringEnum.GetStringValue(type), out listener);

                if (listener != null)
                {
                    for (int i = 0; i < listener.Count; i++)
                    {
                        ChimeraEventResponce response = listener[i];

                        if (response.Callback != null)
                        {
                            response.Callback(response);
                        }
                    }
                }
            }
        }
示例#7
0
        public void RemoveEventListener(ChimeraEvent type, EventDelegat callback)
        {
            List<ChimeraEventResponce> listener = null;
            if (listeners.ContainsKey(StringEnum.GetStringValue(type)))
            {
                listeners.TryGetValue(StringEnum.GetStringValue(type), out listener);

                for (int i = 0; i < listener.Count; i++)
                {
                    ChimeraEventResponce responce = listener[i];
                    if (responce.Callback == callback)
                    {
                        listener.Remove(responce);
                        listeners[StringEnum.GetStringValue(type)] = listener;
                        break;
                    }
                }
            }
        }
示例#8
0
        public bool HasEventListener(ChimeraEvent type, EventDelegat callback)
        {
            bool result = false;
            List<ChimeraEventResponce> listener = null;

            if (listeners.ContainsKey(StringEnum.GetStringValue(type)))
            {
                listeners.TryGetValue(StringEnum.GetStringValue(type), out listener);

                if (listener != null)
                {
                    for (int i = 0; i < listener.Count; i++)
                    {
                        //				System.Runtime.Serialization.SerializationInfo info;
                        //				System.Runtime.Serialization.StreamingContext contex;
                        //				callback.GetObjectData(info,contex);

                        ChimeraEventResponce responce = listener[i];
                        if (responce.Callback == callback)
                        {
                            result = true;
                            break;
                        }
                    }
                }
            }
            return result;
        }
示例#9
0
        public void DispatchEvent(ChimeraEvent type)
        {
            List<ChimeraEventResponce> listener = null;
            if (listeners.ContainsKey(StringEnum.GetStringValue(type)))
            {
                listeners.TryGetValue(StringEnum.GetStringValue(type), out listener);

                if (listener != null)
                {
                    for (int i = 0; i < listener.Count; i++)
                    {
                        ChimeraEventResponce response = listener[i];

                        if(response.Callback != null)
                        {
                            response.Callback(response);
                        }
                    }
                }
            }
        }