Interface IFactory
Defines a service factory for Umbraco.
Namespace: Umbraco.Core.Composing
Assembly: Umbraco.Core.dll
Syntax
public interface IFactory
Properties
View SourceConcrete
Gets the concrete factory.
Declaration
object Concrete { get; }
Property Value
Type | Description |
---|---|
System.Object |
Methods
View SourceBeginScope()
Begins a scope.
Declaration
IDisposable BeginScope()
Returns
Type | Description |
---|---|
System.IDisposable |
Remarks
When the scope is disposed, scoped instances that have been created during the scope are disposed.
Scopes can be nested. Each instance is disposed individually.
EnablePerWebRequestScope()
Enables per-request scope.
Declaration
void EnablePerWebRequestScope()
Remarks
Ties scopes to web requests.
GetAllInstances(Type)
Gets all instances of a service.
Declaration
IEnumerable<object> GetAllInstances(Type serviceType)
Parameters
Type | Name | Description |
---|---|---|
System.Type | serviceType | The type of the service. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.Object> |
GetAllInstances<TService>()
Gets all instances of a service.
Declaration
IEnumerable<TService> GetAllInstances<TService>()
where TService : class
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<TService> |
Type Parameters
Name | Description |
---|---|
TService | The type of the service. |
GetInstance(Type)
Gets an instance of a service.
Declaration
object GetInstance(Type type)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | The type of the service. |
Returns
Type | Description |
---|---|
System.Object | An instance of the specified type. |
Remarks
Throws an exception if the container failed to get an instance of the specified type.
GetInstanceFor<TService, TTarget>()
Gets a targeted instance of a service.
Declaration
TService GetInstanceFor<TService, TTarget>()
Returns
Type | Description |
---|---|
TService | The instance of the specified type for the specified target. |
Type Parameters
Name | Description |
---|---|
TService | The type of the service. |
TTarget | The type of the target. |
Remarks
Throws an exception if the container failed to get an instance of the specified type.
Release(Object)
Releases an instance.
Declaration
void Release(object instance)
Parameters
Type | Name | Description |
---|---|---|
System.Object | instance | The instance. |
Remarks
See https://stackoverflow.com/questions/14072208 and http://kozmic.net/2010/08/27/must-i-release-everything-when-using-windsor/, you only need to release instances you specifically resolved, and even then, if done right, that might never be needed. For instance, LightInject does not require this and does not support it - should work with scopes.
TryGetInstance(Type)
Tries to get an instance of a service.
Declaration
object TryGetInstance(Type type)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | The type of the service. |
Returns
Type | Description |
---|---|
System.Object | An instance of the specified type, or null. |
Remarks
Returns null if the container does not know how to get an instance of the specified type. Throws an exception if the container does know how to get an instance of the specified type, but failed to do so.