コード例 #1
0
        public void FireEvent(string eventName, object state)
        {
            OxiteEvent foundEvent = GetEvent(eventName);

            if (foundEvent != null)
            {
                foreach (Action <object> method in foundEvent.Methods)
                {
                    method(state);
                }
            }
        }
コード例 #2
0
        public void Add(string eventName, Action <object> method)
        {
            OxiteEvent evnt = GetEvent(eventName);

            if (evnt == null)
            {
                evnt = new OxiteEvent(eventName);

                events.Add(evnt);
            }

            evnt.Methods.Add(method);
        }
コード例 #3
0
        public void Remove(string eventName, Action <object> method)
        {
            OxiteEvent evnt = GetEvent(eventName);

            if (evnt != null)
            {
                evnt.Methods.Remove(method);

                if (evnt.Methods.Count == 0)
                {
                    events.Remove(evnt);
                }
            }
        }
コード例 #4
0
        public OxiteEvent GetEvent(string eventName)
        {
            OxiteEvent foundEvent = null;

            foreach (OxiteEvent evnt in events)
            {
                if (string.Compare(evnt.Name, eventName, true) == 0)
                {
                    foundEvent = evnt;

                    break;
                }
            }

            return(foundEvent);
        }