Class LambdaAdvancedFactoryBlueprint<TBlueprintID, TBlueprintConfig, TProduced>
An implementation of IAdvancedFactoryBlueprint<TBlueprintID, TBlueprintConfig, TProduced> that allows you to specify a Func object to use as the factory method.
Implements
Inherited Members
Namespace: GoRogue.Factories
Assembly: GoRogue.dll
Syntax
public class LambdaAdvancedFactoryBlueprint<TBlueprintID, TBlueprintConfig, TProduced> : IAdvancedFactoryBlueprint<TBlueprintID, TBlueprintConfig, TProduced>
Type Parameters
Name | Description |
---|---|
TBlueprintID | The type being used to identify what object to produce. |
TBlueprintConfig | The type of object to pass to the creation function. |
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 that takes a parameter. For more complex cases, you may want to implement your own IAdvancedFactoryBlueprint.
Constructors
View SourceLambdaAdvancedFactoryBlueprint(TBlueprintID, Func<TBlueprintConfig, TProduced>)
Constructor.
Declaration
public LambdaAdvancedFactoryBlueprint(TBlueprintID id, Func<TBlueprintConfig, TProduced> factoryMethod)
Parameters
Type | Name | Description |
---|---|---|
TBlueprintID | id | A unique identifier for this factory blueprint definition. |
Func<TBlueprintConfig, TProduced> | factoryMethod | The method to call when Create(TBlueprintConfig) 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(TBlueprintConfig)
Creates an object of the type specified by TProduced using the given configuration parameters.
Declaration
public TProduced Create(TBlueprintConfig config)
Parameters
Type | Name | Description |
---|---|---|
TBlueprintConfig | config | Configuration parameters used to create the object. |
Returns
Type | Description |
---|---|
TProduced | The created object. |