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)); }
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); }
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); }