This type of SymbolPool helps create more strongly typed Symbols that simulate enums, but provide extensibility. Specifically, it creates SymbolE objects, where SymbolE is some derived class of Symbol.
- Template Parameters
-
SymbolE | A derived class of Symbol that owns the pool. See the example below. |
public class ShapeType : Symbol { private ShapeType(Symbol prototype) : base(prototype) { } public static new readonly SymbolPool<ShapeType> Pool = new SymbolPool<ShapeType>(p => new ShapeType(p));
public static readonly ShapeType Circle = Pool.Get("Circle"); public static readonly ShapeType Rect = Pool.Get("Rect"); public static readonly ShapeType Line = Pool.Get("Line"); public static readonly ShapeType Polygon = Pool.Get("Polygon"); }
|
delegate SymbolE | SymbolFactory (Symbol prototype) |
|
| SymbolPool (SymbolFactory factory) |
|
| SymbolPool (SymbolFactory factory, int firstID) |
|
new SymbolE | Get (string name) |
|
new SymbolE | Get (string name, int id) |
|
new SymbolE | GetIfExists (string name) |
|
new SymbolE | GetById (int id) |
|
new IEnumerator< SymbolE > | GetEnumerator () |
|
| SymbolPool (int firstID) |
|
Symbol | Get (string name) |
| Gets a symbol from this pool, or creates it if it does not exist in this pool already. More...
|
|
Symbol | Get (string name, int id) |
| Creates a Symbol in this pool with a specific ID, or verifies that the requested Name-Id pair is present in the pool. More...
|
|
Symbol | GetIfExists (string name) |
| Gets a symbol from this pool, if the name exists already. More...
|
|
Symbol | GetGlobalOrCreateHere (string name) |
| Gets a symbol from the global pool, if it exists there already; otherwise, creates a Symbol in this pool. More...
|
|
Symbol | GetById (int id) |
| Gets a symbol by its ID, or null if there is no such symbol. More...
|
|
IEnumerator< Symbol > | GetEnumerator () |
|