ActivatorUtilities.GetServiceOrCreateInstance Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
The resolved service or created instance.
Applies to
.NET