ServiceCollectionMap.TryAddSingleton Method
Definition
Overloads
TryAddSingleton(Type, Type) |
Adds a Singleton service implemented by the given concrete type if no service for the given service type has already been registered. |
TryAddSingleton(Type, Func<IServiceProvider,Object>) |
Adds a Singleton service implemented by the given factory if no service for the given service type has already been registered. |
TryAddSingleton(Type, Object) |
Adds a Singleton service implemented by the given instance if no service for the given service type has already been registered. |
TryAddSingleton<TService,TImplementation>() |
Adds a Singleton service implemented by the given concrete type if no service for the given service type has already been registered. |
TryAddSingleton<TService,TImplementation>(Func<IServiceProvider,TImplementation>) |
Adds a Singleton service implemented by the given factory if no service for the given service type has already been registered. |
TryAddSingleton<TService>(Func<IServiceProvider,TService>) |
Adds a Singleton service implemented by the given factory if no service for the given service type has already been registered. |
TryAddSingleton<TService>(TService) |
Adds a Singleton service implemented by the given instance if no service for the given service type has already been registered. |
TryAddSingleton(Type, Type)
Adds a Singleton service implemented by the given concrete type if no service for the given service type has already been registered.
public virtual Microsoft.EntityFrameworkCore.Infrastructure.ServiceCollectionMap TryAddSingleton (Type serviceType, Type implementationType);
abstract member TryAddSingleton : Type * Type -> Microsoft.EntityFrameworkCore.Infrastructure.ServiceCollectionMap
override this.TryAddSingleton : Type * Type -> Microsoft.EntityFrameworkCore.Infrastructure.ServiceCollectionMap
Public Overridable Function TryAddSingleton (serviceType As Type, implementationType As Type) As ServiceCollectionMap
Parameters
- serviceType
- Type
The contract for the service.
- implementationType
- Type
The concrete type that implements the service.
Returns
The map, such that further calls can be chained.
Applies to
TryAddSingleton(Type, Func<IServiceProvider,Object>)
Adds a Singleton service implemented by the given factory if no service for the given service type has already been registered.
public virtual Microsoft.EntityFrameworkCore.Infrastructure.ServiceCollectionMap TryAddSingleton (Type serviceType, Func<IServiceProvider,object> factory);
abstract member TryAddSingleton : Type * Func<IServiceProvider, obj> -> Microsoft.EntityFrameworkCore.Infrastructure.ServiceCollectionMap
override this.TryAddSingleton : Type * Func<IServiceProvider, obj> -> Microsoft.EntityFrameworkCore.Infrastructure.ServiceCollectionMap
Public Overridable Function TryAddSingleton (serviceType As Type, factory As Func(Of IServiceProvider, Object)) As ServiceCollectionMap
Parameters
- serviceType
- Type
The contract for the service.
- factory
- Func<IServiceProvider,Object>
The factory that implements the service.
Returns
The map, such that further calls can be chained.
Applies to
TryAddSingleton(Type, Object)
Adds a Singleton service implemented by the given instance if no service for the given service type has already been registered.
public virtual Microsoft.EntityFrameworkCore.Infrastructure.ServiceCollectionMap TryAddSingleton (Type serviceType, object implementation);
abstract member TryAddSingleton : Type * obj -> Microsoft.EntityFrameworkCore.Infrastructure.ServiceCollectionMap
override this.TryAddSingleton : Type * obj -> Microsoft.EntityFrameworkCore.Infrastructure.ServiceCollectionMap
Public Overridable Function TryAddSingleton (serviceType As Type, implementation As Object) As ServiceCollectionMap
Parameters
- serviceType
- Type
The contract for the service.
- implementation
- Object
The object that implements the service.
Returns
The map, such that further calls can be chained.
Applies to
TryAddSingleton<TService,TImplementation>()
Adds a Singleton service implemented by the given concrete type if no service for the given service type has already been registered.
public virtual Microsoft.EntityFrameworkCore.Infrastructure.ServiceCollectionMap TryAddSingleton<TService,TImplementation> () where TService : class where TImplementation : class, TService;
abstract member TryAddSingleton : unit -> Microsoft.EntityFrameworkCore.Infrastructure.ServiceCollectionMap (requires 'Service : null)
override this.TryAddSingleton : unit -> Microsoft.EntityFrameworkCore.Infrastructure.ServiceCollectionMap (requires 'Service : null)
Public Overridable Function TryAddSingleton(Of TService As Class, TImplementation As Class) () As ServiceCollectionMap
Type Parameters
- TService
The contract for the service.
- TImplementation
The concrete type that implements the service.
Returns
The map, such that further calls can be chained.
Applies to
TryAddSingleton<TService,TImplementation>(Func<IServiceProvider,TImplementation>)
Adds a Singleton service implemented by the given factory if no service for the given service type has already been registered.
public virtual Microsoft.EntityFrameworkCore.Infrastructure.ServiceCollectionMap TryAddSingleton<TService,TImplementation> (Func<IServiceProvider,TImplementation> factory) where TService : class where TImplementation : class, TService;
abstract member TryAddSingleton : Func<IServiceProvider, #'Service> -> Microsoft.EntityFrameworkCore.Infrastructure.ServiceCollectionMap (requires 'Service : null)
override this.TryAddSingleton : Func<IServiceProvider, #'Service> -> Microsoft.EntityFrameworkCore.Infrastructure.ServiceCollectionMap (requires 'Service : null)
Public Overridable Function TryAddSingleton(Of TService As Class, TImplementation As Class) (factory As Func(Of IServiceProvider, TImplementation)) As ServiceCollectionMap
Type Parameters
- TService
The contract for the service.
- TImplementation
The concrete type that the given factory creates.
Parameters
- factory
- Func<IServiceProvider,TImplementation>
The factory that implements the service.
Returns
The map, such that further calls can be chained.
Applies to
TryAddSingleton<TService>(Func<IServiceProvider,TService>)
Adds a Singleton service implemented by the given factory if no service for the given service type has already been registered.
public virtual Microsoft.EntityFrameworkCore.Infrastructure.ServiceCollectionMap TryAddSingleton<TService> (Func<IServiceProvider,TService> factory) where TService : class;
abstract member TryAddSingleton : Func<IServiceProvider, 'Service (requires 'Service : null)> -> Microsoft.EntityFrameworkCore.Infrastructure.ServiceCollectionMap (requires 'Service : null)
override this.TryAddSingleton : Func<IServiceProvider, 'Service (requires 'Service : null)> -> Microsoft.EntityFrameworkCore.Infrastructure.ServiceCollectionMap (requires 'Service : null)
Public Overridable Function TryAddSingleton(Of TService As Class) (factory As Func(Of IServiceProvider, TService)) As ServiceCollectionMap
Type Parameters
- TService
The contract for the service.
Parameters
- factory
- Func<IServiceProvider,TService>
The factory that implements the service.
Returns
The map, such that further calls can be chained.
Applies to
TryAddSingleton<TService>(TService)
Adds a Singleton service implemented by the given instance if no service for the given service type has already been registered.
public virtual Microsoft.EntityFrameworkCore.Infrastructure.ServiceCollectionMap TryAddSingleton<TService> (TService implementation) where TService : class;
abstract member TryAddSingleton : 'Service -> Microsoft.EntityFrameworkCore.Infrastructure.ServiceCollectionMap (requires 'Service : null)
override this.TryAddSingleton : 'Service -> Microsoft.EntityFrameworkCore.Infrastructure.ServiceCollectionMap (requires 'Service : null)
Public Overridable Function TryAddSingleton(Of TService As Class) (implementation As TService) As ServiceCollectionMap
Type Parameters
- TService
The contract for the service.
Parameters
- implementation
- TService
The object that implements the service.
Returns
The map, such that further calls can be chained.