Show / Hide Table of Contents

Class Factory<TBlueprintID, TProduced>

A simple factory that produces a type of object based on a blueprint.

Inheritance
object
Factory<TBlueprintID, TProduced>
Implements
IEnumerable<IFactoryBlueprint<TBlueprintID, TProduced>>
IEnumerable
Inherited Members
object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: GoRogue.Factories
Assembly: GoRogue.dll
Syntax
[DataContract]
public class Factory<TBlueprintID, TProduced> : IEnumerable<IFactoryBlueprint<TBlueprintID, TProduced>>, IEnumerable where TBlueprintID : notnull
Type Parameters
Name Description
TBlueprintID

The type used to uniquely identify blueprints.

TProduced

The type of object this factory creates.

Constructors

View Source

Factory()

Constructor.

Declaration
public Factory()
View Source

Factory(IEnumerable<IFactoryBlueprint<TBlueprintID, TProduced>>)

Constructor. Takes initial blueprints to add.

Declaration
public Factory(IEnumerable<IFactoryBlueprint<TBlueprintID, TProduced>> initialBlueprints)
Parameters
Type Name Description
IEnumerable<IFactoryBlueprint<TBlueprintID, TProduced>> initialBlueprints

Initial blueprints to add.

Methods

View Source

Add(IFactoryBlueprint<TBlueprintID, TProduced>)

Adds a blueprint to the factory.

Declaration
public void Add(IFactoryBlueprint<TBlueprintID, TProduced> blueprint)
Parameters
Type Name Description
IFactoryBlueprint<TBlueprintID, TProduced> blueprint

The blueprint to add.

View Source

AddRange(IEnumerable<IFactoryBlueprint<TBlueprintID, TProduced>>)

Adds the given blueprints to the factory.

Declaration
public void AddRange(IEnumerable<IFactoryBlueprint<TBlueprintID, TProduced>> blueprints)
Parameters
Type Name Description
IEnumerable<IFactoryBlueprint<TBlueprintID, TProduced>> blueprints

The blueprints to add.

View Source

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 blueprintID exists; otherwise false.

View Source

Create(TBlueprintID)

Creates a TProduced object using the blueprint with the given factory id.

Declaration
public TProduced Create(TBlueprintID blueprintID)
Parameters
Type Name Description
TBlueprintID blueprintID

The factory id of a blueprint.

Returns
Type Description
TProduced

A new object.

View Source

GetBlueprint(TBlueprintID)

Gets a blueprint by identifier.

Declaration
public IFactoryBlueprint<TBlueprintID, TProduced> GetBlueprint(TBlueprintID blueprintID)
Parameters
Type Name Description
TBlueprintID blueprintID

The blueprint identifier to get.

Returns
Type Description
IFactoryBlueprint<TBlueprintID, TProduced>

The blueprint of the object.

Exceptions
Type Condition
ItemNotDefinedException<TBlueprintID>

Thrown if the factory identifier does not exist.

View Source

GetEnumerator()

Gets an enumerator of all of the blueprints in the factory.

Declaration
public IEnumerator<IFactoryBlueprint<TBlueprintID, TProduced>> GetEnumerator()
Returns
Type Description
IEnumerator<IFactoryBlueprint<TBlueprintID, TProduced>>

An enumeration of the blueprints.

Implements

IEnumerable<T>
IEnumerable

Extension Methods

Utility.Yield<T>(T)
  • View Source
In this article
Back to top Generated by DocFX