Example #1
0
        private void AddReceiver(LoadedMod parent, Type eventType, MethodInfo receiver, int priority)
        {
            List <ReceiverSwitch> list;

            if (!_receivers.TryGetValue(eventType, out list))
            {
                list = new List <ReceiverSwitch>();
                _receivers.Add(eventType, list);
            }

            var idx = -1;

            for (var i = 0; i < list.Count; i++)
            {
                if (priority > list[i].Priority)
                {
                    idx = i;
                    break;
                }
            }

            var @switch = new ReceiverSwitch {
                Mod = parent, Info = receiver, Priority = priority, Enabled = true
            };

            if (idx == -1)
            {
                list.Add(@switch);
            }
            else
            {
                list.Insert(idx, @switch);
            }
        }
Example #2
0
        public void AddReceiver(string eventType, ReceiverSwitch @switch)
        {
            List <ReceiverSwitch> list;

            if (!_receivers.TryGetValue(eventType, out list))
            {
                list = new List <ReceiverSwitch>();
                _receivers.Add(eventType, list);
            }

            var idx = -1;

            for (var i = 0; i < list.Count; i++)
            {
                if (@switch.Priority > list[i].Priority)
                {
                    idx = i;
                    break;
                }
            }

            @switch.Enabled = true;

            if (idx == -1)
            {
                list.Add(@switch);
            }
            else
            {
                list.Insert(idx, @switch);
            }
        }