SmartDIContainer.cs
/// <summary>
/// Removes a list of types that the parent type can be resolved as. Includes creators and storage rules.
/// </summary>
/// <typeparam name="TParent">The generic parent type</typeparam>
/// <param name="typesToUnregister">The types to remove.</param>
Removes a list of types that the parent type can be resolved as. Includes creators and storage rules.
Removes a list of types that the parent type can be resolved as . Includes creators and storage rules .
public void UnregisterTypeContracts<TParent>(params Type[] typesToUnregister)
      {
         if (!_registeredTypeContracts.ContainsKey(typeof(TParent)))
         {
            ThrowArgumentException(nameof(UnregisterTypeContracts),
                                   "The type ->" + typeof(TParent) +
                                   "<- cannot be unregistered because it was never is not registered");
            return;
         }
         if (typesToUnregister.IsEmpty())
         {
            _registeredTypeContracts.Remove(typeof(TParent));
            return;
         }
         var parentRegistrations = _registeredTypeContracts[typeof(TParent)];
         foreach (var type in typesToUnregister)
         {
            if (parentRegistrations.CreatorsAndStorageRules.ContainsKey(type))
            {
               parentRegistrations.CreatorsAndStorageRules.Remove(type);
            }
         }
         if (parentRegistrations.CreatorsAndStorageRules.IsEmpty())
         {
            _registeredTypeContracts.Remove(typeof(TParent));
         }
      }
public void UnregisterTypeContracts < TParent > ( params Type [ ] typesToUnregister ) { if ( ! _registeredTypeContracts . ContainsKey ( typeof ( TParent ) ) ) { ThrowArgumentException ( nameof ( UnregisterTypeContracts ) , " " + typeof ( TParent ) + " " ) ; return ; } if ( typesToUnregister . IsEmpty ( ) ) { _registeredTypeContracts . Remove ( typeof ( TParent ) ) ; return ; } var parentRegistrations = _registeredTypeContracts [ typeof ( TParent ) ] ; foreach ( var type in typesToUnregister ) { if ( parentRegistrations . CreatorsAndStorageRules . ContainsKey ( type ) ) { parentRegistrations . CreatorsAndStorageRules . Remove ( type ) ; } } if ( parentRegistrations . CreatorsAndStorageRules . IsEmpty ( ) ) { _registeredTypeContracts . Remove ( typeof ( TParent ) ) ; } }
Removes a list of types that the parent type can be resolved as.
Removes a list of types that the parent type can be resolved as .
// If no sub types named, try to clear the main type, which kills all sub elements // ELSE remove the sub types individually // If this leaves the collection empty, remove it.
typesToUnregister
The types to remove.
The types to remove .
typeparam
The generic parent type
The generic parent type