Прочетете на английски Редактиране

Споделяне чрез


BindingContext.AddService Method

Definition

Overloads

AddService(Type, Func<IServiceProvider,Object>)

Adds the specified service factory to the binding context.

AddService<T>(Func<IServiceProvider,T>)

Adds the specified service factory to the binding context.

AddService(Type, Func<IServiceProvider,Object>)

Source:
BindingContext.cs

Adds the specified service factory to the binding context.

C#
public void AddService(Type serviceType, Func<IServiceProvider,object> factory);

Parameters

serviceType
Type

The type for which this service factory will provide an instance.

factory
Func<IServiceProvider,Object>

A delegate that provides an instance of the specified service type.

Applies to

.NET 10 (package-provided) и други версии
Продукт Версии
.NET 6 (package-provided), 7 (package-provided), 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Standard 2.0 (package-provided)

AddService<T>(Func<IServiceProvider,T>)

Source:
BindingContext.cs

Adds the specified service factory to the binding context.

C#
public void AddService<T>(Func<IServiceProvider,T> factory);

Type Parameters

T

The type for which this service factory will provide an instance.

Parameters

factory
Func<IServiceProvider,T>

A delegate that provides an instance of the specified service type.

Applies to

.NET 10 (package-provided) и други версии
Продукт Версии
.NET 6 (package-provided), 7 (package-provided), 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Standard 2.0 (package-provided)