예제 #1
0
        /// <summary>
        /// Set scope based on <see cref="BindingLifecycle">ActivationScope</see>
        /// </summary>
        /// <param name="syntax"><see cref="IBindingInSyntax{T}">Binding syntax</see> to set the scope for</param>
        /// <param name="lifecycle"><see cref="BindingLifecycle"/> to use</param>
        public static void WithLifecycle <T>(this IBindingInSyntax <T> syntax, BindingLifecycle lifecycle)
        {
            switch (lifecycle)
            {
            case BindingLifecycle.Singleton:
                syntax.InSingletonScope();
                break;

#if (false)
            case BindingLifecycle.Request:
                syntax.InRequestScope();
                break;
#endif

#if (NET461)
            case BindingLifecycle.Thread:
                syntax.InThreadScope();
                break;
#endif


            case BindingLifecycle.Transient:
                syntax.InTransientScope();
                break;
            }
        }
예제 #2
0
        public static IBindingNamedWithOrOnSyntax <T> SetLifeStyle <T>(this IBindingInSyntax <T> registration, LifetimeScope lifeTimeKey)
        {
            switch (lifeTimeKey)
            {
            case LifetimeScope.Unowned:
                return(registration.InTransientScope());

            case LifetimeScope.PerHttpRequest:
                return(registration.InRequestScope());

            case LifetimeScope.PerThread:
                return(registration.InThreadScope());

            default:
                return(registration.InTransientScope());
            }
        }
 /// <summary>
 /// Sets the scope using the given syntax.
 /// </summary>
 /// <param name="syntax">The syntax that is used to set the scope.</param>
 public void SetScope(IBindingInSyntax <object> syntax)
 {
     syntax.InThreadScope();
 }