Ejemplo n.º 1
0
        public IContainerBuilder AddService(
            Microsoft.OData.ServiceLifetime lifetime,
            Type serviceType,
            Func <IServiceProvider, object> implementationFactory)
        {
            Debug.Assert(serviceType != null, "serviceType != null");
            Debug.Assert(implementationFactory != null, "implementationFactory != null");

            services.Add(new ServiceDescriptor(
                             serviceType, implementationFactory, TranslateServiceLifetime(lifetime)));

            return(this);
        }
Ejemplo n.º 2
0
        private static ServiceLifetime TranslateServiceLifetime(
            Microsoft.OData.ServiceLifetime lifetime)
        {
            switch (lifetime)
            {
            case Microsoft.OData.ServiceLifetime.Scoped:
                return(ServiceLifetime.Scoped);

            case Microsoft.OData.ServiceLifetime.Singleton:
                return(ServiceLifetime.Singleton);

            default:
                return(ServiceLifetime.Transient);
            }
        }