Show / Hide Table of Contents

Class Service

This is the entry point for registering dependency injection implementation in Couchbase Lite .NET

Inheritance
System.Object
Service
Namespace: Couchbase.Lite.DI
Assembly: Couchbase.Lite.dll
Syntax
public static class Service : object

Methods

| Improve this Doc View Source

AutoRegister(Assembly)

Automatically register all the dependency types declared CouchbaseDependencyAttributes. To auto register classes, they must implement an interface and must have a default constructor.

Declaration
public static void AutoRegister(Assembly assembly)
Parameters
Type Name Description
Assembly assembly
| Improve this Doc View Source

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

| Improve this Doc View Source

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

| Improve this Doc View Source

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.Boolean transient

If true each call to GetInstance<T>() will return a new instance, otherwise use a singleton

Type Parameters
Name Description
TService

The service type

| Improve this Doc View Source

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.Boolean transient

If true each call to GetInstance<T>() will return a new instance, otherwise use a singleton

Type Parameters
Name Description
TService

The service type

TImplementation

The implementation type

  • Improve this Doc
  • View Source
Back to top Generated by DocFX