Esempio n. 1
0
        public void Register <T>(Action <T> handler) where T : class
        {
            var entry = new TargetAndMethodInfo()
            {
                Target     = new WeakReference <object>(handler.Target),
                MethodInfo = handler.Method
            };

            Register(entry, typeof(T));
        }
Esempio n. 2
0
        private void Register(TargetAndMethodInfo entry, Type type)
        {
            List <TargetAndMethodInfo> list;

            lock (_registrations)
            {
                if (!_registrations.TryGetValue(type, out list))
                {
                    list = new List <TargetAndMethodInfo>();
                    _registrations.Add(type, list);
                }
            }

            lock (list) list.Add(entry);
        }
Esempio n. 3
0
        public void Register <T>(Action <T> handler) where T : class
        {
            List <TargetAndMethodInfo> list;
            var type = typeof(T);

            var entry = new TargetAndMethodInfo()
            {
                Target     = new WeakReference <object>(handler.Target),
                MethodInfo = handler.Method
            };

            lock (_registrations)
            {
                if (!_registrations.TryGetValue(type, out list))
                {
                    list = new List <TargetAndMethodInfo>();
                    _registrations.Add(type, list);
                }
            }

            lock (list) list.Add(entry);
        }