Couchbase .NET SDK __CB_SDK_VERSION__

Show / Hide Table of Contents

Class ServiceCollectionExtensions

Extensions to IServiceCollection for Couchbase dependency injection.

Inheritance
object
ServiceCollectionExtensions
Inherited Members
object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: Couchbase.Extensions.DependencyInjection
Assembly: Couchbase.Extensions.DependencyInjection.dll
Syntax
public static class ServiceCollectionExtensions

Methods

View Source

AddCouchbase(IServiceCollection, IConfiguration)

Add Couchbase dependencies to the IServiceCollection.

Declaration
[RequiresUnreferencedCode("The Couchbase SDK is not compatible with trimming.")]
public static IServiceCollection AddCouchbase(this IServiceCollection services, IConfiguration configuration)
Parameters
Type Name Description
IServiceCollection services

The IServiceCollection.

IConfiguration configuration

Section from the configuration that can be bound to ClusterOptions.

Returns
Type Description
IServiceCollection

The IServiceCollection.

View Source

AddCouchbase(IServiceCollection, Action<ClusterOptions>?)

Add Couchbase dependencies to the IServiceCollection.

Declaration
[RequiresUnreferencedCode("The Couchbase SDK is not compatible with trimming.")]
public static IServiceCollection AddCouchbase(this IServiceCollection services, Action<ClusterOptions>? options)
Parameters
Type Name Description
IServiceCollection services

The IServiceCollection.

Action<ClusterOptions> options

Optional action to configure the ClusterOptions.

Returns
Type Description
IServiceCollection

The IServiceCollection.

View Source

AddCouchbaseBucket<T>(IServiceCollection, string)

Register an interface based on INamedBucketProvider which will be injected with a specific bucket name.

Declaration
[RequiresDynamicCode("Dynamically generated INamedBucketProvider or INamedCollectionProvider instances require dynamic code and are not compatible with AOT. Use an overload that accepts a concrete implementation type instead.")]
public static IServiceCollection AddCouchbaseBucket<T>(this IServiceCollection services, string bucketName) where T : class, INamedBucketProvider
Parameters
Type Name Description
IServiceCollection services

The IServiceCollection.

string bucketName

The name of the Couchbase bucket.

Returns
Type Description
IServiceCollection

The IServiceCollection.

Type Parameters
Name Description
T

Interface inherited from INamedBucketProvider. Must not add any members.

View Source

AddCouchbaseBucket<T>(IServiceCollection, string, Action<IBucketBuilder>?)

Register an interface based on INamedBucketProvider which will be injected with a specific bucket name.

Declaration
[RequiresDynamicCode("Dynamically generated INamedBucketProvider or INamedCollectionProvider instances require dynamic code and are not compatible with AOT. Use an overload that accepts a concrete implementation type instead.")]
public static IServiceCollection AddCouchbaseBucket<T>(this IServiceCollection services, string bucketName, Action<IBucketBuilder>? buildAction) where T : class, INamedBucketProvider
Parameters
Type Name Description
IServiceCollection services

The IServiceCollection.

string bucketName

The name of the Couchbase bucket.

Action<IBucketBuilder> buildAction

Action to perform further configuration.

Returns
Type Description
IServiceCollection

The IServiceCollection.

Type Parameters
Name Description
T

Interface inherited from INamedBucketProvider. Must not add any members.

Remarks

This method is not AOT-compatible. Use the overload that accepts a concrete implementation.

View Source

AddCouchbaseBucket<TService, TImplementation>(IServiceCollection, Action<IBucketBuilder>?)

Register an bucket via an interface inherited from INamedBucketProvider and a concrete implementation of that interface.

Declaration
public static IServiceCollection AddCouchbaseBucket<TService, TImplementation>(this IServiceCollection services, Action<IBucketBuilder>? buildAction = null) where TService : class, INamedBucketProvider where TImplementation : class, TService
Parameters
Type Name Description
IServiceCollection services

The IServiceCollection.

Action<IBucketBuilder> buildAction

Action to perform further configuration.

Returns
Type Description
IServiceCollection

The IServiceCollection.

Type Parameters
Name Description
TService

Interface inherited from INamedBucketProvider.

TImplementation

Concrete implementation of TService.

Remarks

This method is not AOT-compatible. Use the overload that accepts a concrete implementation.

View Source

AddKeyedCouchbase(IServiceCollection, string?, IConfiguration)

Add Couchbase dependencies to the IServiceCollection.

Declaration
[RequiresUnreferencedCode("The Couchbase SDK is not compatible with trimming.")]
public static IServiceCollection AddKeyedCouchbase(this IServiceCollection services, string? serviceKey, IConfiguration configuration)
Parameters
Type Name Description
IServiceCollection services

The IServiceCollection.

string serviceKey

Service key to uniquely represent the cluster.

IConfiguration configuration

Section from the configuration that can be bound to ClusterOptions.

