Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        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);
        }