Esempio n. 1
0
        public void Register <TInterface, TImplement>(DILifeTime lifeTime,
                                                      Action <ICtorSelectorExpression <TImplement, TInterface> > ctorInjectorExpression)
            where TInterface : class
            where TImplement : class, TInterface
        {
            var @for = this.configuration.For <TInterface>();
            var use  = @for.Use <TImplement>();

            var ctorSelectorExpression = new SMCtorSelectorExpression <TImplement, TInterface>();

            ctorSelectorExpression.Register(@for, use, null, lifeTime, SetLifeTime);//Use, lifeTime, setLifeTime and Name only used for Empty constructors
            ctorInjectorExpression(ctorSelectorExpression);

            SetLifeTime(lifeTime, use);
        }
Esempio n. 2
0
        public void Register <TInterface, TImplement>(string name,
                                                      DILifeTime lifeTime,
                                                      Action <ICtorSelectorExpression <TImplement, TInterface> > ctorInjectorExpression)
            where TInterface : class
            where TImplement : class, TInterface
        {
            var register = this.configuration.For <TInterface>();
            var use      = register.Use <TImplement>();

            use.Named(name);

            var ctorSelectorExpression = new SMCtorSelectorExpression <TImplement, TInterface>();

            ctorSelectorExpression.Register(register, use, name, lifeTime, SetLifeTime);//Use, lifeTime, setLifeTime and Name only used for Empty constructors
            ctorInjectorExpression(ctorSelectorExpression);

            register.Use(() => Activator.CreateInstance <TImplement>());

            SetLifeTime(lifeTime, use);
        }