Returns
Type Description
IServiceCollection

The IServiceCollection.

View Source

AddKeyedCouchbase(IServiceCollection, string?, Action<ClusterOptions>?)

Add Couchbase dependencies to the IServiceCollection.

Declaration
[RequiresUnreferencedCode("The Couchbase SDK is not compatible with trimming.")]
public static IServiceCollection AddKeyedCouchbase(this IServiceCollection services, string? serviceKey, Action<ClusterOptions>? options)
Parameters
Type Name Description
IServiceCollection services

The IServiceCollection.

string serviceKey

Service key to uniquely represent the cluster.

Action<ClusterOptions> options

Optional action to configure the ClusterOptions.

Returns
Type Description
IServiceCollection

The IServiceCollection.

View Source

AddKeyedCouchbaseBucket<T>(IServiceCollection, string?, string)

Register an interface based on INamedBucketProvider which will be injected with a specific bucket name.

Declaration
[RequiresDynamicCode("Dynamically generated INamedBucketProvider or INamedCollectionProvider instances require dynamic code and are not compatible with AOT. Use an overload that accepts a concrete implementation type instead.")]
public static IServiceCollection AddKeyedCouchbaseBucket<T>(this IServiceCollection services, string? serviceKey, string bucketName) where T : class, INamedBucketProvider
Parameters
Type Name Description
IServiceCollection services

The IServiceCollection.

string serviceKey

Service key to uniquely represent the cluster.

string bucketName

The name of the Couchbase bucket.

Returns
Type Description
IServiceCollection

The IServiceCollection.

Type Parameters
Name Description
T

Interface inherited from INamedBucketProvider. Must not add any members.

View Source

AddKeyedCouchbaseBucket<T>(IServiceCollection, string?, string?, Action<IBucketBuilder>?)

Register an interface based on INamedBucketProvider which will be injected with a specific bucket name.

Declaration
[RequiresDynamicCode("Dynamically generated INamedBucketProvider or INamedCollectionProvider instances require dynamic code and are not compatible with AOT. Use an overload that accepts a concrete implementation type instead.")]
public static IServiceCollection AddKeyedCouchbaseBucket<T>(this IServiceCollection services, string? serviceKey, string? bucketName, Action<IBucketBuilder>? buildAction) where T : class, INamedBucketProvider
Parameters
Type Name Description
IServiceCollection services

The IServiceCollection.

string serviceKey

Service key to uniquely represent the cluster.

string bucketName

The name of the Couchbase bucket.

Action<IBucketBuilder> buildAction

Action to perform further configuration.

Returns
Type Description
IServiceCollection

The IServiceCollection.

Type Parameters
Name Description
T

Interface inherited from INamedBucketProvider. Must not add any members.

Remarks

This method is not AOT-compatible. Use the overload that accepts a concrete implementation.

View Source

AddKeyedCouchbaseBucket<TService, TImplementation>(IServiceCollection, string?, Action<IBucketBuilder>?)

Register an bucket via an interface inherited from INamedBucketProvider and a concrete implementation of that interface.

Declaration
public static IServiceCollection AddKeyedCouchbaseBucket<TService, TImplementation>(this IServiceCollection services, string? serviceKey, Action<IBucketBuilder>? buildAction = null) where TService : class, INamedBucketProvider where TImplementation : class, TService
Parameters
Type Name Description
IServiceCollection services

The IServiceCollection.

string serviceKey

Service key to uniquely represent the cluster.

Action<IBucketBuilder> buildAction

Action to perform further configuration.

Returns
Type Description
IServiceCollection

The IServiceCollection.

Type Parameters
Name Description
TService

Interface inherited from INamedBucketProvider.

TImplementation

Concrete implementation of TService.

Remarks

This method is not AOT-compatible. Use the overload that accepts a concrete implementation.

View Source

TryAddCouchbaseBucket<T>(IServiceCollection, string)

Register an interface based on INamedBucketProvider which will be injected with a specific bucket name if the interface hasn't already been added.

Declaration
[RequiresDynamicCode("Dynamically generated INamedBucketProvider or INamedCollectionProvider instances require dynamic code and are not compatible with AOT. Use an overload that accepts a concrete implementation type instead.")]
public static IServiceCollection TryAddCouchbaseBucket<T>(this IServiceCollection services, string bucketName) where T : class, INamedBucketProvider
Parameters
Type Name Description
IServiceCollection services

The IServiceCollection.

string bucketName

The name of the Couchbase bucket.

Returns
Type Description
IServiceCollection

The IServiceCollection.

Type Parameters
Name Description
T

Interface inherited from INamedBucketProvider. Must not add any members.

Remarks

This method is not AOT-compatible. Use the overload that accepts a concrete implementation.

View Source

TryAddCouchbaseBucket<T>(IServiceCollection, string, Action<IBucketBuilder>?)

Register an interface based on INamedBucketProvider which will be injected with a specific bucket name if the interface hasn't already been added.

