Example #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;
            }
        }
Example #2
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;
                    }
                }
            }
        }
Example #3
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;
        }