Class IOC
Simple IoC container implementation.
Namespace: Battlehub.RTCommon
Assembly: cs.temp.dll.dll
Syntax
public static class IOC
Methods
ClearAll()
Clears container and removes all registered dependencies and fallbacks
Declaration
public static void ClearAll()
IsFallbackRegistered<T>()
Checks if a fallback dependency of type is registered.
Declaration
public static bool IsFallbackRegistered<T>()
Returns
Type | Description |
---|---|
Boolean | True if fallback dependency of type with name registered. |
Type Parameters
Name | Description |
---|---|
T | Type of fallback dependency. |
IsRegistered<T>()
Checks if a dependency of type is registered.
Declaration
public static bool IsRegistered<T>()
Returns
Type | Description |
---|---|
Boolean | True if dependency of type with name registered. |
Type Parameters
Name | Description |
---|---|
T | Type of dependency. |
IsRegistered<T>(String)
Checks if a named dependency of type is registered.
Declaration
public static bool IsRegistered<T>(string name)
Parameters
Type | Name | Description |
---|---|---|
String | name | Name of dependency. |
Returns
Type | Description |
---|---|
Boolean | True if dependency of type with name registered. |
Type Parameters
Name | Description |
---|---|
T | Type of dependency. |
Register<T>(T)
Registers dependency of type.
Declaration
public static void Register<T>(T instance)
Parameters
Type | Name | Description |
---|---|---|
T | instance | Instance of type. |
Type Parameters
Name | Description |
---|---|
T | Type of dependency. |
Register<T>(Func<T>)
Registers dependency of type.
Declaration
public static void Register<T>(Func<T> func)
Parameters
Type | Name | Description |
---|---|---|
Func<T> | func | Function which constructs object of type. |
Type Parameters
Name | Description |
---|---|
T | Type of dependency. |
Register<T>(String, T)
Registers named dependency of type.
Declaration
public static void Register<T>(string name, T instance)
Parameters
Type | Name | Description |
---|---|---|
String | name | Name of dependency. |
T | instance | Instance of type. |
Type Parameters
Name | Description |
---|---|
T | Type of dependency. |
Register<T>(String, Func<T>)
Registers named dependency of type.
Declaration
public static void Register<T>(string name, Func<T> func)
Parameters
Type | Name | Description |
---|---|---|
String | name | Name of dependency. |
Func<T> | func | Function which constructs object of type. |
Type Parameters
Name | Description |
---|---|
T | Type of dependency. |
RegisterFallback<T>(T)
Registers fallback dependency of type.
Declaration
public static void RegisterFallback<T>(T instance)
Parameters
Type | Name | Description |
---|---|---|
T | instance | Instance of type. |
Type Parameters
Name | Description |
---|---|
T | Type of fallback dependency. |
RegisterFallback<T>(Func<T>)
Registers fallback dependency of type.
Declaration
public static void RegisterFallback<T>(Func<T> func)
Parameters
Type | Name | Description |
---|---|---|
Func<T> | func | Function which constructs object of type. |
Type Parameters
Name | Description |
---|---|
T | Type of fallback dependency. |
Resolve<T>()
Resolves dependency or fallback dependency of type.
Declaration
public static T Resolve<T>()
Returns
Type | Description |
---|---|
T | Object of type (or null if dependency of type is not registered) |
Type Parameters
Name | Description |
---|---|
T | Type of dependency. |
Resolve<T>(String)
Resolves named dependency or fallback dependency of type.
Declaration
public static T Resolve<T>(string name)
Parameters
Type | Name | Description |
---|---|---|
String | name | Name of dependency. |
Returns
Type | Description |
---|---|
T | Object of type (or null if dependency of type is not registered) |
Type Parameters
Name | Description |
---|---|
T | Type of dependency. |
Unregister<T>()
Unregisters dependency of type.
Declaration
public static void Unregister<T>()
Type Parameters
Name | Description |
---|---|
T |
Unregister<T>(T)
Unregisters dependency of type.
Declaration
public static void Unregister<T>(T instance)
Parameters
Type | Name | Description |
---|---|---|
T | instance | Instance which was passed to Register method. |
Type Parameters
Name | Description |
---|---|
T | Type of dependency. |
Unregister<T>(Func<T>)
Unregisters dependency of type.
Declaration
public static void Unregister<T>(Func<T> func)
Parameters
Type | Name | Description |
---|---|---|
Func<T> | func | Function which was passed to Register method. |
Type Parameters
Name | Description |
---|---|
T | Type of dependency. |
Unregister<T>(String, T)
Unregisters named dependency of type
Declaration
public static void Unregister<T>(string name, T instance)
Parameters
Type | Name | Description |
---|---|---|
String | name | Name of dependency |
T | instance | Instance which was passed to Register method. |
Type Parameters
Name | Description |
---|---|
T | Type of dependency |
Unregister<T>(String, Func<T>)
Unregisters named dependency of type.
Declaration
public static void Unregister<T>(string name, Func<T> func)
Parameters
Type | Name | Description |
---|---|---|
String | name | Name of dependency. |
Func<T> | func | Function which was passed to Register method. |
Type Parameters
Name | Description |
---|---|
T | Type of dependency. |
UnregisterFallback<T>()
Unregisters fallback dependency of type.
Declaration
public static void UnregisterFallback<T>()
Type Parameters
Name | Description |
---|---|
T | Type of fallback dependency. |
UnregisterFallback<T>(T)
Unregisters fallback dependency of type.
Declaration
public static void UnregisterFallback<T>(T instance)
Parameters
Type | Name | Description |
---|---|---|
T | instance |
Type Parameters
Name | Description |
---|---|
T | Type of fallback dependency. |
UnregisterFallback<T>(Func<T>)
Unregisters fallback dependency of type.
Declaration
public static void UnregisterFallback<T>(Func<T> func)
Parameters
Type | Name | Description |
---|---|---|
Func<T> | func | Function which was passed to RegisterFallback method. |
Type Parameters
Name | Description |
---|---|
T | Type of fallback dependency. |