public IContainerBuilder AddService( 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); }
public IContainerBuilder AddService( OData.ServiceLifetime lifetime, Type serviceType, Type implementationType) { Debug.Assert(serviceType != null, "serviceType != null"); Debug.Assert(implementationType != null, "implementationType != null"); services.Add(new ServiceDescriptor( serviceType, implementationType, TranslateServiceLifetime(lifetime))); return(this); }
private static ServiceLifetime TranslateServiceLifetime( OData.ServiceLifetime lifetime) { switch (lifetime) { case OData.ServiceLifetime.Scoped: return(ServiceLifetime.Scoped); case OData.ServiceLifetime.Singleton: return(ServiceLifetime.Singleton); default: return(ServiceLifetime.Transient); } }