Ejemplo n.º 1
0
        PerLifeStyle <TLimit, TActivatorData, TRegistrationStyle>
            (this global::Autofac.Builder.IRegistrationBuilder <TLimit, TActivatorData, TRegistrationStyle> builder,
            BindingLifecycle lifecycle)
        {
            //no thread lifecycle
            switch (lifecycle)
            {
            case BindingLifecycle.Transient:
                return(builder.InstancePerDependency());

            case BindingLifecycle.Singleton:
                return(builder.SingleInstance());

            default:
                return(builder.InstancePerDependency());
            }
        }
Ejemplo n.º 2
0
        public static global::Autofac.Builder.IRegistrationBuilder <TLimit, TActivatorData, TRegistrationStyle> PerLifeStyle <TLimit, TActivatorData, TRegistrationStyle>(this global::Autofac.Builder.IRegistrationBuilder <TLimit, TActivatorData, TRegistrationStyle> builder, ComponentLifeStyle lifeStyle)
        {
            switch (lifeStyle)
            {
            case ComponentLifeStyle.LifetimeScope:
                return(HttpContext.Current != null?builder.InstancePerHttpRequest() : builder.InstancePerLifetimeScope());

            case ComponentLifeStyle.Transient:
                return(builder.InstancePerDependency());

            case ComponentLifeStyle.Singleton:
                return(builder.SingleInstance());

            default:
                return(builder.SingleInstance());
            }
        }
Ejemplo n.º 3
0
        public static global::Autofac.Builder.IRegistrationBuilder <TLimit, TActivatorData, TRegistrationStyle> PerLifeStyle <TLimit, TActivatorData, TRegistrationStyle>(
            this global::Autofac.Builder.IRegistrationBuilder <TLimit, TActivatorData, TRegistrationStyle> builder, Ricky.Infrastructure.Core.ObjectContainer.Dependency.ComponentLifeStyle lifeStyle)
        {
            switch (lifeStyle)
            {
            case ComponentLifeStyle.InRequestScope:
                //return HttpContext.Current != null ? builder.InstancePerHttpRequest() : builder.InstancePerLifetimeScope();
                return(HttpContext.Current != null?builder.InstancePerRequest() : builder.InstancePerLifetimeScope());

            //return builder.InstancePerLifetimeScope();
            case ComponentLifeStyle.Transient:
                return(builder.InstancePerDependency());

            case ComponentLifeStyle.Singleton:
                return(builder.SingleInstance());

            default:
                return(builder.SingleInstance());
            }
        }