Show / Hide Table of Contents

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>
GeneratedRegistrar<T>
Implements
IRegistrar
IController
IViewController
IHasUniversalID
ITrackedEnumerable
System.Collections.IEnumerable
System.Collections.Generic.IEnumerable<T>
Namespace: Eco.Core.Systems
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
Name Description
T

Constructors

Registrar()

Declaration
public Registrar()

Fields

Initializer

Declaration
public Initializer Initializer
Field Value
Type Description
Initializer

MaxNameLength

Max name length of entry in this registrar, can be overriden in PreInit(LocString, Boolean, ISaveablePlugin, String, Boolean, Int32, Int32)

Declaration
public int MaxNameLength
Field Value
Type Description
System.Int32

MinNameLength

Min name length of entry in this registrar, can be overriden in PreInit(LocString, Boolean, ISaveablePlugin, String, Boolean, Int32, Int32)

Declaration
public int MinNameLength
Field Value
Type Description
System.Int32

Properties

Callbacks

Declaration
public TrackingCallbacks Callbacks { get; set; }
Property Value
Type Description
TrackingCallbacks

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
Type Description
ControllerDictionary<System.String, T>

Objs

Declaration
protected ControllerHashSet<T> Objs { get; set; }
Property Value
Type Description
ControllerHashSet<T>

OnContentsChangedStates

Declaration
public ThreadSafeAction<IHasID, ProposableState> OnContentsChangedStates { get; set; }
Property Value
Type Description
ThreadSafeAction<IHasID, ProposableState>

OnRenamed

Declaration
public ThreadSafeAction<IHasID, string> OnRenamed { get; set; }
Property Value
Type Description
ThreadSafeAction<IHasID, System.String>

Random

Declaration
public T Random { get; }
Property Value
Type Description
T

RegistrarName

Declaration
public LocString RegistrarName { get; }
Property Value
Type Description
LocString

SaveObject

Declaration
public ISaveablePlugin SaveObject { get; set; }
Property Value
Type Description
ISaveablePlugin

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
public T Add()
Returns
Type Description
T

Add(INetObject)

Declaration
public T Add(INetObject netObj)
Parameters
Type Name Description
INetObject netObj
Returns
Type Description
T

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
Type Description
T

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
Type Description
T

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 Description
TImpl
Type Parameters
Name Description
TImpl

All()

Declaration
public IEnumerable<T> All()
Returns
Type Description
System.Collections.Generic.IEnumerable<T>

Clear()

Declaration
public void Clear()

GetByName(String)

Declaration
public T GetByName(string name)
Parameters
Type Name Description
System.String name
Returns
Type Description
T

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
public void Initialize()

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
Type Description
T

IsNameValid(String)

Declaration
public Result IsNameValid(string name)
Parameters
Type Name Description
System.String name
Returns
Type Description
Result

OfType<TResult>()

Declaration
public IEnumerable<TResult> OfType<TResult>()
Returns
Type Description
System.Collections.Generic.IEnumerable<TResult>
Type Parameters
Name Description
TResult

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
public bool Remove(T t)
Parameters
Type Name Description
T t
Returns
Type Description
System.Boolean

Remove(INetObject, T)

Declaration
public bool Remove(INetObject netObj, T obj)
Parameters
Type Name Description
INetObject netObj
T obj
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
Type Description
Result

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
Type Description
Result

Save()

Declaration
public void Save()

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
public void Verify()

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
Type Description
IHasID

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
Type Description
IHasID

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
Type Description
IHasID

IRegistrar.Random

Declaration
IHasID IRegistrar.Random { get; }
Returns
Type Description
IHasID

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
Type Name Description
INetObject netObj
IHasID obj
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

IRegistrar
IController
IViewController
IHasUniversalID
ITrackedEnumerable
System.Collections.IEnumerable
System.Collections.Generic.IEnumerable<>

Extension Methods

PropertyChanges.FirePropertyChanged(Object, String)
PropertyChanges.FirePropertyChanged(Object, String, Object, Object)
PropertyChanges.FirePropertyChanged(Object, MemberChangedBeforeAfterEventArgs)
☀
☾
In This Article
Back to top
Copyright (c) Strange Loop Games 2021
☀
☾