Class NameRegistry<T>
- Namespace
- TypedRest.CodeGeneration.Generation
- Assembly
- TypedRest.CodeGeneration.dll
Keeps track of the names handed out during a generation run, so that no two generated types end up with the same name.
public class NameRegistry<T>
Type Parameters
TThe type representing a name, e.g. a language-specific type identifier.
- Inheritance
-
objectNameRegistry<T>
Constructors
NameRegistry(Func<T, string>, Func<T, int, T>)
Keeps track of the names handed out during a generation run, so that no two generated types end up with the same name.
public NameRegistry(Func<T, string> getKey, Func<T, int, T> withNumber)
Parameters
getKeyFunc<T, string>Maps a name to the string used to detect collisions.
withNumberFunc<T, int, T>Creates a copy of a name with a number appended to it.
Methods
Register(IEnumerable<T>)
Registers the first of the candidates that is still free.
Falls back to appending a number to the last candidate if all of them are taken.
public T Register(IEnumerable<T> candidates)
Parameters
candidatesIEnumerable<T>
Returns
- T
Register(T)
Registers a name, appending a number if it is already taken.
public T Register(T candidate)
Parameters
candidateT
Returns
- T