public AutomaticDependencyFactory(DependencyContainer dependency_container,
                                   ConstructorSelectionStrategy constructor_selection_strategy, Type type)
 {
     this.dependency_container = dependency_container;
     this.constructor_selection_strategy = constructor_selection_strategy;
     this.type = type;
 }
 public MagicWiringDependencyFactory(Type type_being_created, DependencyContainer container,
                                     ConstructorSelectionStrategy strategy)
 {
     this.type_being_created = type_being_created;
     this.container = container;
     this.strategy = strategy;
 }
Esempio n. 3
0
 public AutomaticDependencyFactory(Type type_to_create, IFetchDependencies container,
                                   ConstructorSelectionStrategy ctor_selector)
 {
   this.type_to_create = type_to_create;
   this.container = container;
   this.ctor_selector = ctor_selector;
 }
Esempio n. 4
0
        /// <summary>Builds the instance.</summary>
        /// <param name="type">The type. </param>
        /// <param name="strategy">The <see cref="ConstructorSelectionStrategy"/> that is used. </param>
        /// <returns>The instance </returns>
        /// <exception cref="ArgumentNullException"><paramref name="type"/> is null. </exception>
        /// <exception cref="ArgumentException">
        ///    <paramref name="type"/> is not a RuntimeType. -or-<paramref name="type"/> is an open generic type (that is, the
        ///    <see cref="P:System.Type.ContainsGenericParameters"/> property returns true).
        /// </exception>
        /// <exception cref="NotSupportedException">
        ///    <paramref name="type"/> cannot be a <see cref="T:System.Reflection.Emit.TypeBuilder"/>.-or- Creation of
        ///    <see cref="T:System.TypedReference"/>, <see cref="T:System.ArgIterator"/>, <see cref="T:System.Void"/>, and <see cref="T:System.RuntimeArgumentHandle"/> types, or arrays of
        ///    those types, is not supported.
        /// </exception>
        /// <exception cref="MethodAccessException">The caller does not have permission to call this constructor. </exception>
        /// <exception cref="MemberAccessException">Cannot create an instance of an abstract class, or this member was invoked with a late-binding mechanism. </exception>
        /// <exception cref="InvalidComObjectException">The COM type was not obtained through Overload:System.Type.GetTypeFromProgID" or "Overload:System.Type.GetTypeFromCLSID". </exception>
        /// <exception cref="MissingMethodException">No matching public constructor was found. </exception>
        /// <exception cref="COMException"><paramref name="type"/> is a COM object but the class identifier used to obtain the type is invalid, or the identified class is not registered. </exception>
        /// <exception cref="TypeLoadException"><paramref name="type"/> is not a valid type. </exception>
        /// <exception cref="TargetInvocationException">The constructor being called throws an exception. </exception>
        protected object BuildInstance(Type type, ConstructorSelectionStrategy strategy)
        {
            var args = DetermineConstructorArgs(type, strategy);

            if (args == null)
            {
                return(null);
            }
            return(ActivateInstance(type, args));
        }
Esempio n. 5
0
        private object[] DetermineConstructorArgs(Type implementation, ConstructorSelectionStrategy selectionStrategy)
        {
            var args        = new List <object>();
            var constructor = selectionStrategy.SelectCostructor(implementation);

            if (constructor == null)
            {
                return(null);
            }

            args.AddRange(constructor.GetParameters().Select(info => ResolveNamed(info.ParameterType, ComputeName(info))));
            return(args.ToArray());
        }
 public ObjectionStore(ImplementationResolver implementationResolver, ConstructorSelectionStrategy constructorSelectionStrategy)
 {
     this.implementationResolver       = implementationResolver;
     this.constructorSelectionStrategy = constructorSelectionStrategy;
     typedInstances            = new Hashtable();
     implementationTypes       = new Hashtable();
     dependencyImplementations = new Hashtable();
     namedTypes = new Hashtable();
     dependencyImplementationsForNames = new Hashtable();
     namedInstances = new Hashtable();
     AddInstanceForType(typeof(ObjectSource), this);
     AddInstanceForType(typeof(ObjectionManager), this);
     AddInstanceForType(typeof(ObjectionStore), this);
 }
		public ObjectionStore(ImplementationResolver implementationResolver, ConstructorSelectionStrategy constructorSelectionStrategy)
		{
			this.implementationResolver = implementationResolver;
			this.constructorSelectionStrategy = constructorSelectionStrategy;
			typedInstances = new Hashtable();
			implementationTypes = new Hashtable();
			dependencyImplementations = new Hashtable();
			namedTypes = new Hashtable();
			dependencyImplementationsForNames = new Hashtable();
			namedInstances = new Hashtable();
			AddInstanceForType(typeof(ObjectSource), this);
			AddInstanceForType(typeof(ObjectionManager), this);
			AddInstanceForType(typeof(ObjectionStore), this);
		}
Esempio n. 8
0
 public AutoWiringResolver(Type item_to_resolve, DependencyResolver dependency_resolver, ConstructorSelectionStrategy constructor_selection_strategy)
 {
     this.item_to_resolve = item_to_resolve;
     this.constructor_selection_strategy = constructor_selection_strategy;
     this.dependency_resolver = dependency_resolver;
 }
Esempio n. 9
0
 public AutoWiringFactory(ConstructorSelectionStrategy constructor_selection_strategy, Container container)
 {
     this.constructor_selection_strategy = constructor_selection_strategy;
     this.container = container;
 }
 public MagicWiringDependencyFactory(Type type_being_created, DependencyContainer container,
                                     ConstructorSelectionStrategy strategy)
 {
     this.constructor_selection_strategy = constructor_selection_strategy;
     this.the_type_that_is_being_created = the_type_that_is_being_created;
 }
 public DefaultDependencyFactoriesProvider(DependencyContainer dependency_container,
                                           ConstructorSelectionStrategy constructor_selection_strategy)
 {
     this.dependency_container = dependency_container;
     this.constructor_selection_strategy = constructor_selection_strategy;
 }