Show / Hide Table of Contents

Class ClassFactory

Factory of the replacement classes.

Inheritance
System.Object
ClassFactory
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: Terrasoft.Core.Factories
Assembly: Terrasoft.Core.dll
Syntax
public static class ClassFactory

Methods

Bind(Type, Type)

Declares a binding for the specified service and indicates that the service should be bound to the specified implementation type.

Declaration
public static void Bind(Type service, Type implementation)
Parameters
Type Name Description
System.Type service

The service to bind.

System.Type implementation

The implementation type.

Bind(Type, Type, String)

Declares a binding for the specified service and indicates that the service should be bound to the specified implementation type.

Declaration
public static void Bind(Type service, Type implementation, string name)
Parameters
Type Name Description
System.Type service

The service to bind.

System.Type implementation

The implementation type.

System.String name

The name to give the binding.

Bind<T>(Func<T>)

Declares a binding for the specified service.

Declaration
public static void Bind<T>(Func<T> resolveMethod)

    where T : class
Parameters
Type Name Description
System.Func<T> resolveMethod

Method that returns the specified service.

Type Parameters
Name Description
T

The service to resolve.

Bind<T>(Func<T>, String)

Declares a named binding for the specified service.

Declaration
public static void Bind<T>(Func<T> resolveMethod, string name)

    where T : class
Parameters
Type Name Description
System.Func<T> resolveMethod

Method that returns the specified service.

System.String name

The name to give the binding.

Type Parameters
Name Description
T

The service to resolve.

Bind<T>(Type)

Declares a binding for the specified service by type.

Declaration
public static void Bind<T>(Type classType)

    where T : class
Parameters
Type Name Description
System.Type classType

Type of class.

Type Parameters
Name Description
T

The service to resolve.

Bind<T, TImpl>()

Declares a binding for the specified service and indicates that the service should be bound to the specified implementation type.

Declaration
public static void Bind<T, TImpl>()

    where T : class where TImpl : T
Type Parameters
Name Description
T

The service to bind.

TImpl

The implementation type.

Bind<T, TImpl>(String)

Declares a binding for the specified service and indicates that the service should be bound to the specified implementation type.

Declaration
public static void Bind<T, TImpl>(string name)

    where T : class where TImpl : T
Parameters
Type Name Description
System.String name

The name to give the binding.

Type Parameters
Name Description
T

The service to bind.

TImpl

The implementation type.

ForceGet<T>(String, ConstructorArgument[])

Returns an instance of the class by name.

Declaration
public static T ForceGet<T>(string fullClassName, params ConstructorArgument[] constructorArguments)

    where T : class
Parameters
Type Name Description
System.String fullClassName

Full name of class.

ConstructorArgument[] constructorArguments

Array of the constructor arguments.

Returns
Type Description
T

Instance of the class, or null.

Type Parameters
Name Description
T

The service to resolve.

Get(Type)

Returns an instance of specified type.

Declaration
public static object Get(Type type)
Parameters
Type Name Description
System.Type type

Type of instance to resolve.

Returns
Type Description
System.Object

Get<T>(String, ConstructorArgument[])

Declaration
public static T Get<T>(string name, params ConstructorArgument[] constructorArguments)

    where T : class
Parameters
Type Name Description
System.String name
ConstructorArgument[] constructorArguments
Returns
Type Description
T
Type Parameters
Name Description
T

Get<T>(ConstructorArgument[])

Returns an instance of replacing type for specified replacement type.

Declaration
public static T Get<T>(params ConstructorArgument[] constructorArguments)

    where T : class
Parameters
Type Name Description
ConstructorArgument[] constructorArguments

Array of the constructor arguments of the replacement type.

Returns
Type Description
T

Instance of type that replaces the T type.

Type Parameters
Name Description
T

Replacement type.

GetAll<T>(String, ConstructorArgument[])

Declaration
public static IEnumerable<T> GetAll<T>(string name, params ConstructorArgument[] constructorArguments)

    where T : class
Parameters
Type Name Description
System.String name
ConstructorArgument[] constructorArguments
Returns
Type Description
System.Collections.Generic.IEnumerable<T>
Type Parameters
Name Description
T

GetAll<T>(ConstructorArgument[])

Declaration
public static IEnumerable<T> GetAll<T>(params ConstructorArgument[] constructorArguments)

    where T : class
Parameters
Type Name Description
ConstructorArgument[] constructorArguments
Returns
Type Description
System.Collections.Generic.IEnumerable<T>
Type Parameters
Name Description
T

HasBinding(Type)

Returns true if service has binding.

Declaration
public static bool HasBinding(Type type)
Parameters
Type Name Description
System.Type type

The service to check binding.

Returns
Type Description
System.Boolean

true if service has binding.

HasBinding(Type, String)

Returns true if service has binding.

Declaration
public static bool HasBinding(Type type, string name)
Parameters
Type Name Description
System.Type type

The service to check binding.

System.String name

The name of the existing service to check. If null, any service is checked.

Returns
Type Description
System.Boolean

true if service has binding.

HasBinding<T>()

Returns true if service has binding.

Declaration
public static bool HasBinding<T>()

    where T : class
Returns
Type Description
System.Boolean

true if service has binding.

Type Parameters
Name Description
T

The service to check binding.

ReBind<T, TImpl>()

Removes any existing bindings for the specified service, declares a new one and indicates that the service should be bound to the specified implementation type.

Declaration
public static void ReBind<T, TImpl>()

    where T : class where TImpl : T
Type Parameters
Name Description
T

The service to re-bind.

TImpl

The implementation type.

ReBind<T, TImpl>(String)

Removes any existing bindings with specified name for the specified service and replaces it with a new one. If there are no bindings with the given name then just creates a new.

Declaration
public static void ReBind<T, TImpl>(string name)

    where T : class where TImpl : T
Parameters
Type Name Description
System.String name

The name for existing service.

Type Parameters
Name Description
T

The service to re-bind.

TImpl

The implementation type.

RebindWithFactoryMethod<T>(Func<T>)

Rewrites a binding for the specified service.

Declaration
public static void RebindWithFactoryMethod<T>(Func<T> resolveMethod)

    where T : class
Parameters
Type Name Description
System.Func<T> resolveMethod

Method that returns the specified service.

Type Parameters
Name Description
T

The service to resolve.

RebindWithFactoryMethod<T>(Func<T>, String)

Rewrites a binding for the specified service with the given name.

Declaration
public static void RebindWithFactoryMethod<T>(Func<T> resolveMethod, string name)

    where T : class
Parameters
Type Name Description
System.Func<T> resolveMethod

Method that returns the specified service.

System.String name

The name to give the binding.

Type Parameters
Name Description
T

The service to resolve.

TryGet<T>(String, out T, ConstructorArgument[])

Tries to get an instance of the specified service by using the first binding with the specified name.

Declaration
public static bool TryGet<T>(string name, out T instance, params ConstructorArgument[] constructorArguments)

    where T : class
Parameters
Type Name Description
System.String name

Full name of class.

T instance

Instance of resolve service.

ConstructorArgument[] constructorArguments

Array of the constructor arguments of the replacement type.

Returns
Type Description
System.Boolean

true if find instance of the class.

Type Parameters
Name Description
T

The service to resolve

Back to top Generated by DocFX