Declaration
[RequiresDynamicCode("Dynamically generated INamedBucketProvider or INamedCollectionProvider instances require dynamic code and are not compatible with AOT. Use an overload that accepts a concrete implementation type instead.")]
public static IServiceCollection TryAddCouchbaseBucket<T>(this IServiceCollection services, string bucketName, Action<IBucketBuilder>? buildAction) where T : class, INamedBucketProvider
Parameters
Type Name Description
IServiceCollection services

The IServiceCollection.

string bucketName

The name of the Couchbase bucket.

Action<IBucketBuilder> buildAction

Action to perform further configuration.

Returns
Type Description
IServiceCollection

The IServiceCollection.

Type Parameters
Name Description
T

Interface inherited from INamedBucketProvider. Must not add any members.

Remarks

This method is not AOT-compatible. Use the overload that accepts a concrete implementation.

View Source

TryAddCouchbaseBucket<TService, TImplementation>(IServiceCollection, Action<IBucketBuilder>?)

Register a bucket via an interface inherited from INamedBucketProvider and a concrete implementation of that interface.

Declaration
public static IServiceCollection TryAddCouchbaseBucket<TService, TImplementation>(this IServiceCollection services, Action<IBucketBuilder>? buildAction = null) where TService : class, INamedBucketProvider where TImplementation : class, TService
Parameters
Type Name Description
IServiceCollection services

The IServiceCollection.

Action<IBucketBuilder> buildAction

Action to perform further configuration.

Returns
Type Description
IServiceCollection

The IServiceCollection.

Type Parameters
Name Description
TService

Interface inherited from INamedBucketProvider.

TImplementation

Concrete implementation of TService.

View Source

TryAddKeyedCouchbaseBucket<T>(IServiceCollection, string?, string)

Register an interface based on INamedBucketProvider which will be injected with a specific bucket name if the interface hasn't already been added.

Declaration
[RequiresDynamicCode("Dynamically generated INamedBucketProvider or INamedCollectionProvider instances require dynamic code and are not compatible with AOT. Use an overload that accepts a concrete implementation type instead.")]
public static IServiceCollection TryAddKeyedCouchbaseBucket<T>(this IServiceCollection services, string? serviceKey, string bucketName) where T : class, INamedBucketProvider
Parameters
Type Name Description
IServiceCollection services

The IServiceCollection.

string serviceKey

Service key to uniquely represent the cluster.

string bucketName

The name of the Couchbase bucket.

Returns
Type Description
IServiceCollection

The IServiceCollection.

Type Parameters
Name Description
T

Interface inherited from INamedBucketProvider. Must not add any members.

Remarks

This method is not AOT-compatible. Use the overload that accepts a concrete implementation.

View Source

TryAddKeyedCouchbaseBucket<T>(IServiceCollection, string?, string, Action<IBucketBuilder>?)

Register an interface based on INamedBucketProvider which will be injected with a specific bucket name if the interface hasn't already been added.

Declaration
[RequiresDynamicCode("Dynamically generated INamedBucketProvider or INamedCollectionProvider instances require dynamic code and are not compatible with AOT. Use an overload that accepts a concrete implementation type instead.")]
public static IServiceCollection TryAddKeyedCouchbaseBucket<T>(this IServiceCollection services, string? serviceKey, string bucketName, Action<IBucketBuilder>? buildAction) where T : class, INamedBucketProvider
Parameters
Type Name Description
IServiceCollection services

The IServiceCollection.

string serviceKey

Service key to uniquely represent the cluster.

string bucketName

The name of the Couchbase bucket.

Action<IBucketBuilder> buildAction

Action to perform further configuration.

Returns
Type Description
IServiceCollection

The IServiceCollection.

Type Parameters
Name Description
T

Interface inherited from INamedBucketProvider. Must not add any members.

Remarks

This method is not AOT-compatible. Use the overload that accepts a concrete implementation.

View Source

TryAddKeyedCouchbaseBucket<TService, TImplementation>(IServiceCollection, string?, Action<IBucketBuilder>?)

Register a bucket via an interface inherited from INamedBucketProvider and a concrete implementation of that interface.

Declaration
public static IServiceCollection TryAddKeyedCouchbaseBucket<TService, TImplementation>(this IServiceCollection services, string? serviceKey, Action<IBucketBuilder>? buildAction = null) where TService : class, INamedBucketProvider where TImplementation : class, TService
Parameters
Type Name Description
IServiceCollection services

The IServiceCollection.

string serviceKey

Service key to uniquely represent the cluster.

Action<IBucketBuilder> buildAction

Action to perform further configuration.

Returns
Type Description
IServiceCollection

The IServiceCollection.

Type Parameters
Name Description
TService

Interface inherited from INamedBucketProvider.

TImplementation

Concrete implementation of TService.

  • View Source
In this article
Back to top Copyright © 2020 Couchbase, Inc. All rights reserved.