Class LambdaFactoryBlueprint<TBlueprintID, TProduced>
An implementation of IFactoryBlueprint<TBlueprintID, TProduced> that allows you to specify a Func object to use as the factory method.
Implements
IFactoryBlueprint<TBlueprintID, TProduced>
Inherited Members
Namespace: GoRogue.Factories
Assembly: GoRogue.dll
Syntax
public class LambdaFactoryBlueprint<TBlueprintID, TProduced> : IFactoryBlueprint<TBlueprintID, TProduced>
Type Parameters
Name | Description |
---|---|
TBlueprintID | The type being used to identify what object to produce. |
TProduced | The type of object being produced. |
Remarks
This class may be useful for simple cases where your blueprint has no state, and you simply need to specify some code to run to create the object. For more complex cases, you may want to implement your own IFactoryBlueprint.
Constructors
View SourceLambdaFactoryBlueprint(TBlueprintID, Func<TProduced>)
Constructor.
Declaration
public LambdaFactoryBlueprint(TBlueprintID id, Func<TProduced> factoryMethod)
Parameters
Type | Name | Description |
---|---|---|
TBlueprintID | id | A unique identifier for this factory blueprint definition. |
Func<TProduced> | factoryMethod | The method to call when Create() is used in order to get the object to return. |
Properties
View SourceID
A unique identifier of this factory definition.
Declaration
public TBlueprintID ID { get; }
Property Value
Type | Description |
---|---|
TBlueprintID |
Methods
View SourceCreate()
Creates an object of the type specified by TProduced.
Declaration
public TProduced Create()
Returns
Type | Description |
---|---|
TProduced | The created object. |