Exemplo n.º 1
0
 public DependencyRegistration OverrideLifetimeManager(DependencyLifetimeManager manager)
 {
     return(new DependencyRegistration(
                ServiceType,
                ConcreteType,
                Lifetime,
                manager,
                Factory));
 }
 public DependencyRegistration(Type serviceType, Type concreteType, DependencyLifetimeManager lifetime, object instance)
 {
     Key = Guid.NewGuid().ToString();
     LifetimeManager = lifetime;
     ServiceType = serviceType;
     ConcreteType = concreteType;
     Constructors =
         new List<KeyValuePair<ConstructorInfo, ParameterInfo[]>>(
             concreteType.GetConstructors().Select(ctor => new KeyValuePair<ConstructorInfo, ParameterInfo[]>(ctor, ctor.GetParameters())));
     Constructors.Sort((kv1, kv2) => kv1.Value.Length.CompareTo(kv2.Value.Length) * -1);
     Instance = instance;
     IsInstanceRegistration = instance != null;
 }
Exemplo n.º 3
0
 public DependencyRegistration(Type serviceType, Type concreteType, DependencyLifetimeManager lifetime, object instance)
 {
     Key             = Guid.NewGuid().ToString();
     LifetimeManager = lifetime;
     ServiceType     = serviceType;
     ConcreteType    = concreteType;
     Constructors    =
         new List <KeyValuePair <ConstructorInfo, ParameterInfo[]> >(
             concreteType.GetConstructors().Select(ctor => new KeyValuePair <ConstructorInfo, ParameterInfo[]>(ctor, ctor.GetParameters())));
     Constructors.Sort((kv1, kv2) => kv1.Value.Length.CompareTo(kv2.Value.Length) * -1);
     Instance = instance;
     IsInstanceRegistration = instance != null;
 }
Exemplo n.º 4
0
 public DependencyRegistration(
     Type serviceType,
     Type concreteType,
     DependencyLifetime lifetime,
     DependencyLifetimeManager lifetimeManager,
     Func <ResolveContext, object> factory = null)
 {
     Key             = Guid.NewGuid().ToString();
     LifetimeManager = lifetimeManager;
     ServiceType     = serviceType;
     ConcreteType    = concreteType;
     Lifetime        = lifetime;
     Constructors    =
         new List <KeyValuePair <ConstructorInfo, ParameterInfo[]> >(
             concreteType.GetConstructors()
             .Select(ctor => new KeyValuePair <ConstructorInfo, ParameterInfo[]>(ctor, ctor.GetParameters())));
     Constructors.Sort((kv1, kv2) => kv1.Value.Length.CompareTo(kv2.Value.Length) * -1);
     Factory = factory ?? DefaultFactory;
 }
        public DependencyRegistration(Type serviceType, Type concreteType, DependencyLifetimeManager lifetime,
            object instance, Func<IDependencyResolver, object> factoryFunction)
        {
            Key = Guid.NewGuid().ToString();
            LifetimeManager = lifetime;
            ServiceType = serviceType;

            Instance = instance;
            FactoryFunction = factoryFunction;
            SetRegistrationKind();

            if (RegistrationKind == RegistrationKind.ConcreteType)
            {
                ConcreteType = concreteType;
                Constructors = new List<KeyValuePair<ConstructorInfo, ParameterInfo[]>>(
                    concreteType.GetConstructors().Select(
                        ctor => new KeyValuePair<ConstructorInfo, ParameterInfo[]>(ctor, ctor.GetParameters())));

                Constructors.Sort((kv1, kv2) => kv1.Value.Length.CompareTo(kv2.Value.Length) * -1);
            }
        }
 public DependencyRegistration(Type serviceType, Type concreteType, DependencyLifetimeManager lifetime)
     : this(serviceType, concreteType, lifetime, null)
 {
 }
 public DependencyRegistration(Type serviceType, Func<IDependencyResolver, object> factoryFunction, DependencyLifetimeManager lifetime)
     : this(serviceType, serviceType, lifetime, null, factoryFunction)
 {
 }
Exemplo n.º 8
0
 public DependencyRegistration(Type serviceType, Type concreteType, DependencyLifetimeManager lifetime)
     : this(serviceType, concreteType, lifetime, null)
 {
 }