Example #1
0
        public IRegistrationContainer Register(Type abstractType, Type concreteType,
                                               RegistrationLifeTime registrationLifeTime = RegistrationLifeTime.Transient, string key = null, bool shouldReplace = false)
        {
            _container.Register(abstractType, concreteType, registrationLifeTime.ToContainerLifeTime(), serviceKey: ResolveKey(key), ifAlreadyRegistered: Map(shouldReplace));

            return(this);
        }
Example #2
0
        public IRegistrationContainer Register(Type abstractType, Type concreteType,
                                               RegistrationLifeTime registrationLifeTime = RegistrationLifeTime.Transient, string key = null, bool shouldReplace = false)
        {
            _container.Register(abstractType, concreteType, registrationLifeTime.ToContainerLifeTime());

            return(this);
        }
Example #3
0
        public IRegistrationContainer RegisterDecorator(Type abstractType, Type decorator,
                                                        RegistrationLifeTime registrationLifeTime = RegistrationLifeTime.Transient, string key = null, bool shouldReplace = false)
        {
            var serviceKey = ResolveKey(key);

            if (string.IsNullOrEmpty(serviceKey))
            {
                _container.Register(abstractType, decorator, registrationLifeTime.ToContainerLifeTime(), setup: Setup.Decorator, ifAlreadyRegistered: Map(shouldReplace));
            }
            else
            {
                _container.Register(abstractType, decorator, registrationLifeTime.ToContainerLifeTime(), setup: Setup.DecoratorWith(r =>
                                                                                                                                    string.Equals(key, r.ServiceKey as string, StringComparison.OrdinalIgnoreCase)));
            }
            return(this);
        }
Example #4
0
        public IRegistrationContainer Register(Type concreteType, RegistrationTarget target,
                                               RegistrationLifeTime registrationLifeTime = RegistrationLifeTime.Transient, string key = null, bool shouldReplace = false)
        {
            var serviceTypeCondition = TargetResolver.Resolve(target);

            _container.RegisterMany(new[] { concreteType }, registrationLifeTime.ToContainerLifeTime(), serviceTypeCondition: serviceTypeCondition, serviceKey: ResolveKey(key), ifAlreadyRegistered: Map(shouldReplace));
            return(this);
        }
Example #5
0
        public IRegistrationContainer Register <TAbstract, TConcrete>(
            RegistrationLifeTime registrationLifeTime = RegistrationLifeTime.Transient,
            Action <TAbstract> cleanupAction          = null,
            string key = null, bool shouldReplace = false) where TAbstract : class where TConcrete : class, TAbstract
        {
            _container.Register <TAbstract, TConcrete>(registrationLifeTime.ToContainerLifeTime());

            return(this);
        }
Example #6
0
        public IRegistrationContainer RegisterFactory <TAbstract>(Func <IResolutionContainer, TAbstract> factoryFunc,
                                                                  RegistrationLifeTime registrationLifeTime = RegistrationLifeTime.Transient, string key = null, bool shouldReplace = false) where TAbstract : class

        {
            SimpleInjectorIocResolverAdapter c = SimpleInjectorIocResolverAdapter.Adapt(_container);

            _container.Register <TAbstract>(() => factoryFunc(c), registrationLifeTime.ToContainerLifeTime());
            return(this);
        }
Example #7
0
        public IRegistrationContainer Register(Type concreteType, RegistrationTarget target,
                                               RegistrationLifeTime registrationLifeTime = RegistrationLifeTime.Transient, string key = null, bool shouldReplace = false)
        {
            var serviceTypeCondition = TargetResolver.Resolve(target);

            //_container.Register(concreteType);
            //_container.Register( concreteType.UnderlyingSystemType, () => concreteType, registrationLifeTime.ToContainerLifeTime());
            _container.Register(concreteType.GetType(), () => concreteType, registrationLifeTime.ToContainerLifeTime());
            return(this);
        }
Example #8
0
        public IRegistrationContainer Register <TAbstract, TConcrete>(
            RegistrationLifeTime registrationLifeTime = RegistrationLifeTime.Transient,
            Action <TAbstract> cleanupAction          = null,
            string key = null, bool shouldReplace = false) where TAbstract : class where TConcrete : class, TAbstract
        {
            _container.Register <TAbstract, TConcrete>(registrationLifeTime.ToContainerLifeTime(), serviceKey: ResolveKey(key), ifAlreadyRegistered: Map(shouldReplace));

            if (cleanupAction != null)
            {
                _container.RegisterDisposer(cleanupAction);
            }

            return(this);
        }
Example #9
0
        public IRegistrationContainer RegisterFactory <TAbstract>(Func <IResolutionContainer, TAbstract> factoryFunc,
                                                                  RegistrationLifeTime registrationLifeTime = RegistrationLifeTime.Transient, string key = null, bool shouldReplace = false) where TAbstract : class

        {
            _container.RegisterDelegate(_ => factoryFunc(DryIocResolverAdapter.Adapt(_container)), registrationLifeTime.ToContainerLifeTime(), serviceKey: ResolveKey(key), ifAlreadyRegistered: Map(shouldReplace));
            return(this);
        }