private static IEnumerable <IInstanceCreator> GetConstructorCreators(Type targetType, Type availableType)
        {
            Debug.Assert(targetType != null);
            Debug.Assert(availableType != null);
            Debug.Assert(!availableType.IsAbstract);

            if (targetType.ContainsGenericParameters)
            {
                Type definition = targetType.IsGenericParameter ? targetType : targetType.GetGenericTypeDefinition( );
                var  bindings   = new BindingCollection(Binding.EmptyBindings);
                GenericTypeResolver.GetAssignedGenericArguments(bindings, availableType, definition);

                foreach (var binding in bindings)
                {
                    Type resolvedType =
                        definition.IsGenericParameter
                            ? Binding.ForArgument(binding, definition).Type
                            : GenericTypeResolver.MakeConcreteType(definition, binding);

                    targetType = resolvedType;
                    break;
                }
            }

            var creators = new List <IInstanceCreator>( );

            // If type is an enumeration, get creator for enum values.
            if (availableType.IsEnum || availableType == typeof(bool))
            {
                creators.AddRange(WeakInstanceCreator.ForEnum(availableType));
            }
            // Otherwise, get creator for any default constructor.
            else if (Constraint.HasDefaultConstructor(availableType))
            {
                creators.Add(WeakInstanceCreator.ForType(availableType));
            }

            // Get creators for any parameterized constructors.
            var parameterizedConstructors = availableType.GetConstructors( ).Where((c) => c.GetParameters( ).Length > 0).ToArray( );

            if (parameterizedConstructors.Length < 3)
            {
                foreach (var constructor in parameterizedConstructors)
                {
                    creators.AddRange(TypeCreator.GetMethodCreators(targetType, constructor));
                }
            }

            return(creators);
        }
        public static Type MakeConcreteType(Type genericType, LinkList <Binding> bindings)
        {
            var openArguments = GenericTypeResolver.GetOpenGenericArguments(genericType);

            return(GenericTypeResolver.MakeConcreteType(genericType, openArguments, bindings));
        }
 /// <summary>
 /// Creates an instance of the <paramref name="genericType"/> by assigning each of the <paramref name="openArguments"/>
 ///  to the concrete type specified by the <paramref name="bindings"/>.
 /// </summary>
 public static Type CreateConcreteType(Type genericType, LinkList <Type> openArguments, LinkList <Binding> bindings)
 {
     return(GenericTypeResolver.MakeConcreteType(genericType, openArguments, bindings));
 }