Interface IBlockFactory

Defines a factory that creates runtime block instances from a JsonModel configuration.

Namespace: MOSAIC.Components.Interfaces
Assembly: MOSAIC.dll
Syntax
public interface IBlockFactory
Remarks

Implementations typically use Type to resolve a concrete runtime type (for example via reflection or dependency injection) and then apply configuration values such as Params, Inputs, and DesiredRate.

The factory returns object to support heterogeneous pipelines. Use Create<T>(JsonModel) when the expected block type is known.

Methods

Create(JsonModel)

Creates a block instance from the provided configuration model.

Declaration
object Create(JsonModel m)
Parameters
Type Name Description
JsonModel m

Block configuration model.

Returns
Type Description
object

The created block instance.

Exceptions
Type Condition
ArgumentNullException

Thrown if m is null.

InvalidOperationException

Thrown if the configuration cannot be resolved to a concrete block type or the block cannot be constructed.

Create<T>(JsonModel)

Creates a block instance from the provided configuration model and casts it to T.

Declaration
T Create<T>(JsonModel m) where T : class
Parameters
Type Name Description
JsonModel m

Block configuration model.

Returns
Type Description
T

The created block instance cast to T.

Type Parameters
Name Description
T

Expected runtime type of the created block.

Exceptions
Type Condition
ArgumentNullException

Thrown if m is null.

InvalidOperationException

Thrown if the configuration cannot be resolved to a concrete block type, the block cannot be constructed, or the created instance is not compatible with T.

GetBlockType(string)

Resolves a registered runtime type without opening devices. Custom factories may return null.

Declaration
Type? GetBlockType(string type)
Parameters
Type Name Description
string type
Returns
Type Description
Type

Search documentation

Start typing to search the documentation.