Class Registrar<T>
A registrar stores things of a single type that are accessible via an ID or via a name.
Types that are stored in a registrar must have a private constructor,
only the registrar is allowed to construct them so that the ID stays assigned and tracked properly.
Inheritance
System.Object
Registrar<T>
Implements
System.Collections.IEnumerable
System.Collections.Generic.IEnumerable<T>
Assembly: Eco.Core.dll
Syntax
[ForceCreateView(ViewTypeName = "RegistrarView")]
public class Registrar<T> : Object, IRegistrar, IController, IViewController, IHasUniversalID, ITrackedEnumerable, IEnumerable, IEnumerable<T> where T : class, IHasID
Type Parameters
Constructors
Registrar()
Declaration
Fields
Initializer
Declaration
public Initializer Initializer
Field Value
MaxNameLength
Declaration
Field Value
Type |
Description |
System.Int32 |
|
MinNameLength
Declaration
Field Value
Type |
Description |
System.Int32 |
|
Properties
Callbacks
Declaration
public TrackingCallbacks Callbacks { get; set; }
Property Value
ContainedType
Declaration
[SyncToView(null, true)]
public Type ContainedType { get; }
Property Value
Type |
Description |
System.Type |
|
ControllerID
Declaration
public ref int ControllerID { get; }
Property Value
Type |
Description |
System.Int32 |
|
Count
Declaration
public int Count { get; }
Property Value
Type |
Description |
System.Int32 |
|
EcopediaPageName
Declaration
public string EcopediaPageName { get; }
Property Value
Type |
Description |
System.String |
|
Hidden
Declaration
public bool Hidden { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
NameToObj
Declaration
protected ControllerDictionary<string, T> NameToObj { get; set; }
Property Value
Objs
Declaration
protected ControllerHashSet<T> Objs { get; set; }
Property Value
OnContentsChangedStates
Declaration
public ThreadSafeAction<IHasID, ProposableState> OnContentsChangedStates { get; set; }
Property Value
OnRenamed
Declaration
public ThreadSafeAction<IHasID, string> OnRenamed { get; set; }
Property Value
Random
Declaration
Property Value
RegistrarName
Declaration
public LocString RegistrarName { get; }
Property Value
SaveObject
Declaration
public ISaveablePlugin SaveObject { get; set; }
Property Value
ShareWithClient
Declaration
public bool ShareWithClient { get; }
Property Value
Type |
Description |
System.Boolean |
|
ShowInEcopedia
Declaration
public bool ShowInEcopedia { get; }
Property Value
Type |
Description |
System.Boolean |
|
Methods
Add()
Declaration
Returns
Add(INetObject)
Declaration
public T Add(INetObject netObj)
Parameters
Returns
Add(INetObject, String, Action<T>)
Declaration
public T Add(INetObject netObj, string name, Action<T> preInit = null)
Parameters
Type |
Name |
Description |
INetObject |
netObj |
|
System.String |
name |
|
System.Action<T> |
preInit |
|
Returns
Add(Type, INetObject, String, Action<T>)
Declaration
public T Add(Type type, INetObject netObj = null, string name = null, Action<T> preInit = null)
Parameters
Type |
Name |
Description |
System.Type |
type |
|
INetObject |
netObj |
|
System.String |
name |
|
System.Action<T> |
preInit |
|
Returns
Add<TImpl>(INetObject, String, Action<TImpl>)
Declaration
public TImpl Add<TImpl>(INetObject netObj, string name, Action<TImpl> preInit = null)
where TImpl : T
Parameters
Type |
Name |
Description |
INetObject |
netObj |
|
System.String |
name |
|
System.Action<TImpl> |
preInit |
|
Returns
Type Parameters
All()
Declaration
public IEnumerable<T> All()
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<T> |
|
Clear()
Declaration
GetByName(String)
Declaration
public T GetByName(string name)
Parameters
Type |
Name |
Description |
System.String |
name |
|
Returns
GetEnumerator()
Declaration
public IEnumerator<T> GetEnumerator()
Returns
Type |
Description |
System.Collections.Generic.IEnumerator<T> |
|
GetUniqueName(String)
Declaration
public string GetUniqueName(string name)
Parameters
Type |
Name |
Description |
System.String |
name |
|
Returns
Type |
Description |
System.String |
|
Initialize()
Declaration
Insert(T, INetObject, Boolean)
Declaration
public T Insert(T newObj, INetObject netObj = null, bool overrideMaxNameLength = false)
Parameters
Type |
Name |
Description |
T |
newObj |
|
INetObject |
netObj |
|
System.Boolean |
overrideMaxNameLength |
|
Returns
IsNameValid(String)
Declaration
public Result IsNameValid(string name)
Parameters
Type |
Name |
Description |
System.String |
name |
|
Returns
OfType<TResult>()
Declaration
public IEnumerable<TResult> OfType<TResult>()
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<TResult> |
|
Type Parameters
PreInit(LocString, Boolean, ISaveablePlugin, String, Boolean, Int32, Int32)
Declaration
public void PreInit(LocString registrarName, bool shareWithClient, ISaveablePlugin save, string ecopediaPageName = null, bool hidden = false, int minNameLength = -1, int maxNameLength = -1)
Parameters
Type |
Name |
Description |
LocString |
registrarName |
|
System.Boolean |
shareWithClient |
|
ISaveablePlugin |
save |
|
System.String |
ecopediaPageName |
|
System.Boolean |
hidden |
|
System.Int32 |
minNameLength |
|
System.Int32 |
maxNameLength |
|
Remove(T)
Declaration
Parameters
Type |
Name |
Description |
T |
t |
|
Returns
Type |
Description |
System.Boolean |
|
Remove(INetObject, T)
Declaration
public bool Remove(INetObject netObj, T obj)
Parameters
Returns
Type |
Description |
System.Boolean |
|
RemoveAll(Func<T, Boolean>)
Declaration
public void RemoveAll(Func<T, bool> func)
Parameters
Type |
Name |
Description |
System.Func<T, System.Boolean> |
func |
|
Rename(T, String, Boolean, Boolean)
Declaration
public Result Rename(T obj, string newName, bool changeNameIfAlreadyExists, bool overrideMaxNameLength = false)
Parameters
Type |
Name |
Description |
T |
obj |
|
System.String |
newName |
|
System.Boolean |
changeNameIfAlreadyExists |
|
System.Boolean |
overrideMaxNameLength |
|
Returns
SanitizeName(ref String, Boolean, String, Boolean)
Checks a name for requirements (length and profanity-free). If 'allowChanges' is set, it will fix the name to meet reqs. Otherwise it fails if it
doesnt meet reqs.
Declaration
public Result SanitizeName(ref string newName, bool allowChange, string registrarName = "", bool overrideMaxNameLength = false)
Parameters
Type |
Name |
Description |
System.String |
newName |
|
System.Boolean |
allowChange |
|
System.String |
registrarName |
|
System.Boolean |
overrideMaxNameLength |
|
Returns
Save()
Declaration
Snapshot()
Declaration
public IReadOnlySet<T> Snapshot()
Returns
Type |
Description |
System.Collections.Generic.IReadOnlySet<T> |
|
ToString()
Declaration
public override string ToString()
Returns
Type |
Description |
System.String |
|
UpdateName(T)
Declaration
public void UpdateName(T t)
Parameters
Type |
Name |
Description |
T |
t |
|
Verify()
Verifies all entities in the registry and removes all which fails the verification.
Declaration
Verify(T)
Declaration
public void Verify(T entity)
Parameters
Type |
Name |
Description |
T |
entity |
|
Explicit Interface Implementations
IRegistrar.Add(Type, INetObject, String)
Declaration
IHasID IRegistrar.Add(Type type, INetObject netObj, string name)
Parameters
Type |
Name |
Description |
System.Type |
type |
|
INetObject |
netObj |
|
System.String |
name |
|
Returns
IRegistrar.All()
Declaration
IEnumerable<IHasID> IRegistrar.All()
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<IHasID> |
|
IRegistrar.GetByName(String)
Declaration
IHasID IRegistrar.GetByName(string name)
Parameters
Type |
Name |
Description |
System.String |
name |
|
Returns
IRegistrar.Insert(IHasID, INetObject, Boolean)
Declaration
IHasID IRegistrar.Insert(IHasID newObj, INetObject netObj, bool overrideMaxNameLength)
Parameters
Type |
Name |
Description |
IHasID |
newObj |
|
INetObject |
netObj |
|
System.Boolean |
overrideMaxNameLength |
|
Returns
IRegistrar.Random
Declaration
IHasID IRegistrar.Random { get; }
Returns
IRegistrar.Remove(IHasID)
Declaration
bool IRegistrar.Remove(IHasID obj)
Parameters
Type |
Name |
Description |
IHasID |
obj |
|
Returns
Type |
Description |
System.Boolean |
|
IRegistrar.Remove(INetObject, IHasID)
Declaration
bool IRegistrar.Remove(INetObject netObj, IHasID obj)
Parameters
Returns
Type |
Description |
System.Boolean |
|
IRegistrar.Rename(IHasID, String, Boolean, Boolean)
Declaration
bool IRegistrar.Rename(IHasID obj, string newName, bool changeNameIfNeeded, bool overrideMaxNameLength)
Parameters
Type |
Name |
Description |
IHasID |
obj |
|
System.String |
newName |
|
System.Boolean |
changeNameIfNeeded |
|
System.Boolean |
overrideMaxNameLength |
|
Returns
Type |
Description |
System.Boolean |
|
Implements
System.Collections.IEnumerable
System.Collections.Generic.IEnumerable<>
Extension Methods