示例#1
0
        private static ComponentRegistration <TService> ResolveLifestyle <TService>(ComponentRegistration <TService> registration, Microsoft.Extensions.DependencyInjection.ServiceDescriptor service) where TService : class
        {
            switch (service.Lifetime)
            {
            case ServiceLifetime.Singleton:
                return(registration.LifeStyle.NetStatic());

            case ServiceLifetime.Scoped:
                return(registration.LifeStyle.ScopedToNetServiceScope());

            case ServiceLifetime.Transient:
                return(registration.LifestyleNetTransient());

            default:
                throw new System.ArgumentException($"Invalid lifetime {service.Lifetime}");
            }
        }