public static void Unregister(IDynamicRefTarget dynamicRefTarget) { //remove by id if (!string.IsNullOrEmpty(dynamicRefTarget.Id)) { _refsById.Remove(dynamicRefTarget.Id); } //remove by type Type refType = dynamicRefTarget.Target.GetType(); List <IDynamicRefTarget> dynamicReferences; if (_refsByType.TryGetValue(refType, out dynamicReferences)) { dynamicReferences.Remove(dynamicRefTarget); } }
public static void Register(IDynamicRefTarget dynamicRefTarget) { //add by id if (!string.IsNullOrEmpty(dynamicRefTarget.Id)) { _refsById[dynamicRefTarget.Id] = dynamicRefTarget; } //add by type Type refType = dynamicRefTarget.Target.GetType(); List <IDynamicRefTarget> dynamicReferences; if (!_refsByType.TryGetValue(refType, out dynamicReferences)) { dynamicReferences = new List <IDynamicRefTarget>(); _refsByType.Add(refType, dynamicReferences); } dynamicReferences.Add(dynamicRefTarget); }