Class DefaultServiceProvider
- Namespace
- Cratis.Chronicle
- Assembly
- Cratis.Chronicle.dll
Represents a default IServiceProvider that will create instances of services using the default constructor.
public class DefaultServiceProvider : IServiceProviderIsKeyedService, IServiceProviderIsService, IKeyedServiceProvider, IServiceProvider, IServiceScopeFactory, IServiceScope, IDisposable
- Inheritance
-
DefaultServiceProvider
- Implements
- Inherited Members
- Extension Methods
Constructors
DefaultServiceProvider()
public DefaultServiceProvider()
Properties
ServiceProvider
Gets the IServiceProvider used to resolve dependencies from the scope.
public IServiceProvider ServiceProvider { get; }
Property Value
Methods
CreateScope()
Create an IServiceScope that contains an IServiceProvider used to resolve dependencies from a newly created scope.
public IServiceScope CreateScope()
Returns
- IServiceScope
An IServiceScope controlling the lifetime of the scope. Once this is disposed, any scoped services that have been resolved from the ServiceProvider will also be disposed.
Dispose()
public void Dispose()
GetKeyedService(Type, object?)
Gets the service object of the specified type.
public object? GetKeyedService(Type serviceType, object? serviceKey)
Parameters
serviceTypeTypeAn object that specifies the type of service object to get.
serviceKeyobjectAn object that specifies the key of service object to get.
Returns
- object
A service object of type
serviceType.-or-
null if there is no service object of type
serviceType.
GetRequiredKeyedService(Type, object?)
Gets service of type serviceType from the IServiceProvider implementing
this interface.
public object GetRequiredKeyedService(Type serviceType, object? serviceKey)
Parameters
serviceTypeTypeAn object that specifies the type of service object to get.
serviceKeyobjectThe ServiceKey of the service.
Returns
- object
A service object of type
serviceType. Throws an exception if the IServiceProvider cannot create the object.
GetService(Type)
public object? GetService(Type serviceType)
Parameters
serviceTypeType
Returns
IsKeyedService(Type, object?)
Determines if the specified service type with the specified service key is available from the IServiceProvider.
public bool IsKeyedService(Type serviceType, object? serviceKey)
Parameters
serviceTypeTypeAn object that specifies the type of service object to test.
serviceKeyobjectThe ServiceKey of the service.
Returns
- bool
true if the specified service is a available, false if it is not.
IsService(Type)
Determines if the specified service type is available from the IServiceProvider.
public bool IsService(Type serviceType)
Parameters
serviceTypeTypeAn object that specifies the type of service object to test.
Returns
- bool
true if the specified service is a available, false if it is not.