Class Service
This is the entry point for registering dependency injection implementation in Couchbase Lite .NET
Inheritance
Namespace: Couchbase.Lite.DI
Assembly: Couchbase.Lite.dll
Syntax
public static class Service : object
Methods
| Improve this Doc View SourceAutoRegister(Assembly)
Automatically register all the dependency types declared
Couchbase
Declaration
public static void AutoRegister(Assembly assembly)
Parameters
Type | Name | Description |
---|---|---|
Assembly | assembly |
GetInstance<T>()
Gets the implementation for the given service, or null
if no implementation is registered
Declaration
public static T GetInstance<T>()
where T : class
Returns
Type | Description |
---|---|
T | The implementation for the given service |
Type Parameters
Name | Description |
---|---|
T | The type of service to get an implementation for |
Register<TService>(TService)
Registers an instantiated object as a singleton implementation for a service
Declaration
public static void Register<TService>(TService instance)
where TService : class
Parameters
Type | Name | Description |
---|---|---|
TService | instance | The singleton instance to use as the implementation |
Type Parameters
Name | Description |
---|---|
TService | The service type |
Register<TService>(Func<TService>, Boolean)
Registers a lazy implementation for the given service
Declaration
public static void Register<TService>(Func<TService> generator, bool transient = false)
where TService : class
Parameters
Type | Name | Description |
---|---|---|
Func<TService> | generator | The function that creates the object to use |
System. |
transient | If |
Type Parameters
Name | Description |
---|---|
TService | The service type |
Register<TService, TImplementation>(Boolean)
Registers an implementation for the given service
Declaration
public static void Register<TService, TImplementation>(bool transient = false)
where TService : class where TImplementation : class, TService
Parameters
Type | Name | Description |
---|---|---|
System. |
transient | If |
Type Parameters
Name | Description |
---|---|
TService | The service type |
TImplementation | The implementation type |