Class ServiceProviderExtensions
Provides extension methods to the
Inheritance
System.Object
Namespace: Umbraco.Extensions
Assembly: Umbraco.Core.dll
Syntax
public static class ServiceProviderExtensions
Methods
View SourceCreateDefaultPublishedModelFactory(IServiceProvider)
Declaration
public static PublishedModelFactory CreateDefaultPublishedModelFactory(this IServiceProvider factory)
Parameters
Type | Name | Description |
---|---|---|
IServiceProvider | factory |
Returns
Type | Description |
---|---|
PublishedModelFactory |
CreateInstance(IServiceProvider, Type, Object[])
Creates an instance of a service, with arguments.
Declaration
public static object CreateInstance(this IServiceProvider serviceProvider, Type type, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
IServiceProvider | serviceProvider | The |
Type | type | The type of the instance. |
System.Object[] | args | Named arguments. |
Returns
Type | Description |
---|---|
System.Object | An instance of the specified type. |
Remarks
The instance type does not need to be registered into the factory.
The arguments are used as dependencies by the factory. Other dependencies are retrieved from the factory.
CreateInstance<T>(IServiceProvider, Object[])
Creates an instance with arguments.
Declaration
public static T CreateInstance<T>(this IServiceProvider serviceProvider, params object[] args)
where T : class
Parameters
Type | Name | Description |
---|---|---|
IServiceProvider | serviceProvider | The factory. |
System.Object[] | args | Arguments. |
Returns
Type | Description |
---|---|
T | An instance of the specified type. |
Type Parameters
Name | Description |
---|---|
T | The type of the instance. |
Remarks
Throws an exception if the factory failed to get an instance of the specified type.
The arguments are used as dependencies by the factory.