Share via


ActivatorUtilities.GetServiceOrCreateInstance Method

Definition

Overloads

GetServiceOrCreateInstance(IServiceProvider, Type)

Retrieve an instance of the given type from the service provider. If one is not found then instantiate it directly.

GetServiceOrCreateInstance<T>(IServiceProvider)

Retrieve an instance of the given type from the service provider. If one is not found then instantiate it directly.

GetServiceOrCreateInstance(IServiceProvider, Type)

Source:
ActivatorUtilities.cs
Source:
ActivatorUtilities.cs
Source:
ActivatorUtilities.cs
Source:
ActivatorUtilities.cs
Source:
ActivatorUtilities.cs

Retrieve an instance of the given type from the service provider. If one is not found then instantiate it directly.

public:
 static System::Object ^ GetServiceOrCreateInstance(IServiceProvider ^ provider, Type ^ type);
public static object GetServiceOrCreateInstance (IServiceProvider provider, Type type);
static member GetServiceOrCreateInstance : IServiceProvider * Type -> obj
Public Shared Function GetServiceOrCreateInstance (provider As IServiceProvider, type As Type) As Object

Parameters

provider
IServiceProvider

The service provider.

type
Type

The type of the service.

Returns

The resolved service or created instance.

Applies to

GetServiceOrCreateInstance<T>(IServiceProvider)

Source:
ActivatorUtilities.cs
Source:
ActivatorUtilities.cs
Source:
ActivatorUtilities.cs
Source:
ActivatorUtilities.cs
Source:
ActivatorUtilities.cs

Retrieve an instance of the given type from the service provider. If one is not found then instantiate it directly.

public:
generic <typename T>
 static T GetServiceOrCreateInstance(IServiceProvider ^ provider);
public static T GetServiceOrCreateInstance<T> (IServiceProvider provider);
static member GetServiceOrCreateInstance : IServiceProvider -> 'T
Public Shared Function GetServiceOrCreateInstance(Of T) (provider As IServiceProvider) As T

Type Parameters

T

The type of the service.

Parameters

provider
IServiceProvider

The service provider used to resolve dependencies.

Returns

T

The resolved service or created instance.

Applies to