private static IEnumerable <IInstanceCreator> GetInstanceCreators(Type targetType, Type availableType) { Debug.Assert(targetType != null); Debug.Assert(availableType != null); // If type is generic, find all concrete types. if (availableType.ContainsGenericParameters) { return(TypeCreator.GetGenericCreators(targetType, availableType)); } // If given type derives from target base type, check constructors. if (availableType.Is(targetType)) { return(GetConstructorCreators(targetType, availableType)); } // If type is a static factory, check for usable factory methods. if (availableType.IsAbstract && availableType.IsSealed && availableType.Name.StartsWith("Factory")) { return(GetFactoryCreators(targetType, availableType)); } // Cannot use type to create instances of the target type. return(Enumerable.Empty <IInstanceCreator>( )); }