Class PortableIoc
Inheritance
Implements
Inherited Members
Namespace: DelsysAPI.Utils
Assembly: DelsysAPI.dll
Syntax
public sealed class PortableIoc : IPortableIoC
Properties
Instance
Declaration
public static PortableIoc Instance { get; }
Property Value
| Type | Description |
|---|---|
| PortableIoc |
Methods
CanResolve<T>(String)
Test to see whether it is possible to resolve a type
Declaration
public bool CanResolve<T>(string label = "")
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | label | A unique label that allows for multiple implementations of the same type |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if an implementation exists for the type |
Type Parameters
| Name | Description |
|---|---|
| T | The type to test for |
Destroy<T>(String)
Destroy the shared instance of a type
Declaration
public bool Destroy<T>(string label = "")
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | label | An optional label to allow multiple implementations of the same type |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if a shared instance existed |
Type Parameters
| Name | Description |
|---|---|
| T | The type to destroy |
Remarks
This will allow for a new instance to become shared if the resolve call is made later
Register<T>(Func<IPortableIoC, T>, String)
Register a type to be created with an alias to create that includes an instance of the IoC container
Declaration
public void Register<T>(Func<IPortableIoC, T> creation, string label = "")
Parameters
| Type | Name | Description |
|---|---|---|
| System.Func<IPortableIoC, T> | creation | An expression to create a new instance of the type |
| System.String | label | A unique label that allows multiple implementations of the same type |
Type Parameters
| Name | Description |
|---|---|
| T | The type that is going to be implemented |
Resolve<T>(Boolean, String)
Overload to resolve the implementation of a type with the option to create a non-shared instance
Declaration
public T Resolve<T>(bool createNew, string label = "")
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | createNew | True for a non-shared instance |
| System.String | label | A unique label that allows multiple implementations of the same type |
Returns
| Type | Description |
|---|---|
| T | The implementation of the type |
Type Parameters
| Name | Description |
|---|---|
| T | The type to resolve |
Resolve<T>(String)
Resolve the implementation of a type (interface, abstract class, etc.)
Declaration
public T Resolve<T>(string label = "")
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | label | A unique label that allows multiple implementations of the same type |
Returns
| Type | Description |
|---|---|
| T | The implementation (defaults to a shared implementation) |
Type Parameters
| Name | Description |
|---|---|
| T | The type to resolve the implementation for |
TryResolve<T>(out T, Boolean, String)
Attempt to resolve an instance
Declaration
public bool TryResolve<T>(out T instance, bool createNew, string label = "")
Parameters
| Type | Name | Description |
|---|---|---|
| T | instance | The instance, if it is possible to create one |
| System.Boolean | createNew | Set to true to create a non-shared instance |
| System.String | label | A unique label that allows for multiple implementations of the same type |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the resolution succeeded |
Type Parameters
| Name | Description |
|---|---|
| T | The type to resolve |
TryResolve<T>(out T, String)
Attempt to resolve an instance
Declaration
public bool TryResolve<T>(out T instance, string label = "")
Parameters
| Type | Name | Description |
|---|---|---|
| T | instance | The instance, if it is possible to create one |
| System.String | label | A unique label that allows for multiple implementations of the same type |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the resolution succeeded |
Type Parameters
| Name | Description |
|---|---|
| T | The type to resolve |
Unregister<T>(String)
Unregister a definition.
Declaration
public bool Unregister<T>(string label = "")
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | label | An optional label to allow multiple implementations of the same type |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the definition existed |
Type Parameters
| Name | Description |
|---|---|
| T | The type to destroy |
Remarks
This will destroy references to any shared instances for the type