/// <summary> /// Adds a service of <paramref name="serviceType"/> with an <paramref name="implementationType"/>. /// </summary> /// <param name="lifetime">The lifetime of the service to register.</param> /// <param name="serviceType">The type of the service to register.</param> /// <param name="implementationType">The implementation type of the service.</param> /// <returns>The <see cref="IContainerBuilder"/> instance itself.</returns> public virtual IContainerBuilder AddService(ODataServiceLifetime lifetime, Type serviceType, Type implementationType) { Ensure.NotNull(serviceType, nameof(serviceType)); Ensure.NotNull(implementationType, nameof(implementationType)); Services.Add(new ServiceDescriptor(serviceType, implementationType, TranslateServiceLifetime(lifetime))); return(this); }
/// <summary> /// Adds a service of <paramref name="serviceType"/> with an <paramref name="implementationFactory"/>. /// </summary> /// <param name="lifetime">The lifetime of the service to register.</param> /// <param name="serviceType">The type of the service to register.</param> /// <param name="implementationFactory">The factory that creates the service.</param> /// <returns>The <see cref="IContainerBuilder"/> instance itself.</returns> public IContainerBuilder AddService(ODataServiceLifetime lifetime, Type serviceType, Func <IServiceProvider, object> implementationFactory) { Ensure.NotNull(serviceType, nameof(serviceType)); Ensure.NotNull(implementationFactory, nameof(implementationFactory)); Services.Add(new ServiceDescriptor(serviceType, implementationFactory, TranslateServiceLifetime(lifetime))); return(this); }
public virtual IContainerBuilder AddService(Microsoft.OData.ServiceLifetime lifetime, Type serviceType, Type implementationType) { services.Add(new ServiceDescriptor( serviceType ?? throw new ArgumentNullException(nameof(serviceType)), implementationType ?? throw new ArgumentNullException(nameof(implementationType)), TranslateServiceLifetime(lifetime))); return(this); }
public IContainerBuilder AddService(Microsoft.OData.ServiceLifetime lifetime, Type serviceType, Func <IServiceProvider, object> implementationFactory) { services.Add(new ServiceDescriptor( serviceType ?? throw new ArgumentNullException(nameof(serviceType)), implementationFactory ?? throw new ArgumentNullException(nameof(implementationFactory)), TranslateServiceLifetime(lifetime))); return(this); }
public override IContainerBuilder AddService( ServiceLifetime lifetime, Type serviceType, Type implementationType) { if (serviceType == typeof(ITestService)) { return(base.AddService(lifetime, serviceType, typeof(TestService2))); } return(base.AddService(lifetime, serviceType, implementationType)); }
/// <summary> /// /// </summary> /// <param name="lifetime"></param> /// <returns></returns> private static DIServiceLifetime TranslateServiceLifetime(ODataServiceLifetime lifetime) { switch (lifetime) { case ODataServiceLifetime.Scoped: return(DIServiceLifetime.Scoped); case ODataServiceLifetime.Singleton: return(DIServiceLifetime.Singleton); default: return(DIServiceLifetime.Transient); } }
private static Microsoft.Extensions.DependencyInjection.ServiceLifetime TranslateServiceLifetime( Microsoft.OData.ServiceLifetime lifetime) { switch (lifetime) { case Microsoft.OData.ServiceLifetime.Scoped: return(Microsoft.Extensions.DependencyInjection.ServiceLifetime.Scoped); case Microsoft.OData.ServiceLifetime.Singleton: return(Microsoft.Extensions.DependencyInjection.ServiceLifetime.Singleton); default: return(Microsoft.Extensions.DependencyInjection.ServiceLifetime.Transient); } }
/// <summary> /// Adds a service of <paramref name="serviceType"/> with an <paramref name="implementationType"/>. /// </summary> /// <param name="lifetime">The lifetime of the service to register.</param> /// <param name="serviceType">The type of the service to register.</param> /// <param name="implementationType">The implementation type of the service.</param> /// <returns>The <see cref="IContainerBuilder"/> instance itself.</returns> public IContainerBuilder AddService(ServiceLifetime lifetime, Type serviceType, Type implementationType) { if (serviceType == null) { throw Error.ArgumentNull("serviceType"); } if (implementationType == null) { throw Error.ArgumentNull("implementationType"); } _services.Add(new ServiceDescriptor( serviceType, implementationType, TranslateServiceLifetime(lifetime))); return(this); }
/// <summary> /// Adds a service of <paramref name="serviceType"/> with an <paramref name="implementationFactory"/>. /// </summary> /// <param name="lifetime">The lifetime of the service to register.</param> /// <param name="serviceType">The type of the service to register.</param> /// <param name="implementationFactory">The factory that creates the service.</param> /// <returns>The <see cref="IContainerBuilder"/> instance itself.</returns> public IContainerBuilder AddService(ServiceLifetime lifetime, Type serviceType, Func <IServiceProvider, object> implementationFactory) { if (serviceType == null) { throw Error.ArgumentNull("serviceType"); } if (implementationFactory == null) { throw Error.ArgumentNull("implementationFactory"); } _services.Add(new ServiceDescriptor( serviceType, implementationFactory, TranslateServiceLifetime(lifetime))); return(this); }
/// <summary> /// Adds a service of <paramref name="serviceType"/> with an <paramref name="implementationFactory"/>. /// </summary> /// <param name="lifetime">The lifetime of the service to register.</param> /// <param name="serviceType">The type of the service to register.</param> /// <param name="implementationFactory">The factory that creates the service.</param> /// <returns>The <see cref="Microsoft.OData.IContainerBuilder"/> instance itself.</returns> public virtual IContainerBuilder AddService(Microsoft.OData.ServiceLifetime lifetime, Type serviceType, Func <IServiceProvider, object> implementationFactory) { if (serviceType == null) { throw Error.ArgumentNull(nameof(serviceType)); } if (implementationFactory == null) { throw Error.ArgumentNull(nameof(implementationFactory)); } Services.Add(new ServiceDescriptor( serviceType, implementationFactory, TranslateServiceLifetime(lifetime))); return(this); }
/// <summary> /// Adds a service of <paramref name="serviceType"/> with an <paramref name="implementationFactory"/>. /// </summary> /// <param name="lifetime">The lifetime of the service to register.</param> /// <param name="serviceType">The type of the service to register.</param> /// <param name="implementationFactory">The factory that creates the service.</param> /// <returns>The <see cref="IContainerBuilder"/> instance itself.</returns> public IContainerBuilder AddService( ServiceLifetime lifetime, Type serviceType, Func<IServiceProvider, object> implementationFactory) { if (serviceType == null) { throw new ArgumentException(string.Format( CultureInfo.InvariantCulture, Resources.ArgumentCanNotBeNull, "serviceType")); } if (implementationFactory == null) { throw new ArgumentException(string.Format( CultureInfo.InvariantCulture, Resources.ArgumentCanNotBeNull, "implementationFactory")); } services.Add(new ServiceDescriptor( serviceType, implementationFactory, TranslateServiceLifetime(lifetime))); return this; }
/// <summary> /// Adds a service of <paramref name="serviceType"/> with an <paramref name="implementationFactory"/>. /// </summary> /// <param name="lifetime">The lifetime of the service to register.</param> /// <param name="serviceType">The type of the service to register.</param> /// <param name="implementationFactory">The factory that creates the service.</param> /// <returns>The <see cref="IContainerBuilder"/> instance itself.</returns> public IContainerBuilder AddService( ServiceLifetime lifetime, Type serviceType, Func <IServiceProvider, object> implementationFactory) { if (serviceType == null) { throw new ArgumentException(string.Format( CultureInfo.InvariantCulture, Resources.ArgumentCanNotBeNull, "serviceType")); } if (implementationFactory == null) { throw new ArgumentException(string.Format( CultureInfo.InvariantCulture, Resources.ArgumentCanNotBeNull, "implementationFactory")); } services.Add(new ServiceDescriptor( serviceType, implementationFactory, TranslateServiceLifetime(lifetime))); return(this); }
public virtual IContainerBuilder AddService(Microsoft.OData.ServiceLifetime lifetime, Type serviceType, Func <IServiceProvider, object> implementationFactory) { _defaultContainerBuilder.AddService(lifetime, serviceType, implementationFactory); return(this); }
private static Microsoft.Extensions.DependencyInjection.ServiceLifetime TranslateServiceLifetime( ServiceLifetime lifetime) { switch (lifetime) { case ServiceLifetime.Scoped: return Microsoft.Extensions.DependencyInjection.ServiceLifetime.Scoped; case ServiceLifetime.Singleton: return Microsoft.Extensions.DependencyInjection.ServiceLifetime.Singleton; default: return Microsoft.Extensions.DependencyInjection.ServiceLifetime.Transient; } }
public IContainerBuilder AddService(Microsoft.OData.ServiceLifetime lifetime, Type serviceType, Func <IServiceProvider, object> implementationFactory) { return(null); }
public IContainerBuilder AddService(Microsoft.OData.ServiceLifetime lifetime, Type serviceType, Type implementationType) { return(null); }
public virtual IContainerBuilder AddService(Microsoft.OData.ServiceLifetime lifetime, Type serviceType, Type implementationType) { _defaultContainerBuilder.AddService(lifetime, serviceType, implementationType); return(this); }
public virtual IServiceProvider BuildContainer() => services.BuildServiceProvider(); // workaround is here, don't use reflection to call BuildServiceProvider private static Microsoft.Extensions.DependencyInjection.ServiceLifetime TranslateServiceLifetime(Microsoft.OData.ServiceLifetime lifetime) => lifetime switch {