Class AdvancedFactory<TBlueprintID, TBlueprintConfig, TProduced>
A more advanced factory that produces a type of object based on a blueprint and a set of configuration parameters.
Implements
Inherited Members
Namespace: GoRogue.Factories
Assembly: GoRogue.dll
Syntax
[DataContract]
public class AdvancedFactory<TBlueprintID, TBlueprintConfig, TProduced> : IEnumerable<IAdvancedFactoryBlueprint<TBlueprintID, TBlueprintConfig, TProduced>>, IEnumerable where TBlueprintID : notnull
Type Parameters
| Name | Description |
|---|---|
| TBlueprintID | The type used to uniquely identify blueprints. |
| TBlueprintConfig | The type of parameter passed to the Create(TBlueprintID, TBlueprintConfig) function each time an object is created. |
| TProduced | The type of object this factory creates. |
Constructors
View SourceAdvancedFactory()
Constructor.
Declaration
public AdvancedFactory()
AdvancedFactory(IEnumerable<IAdvancedFactoryBlueprint<TBlueprintID, TBlueprintConfig, TProduced>>)
Constructor. Takes some initial blueprints to add.
Declaration
public AdvancedFactory(IEnumerable<IAdvancedFactoryBlueprint<TBlueprintID, TBlueprintConfig, TProduced>> initialBlueprints)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<IAdvancedFactoryBlueprint<TBlueprintID, TBlueprintConfig, TProduced>> | initialBlueprints | Initial blueprints to add. |
Methods
View SourceAdd(IAdvancedFactoryBlueprint<TBlueprintID, TBlueprintConfig, TProduced>)
Adds a blueprint to the factory.
Declaration
public void Add(IAdvancedFactoryBlueprint<TBlueprintID, TBlueprintConfig, TProduced> blueprint)
Parameters
| Type | Name | Description |
|---|---|---|
| IAdvancedFactoryBlueprint<TBlueprintID, TBlueprintConfig, TProduced> | blueprint | The blueprint to add. |
AddRange(IEnumerable<IAdvancedFactoryBlueprint<TBlueprintID, TBlueprintConfig, TProduced>>)
Adds the given blueprints to the factory.
Declaration
public void AddRange(IEnumerable<IAdvancedFactoryBlueprint<TBlueprintID, TBlueprintConfig, TProduced>> blueprints)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<IAdvancedFactoryBlueprint<TBlueprintID, TBlueprintConfig, TProduced>> | blueprints | The blueprints to add. |
BlueprintExists(TBlueprintID)
Checks if a blueprint exists.
Declaration
public bool BlueprintExists(TBlueprintID blueprintID)
Parameters
| Type | Name | Description |
|---|---|---|
| TBlueprintID | blueprintID | The blueprint to check for. |
Returns
| Type | Description |
|---|---|
| bool | Returns true when the specified |
Create(TBlueprintID, TBlueprintConfig)
Creates a TProduced object using the blueprint with the given factory id, and the given
settings object.
Declaration
public TProduced Create(TBlueprintID blueprintID, TBlueprintConfig blueprintConfig)
Parameters
| Type | Name | Description |
|---|---|---|
| TBlueprintID | blueprintID | The factory id of a blueprint. |
| TBlueprintConfig | blueprintConfig | A settings object passed to the Create function of the blueprint. |
Returns
| Type | Description |
|---|---|
| TProduced | A new object. |
GetBlueprint(TBlueprintID)
Gets a blueprint by identifier.
Declaration
public IAdvancedFactoryBlueprint<TBlueprintID, TBlueprintConfig, TProduced> GetBlueprint(TBlueprintID blueprintID)
Parameters
| Type | Name | Description |
|---|---|---|
| TBlueprintID | blueprintID | The blueprint identifier to get. |
Returns
| Type | Description |
|---|---|
| IAdvancedFactoryBlueprint<TBlueprintID, TBlueprintConfig, TProduced> | The blueprint of the object. |
Exceptions
| Type | Condition |
|---|---|
| ItemNotDefinedException<TBlueprintID> | Thrown if the factory identifier does not exist. |
GetEnumerator()
Gets an enumerator of all of the blueprints in the factory.
Declaration
public IEnumerator<IAdvancedFactoryBlueprint<TBlueprintID, TBlueprintConfig, TProduced>> GetEnumerator()
Returns
| Type | Description |
|---|---|
| IEnumerator<IAdvancedFactoryBlueprint<TBlueprintID, TBlueprintConfig, TProduced>> | An enumeration of the blueprints. |