SmartDIContainer.cs
/// <summary>
/// Attempts to use the provided instance creator, if available, and reports the result.
/// </summary>
/// <param name="resolutionToSeek">The resolution to seek.</param>
/// <param name="finalTypeRequestedT">The final type requested t.</param>
/// <param name="instantiatedObject">The instantiated object.</param>
/// <returns><c>true</c> if a provided creator exists but failed to instantiate an object, else <c>false</c>.</returns>
Attempts to use the provided instance creator, if available, and reports the result.
Attempts to use the provided instance creator if available and reports the result .
private bool ProvidedCreatorFailed
      (
         KeyValuePair<Type, IProvideCreatorAndStorageRule> resolutionToSeek,
         Type                                              finalTypeRequestedT,
         ref object                                        instantiatedObject
      )
      {
         if (resolutionToSeek.Value.ProvidedCreator != null)
         {
            instantiatedObject = resolutionToSeek.Value.ProvidedCreator();
            if (instantiatedObject == null)
            {
               ThrowArgumentException(nameof(Resolve),
                                      "Could not create an object using the provided constructor.");
               return true;
            }
            if (!instantiatedObject.GetType().IsTypeOrAssignableFromType(finalTypeRequestedT))
            {
               return true;
            }
         }
         return false;
      }
private bool ProvidedCreatorFailed ( KeyValuePair < Type , IProvideCreatorAndStorageRule > resolutionToSeek , Type finalTypeRequestedT , ref object instantiatedObject ) { if ( resolutionToSeek . Value . ProvidedCreator != null ) { instantiatedObject = resolutionToSeek . Value . ProvidedCreator ( ) ; if ( instantiatedObject == null ) { ThrowArgumentException ( nameof ( Resolve ) , " " ) ; return true ; } if ( ! instantiatedObject . GetType ( ) . IsTypeOrAssignableFromType ( finalTypeRequestedT ) ) { return true ; } } return false ; }
Attempts to use the provided instance creator, if available, and reports the result.
Attempts to use the provided instance creator if available and reports the result .
// FAIL // *Must* be in this order // FAIL // ELSE the instated object is valid. Proceed as if we had created the object using activator create instance. // SUCCESS
None
resolutionToSeek
KeyValuePair<Type, IProvideCreatorAndStorageRule>
The resolution to seek.
The resolution to seek .
finalTypeRequestedT
Type
The final type requested t.
The final type requested t .
object
ref
instantiatedObject
The instantiated object.
The instantiated object .