Class ManagerBase<T, TM>
Base class for managers that handle manageable objects.
public abstract class ManagerBase<T, TM> : IManager<T, TM>, IManager, IManageable where T : class, IManageable<TM> where TM : class, IManager
Type Parameters
T
The type of manageable objects this manager handles, must implement IManageable<T>.
TM
The type of manager interface this manager implements, must implement IManager.
- Inheritance
-
ManagerBase<T, TM>
- Implements
-
IManager<T, TM>
- Derived
- Inherited Members
- Extension Methods
Constructors
ManagerBase(IManagerSource<T, TM>)
protected ManagerBase(IManagerSource<T, TM> source)
Parameters
source
IManagerSource<T, TM>
Fields
InitializedMap
protected readonly Map<Type, bool> InitializedMap
Field Value
LoadedMap
protected readonly Map<Type, bool> LoadedMap
Field Value
PluginsMap
protected readonly Map<Type, List<IPlugin>> PluginsMap
Field Value
ReadyMap
protected readonly Map<Type, bool> ReadyMap
Field Value
ReloadingMap
protected readonly Map<string, bool> ReloadingMap
Field Value
Properties
AllowAutoReload
Indicates whether this manager allows auto-reloading of manageable objects.
public virtual bool AllowAutoReload { get; }
Property Value
IsFullReloading
public bool IsFullReloading { get; protected set; }
Property Value
IsInitialized
Indicates whether the manager is initialized.
public bool IsInitialized { get; protected set; }
Property Value
IsLoaded
Indicates whether the manager is finished loading.
public bool IsLoaded { get; protected set; }
Property Value
IsReady
Indicates whether the manager is ready to be used.
public bool IsReady { get; protected set; }
Property Value
Log
protected abstract Logger Log { get; }
Property Value
UnsubscribeEventsOnRemoval
Indicates whether this manager should unsubscribe from events when manageable objects are removed.
public bool UnsubscribeEventsOnRemoval { get; set; }
Property Value
Methods
Add<TX>(IPlugin, bool)
Add a manageable object of the given type to the manager.
public TX? Add<TX>(IPlugin plugin, bool failIfExists = true) where TX : T
Parameters
Returns
- TX
Type Parameters
TX
Add<TX>(IPlugin, Type, bool)
Get a manageable object of the given type.
public virtual void Add<TX>(IPlugin plugin, Type type, bool failIfExists = true) where TX : IManageable
Parameters
plugin
IPluginThe plugin that is requesting the manageable object.
type
TypeThe type of the manageable object to get.
failIfExists
boolIf true, will throw an exception if the manageable object already exists.
Type Parameters
TX
Type of the manageable object to get, must implement IManageable.
Add<TX>(IPlugin, TX, bool)
Add a manageable object of the given type to the manager.
public virtual void Add<TX>(IPlugin plugin, TX manageable, bool failIfExists = true) where TX : T
Parameters
Type Parameters
TX
AssignDependentPlugins(Type, List<IPlugin>)
Assign a list of dependent plugins to the given type.
public void AssignDependentPlugins(Type type, List<IPlugin> dependentPlugins)
Parameters
AutoReload(IReadOnlyList<FileChange>, IPlugin, bool)
Automatically reloads manageable objects based on file changes.
protected virtual void AutoReload(IReadOnlyList<FileChange> fileChanges, IPlugin plugin, bool force = false)
Parameters
fileChanges
IReadOnlyList<FileChange>List of file changes that triggered the reload.
plugin
IPluginThe plugin that is reloading the manageable objects.
force
boolIf true, forces the reload regardless of the file changes.
CanAutoReloadAll(IReadOnlyList<FileChange>)
protected virtual bool CanAutoReloadAll(IReadOnlyList<FileChange> fileChanges)
Parameters
fileChanges
IReadOnlyList<FileChange>
Returns
Count()
Count the number of manageable objects that are managed by this manager.
public int Count()
Returns
DebugPrintAll(string)
Prints all manageable objects in this manager to the debug log with an optional prefix message.
public virtual void DebugPrintAll(string prefixMessage = "")
Parameters
prefixMessage
stringAn optional prefix message to include in the debug log.
Equals(ManagerBase<T, TM>)
protected bool Equals(ManagerBase<T, TM> other)
Parameters
other
ManagerBase<T, TM>
Returns
Equals(object?)
Determines whether the specified object is equal to the current object.
public override bool Equals(object? obj)
Parameters
obj
objectThe object to compare with the current object.
Returns
ForEach(Action<T>)
Execute an action for each manageable object in the manager.
public void ForEach(Action<T> action)
Parameters
action
Action<T>The action to execute for each manageable object.
Get(Type, bool)
public T? Get(Type type, bool required = true)
Parameters
Returns
- T
GetDependentPlugins(params IPlugin[]?)
public List<IPlugin> GetDependentPlugins(params IPlugin[]? additionalPlugins)
Parameters
additionalPlugins
IPlugin[]
Returns
GetDependentPlugins(Type, params IPlugin[]?)
Get a list of plugins that depend on the given type.
public List<IPlugin> GetDependentPlugins(Type type, params IPlugin[]? additionalPlugins)
Parameters
Returns
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
A hash code for the current object.
GetList()
Get a manageable object of the given type from the manager.
public List<T> GetList()
Returns
- List<T>
GetManagedInfo()
Get a formatted string of all manageable objects that are managed by this manager.
public string GetManagedInfo()
Returns
GetOrCreate<TX>(IPlugin)
Get a manageable object of the given type from the manager.
public TX GetOrCreate<TX>(IPlugin plugin) where TX : T
Parameters
plugin
IPlugin
Returns
- TX
Type Parameters
TX
Get<TX>(bool)
Get a manageable object of the given type from the manager.
public TX? Get<TX>(bool required = true) where TX : T
Parameters
required
bool
Returns
- TX
Type Parameters
TX
Has(string, bool, bool)
Check if the manager has a manageable object of the given type by its name.
public bool Has(string typeName, bool checkAssignable = true, bool checkEnabled = false)
Parameters
Returns
Has(Type, bool, bool)
Check if the manager has a manageable object of the given type.
public bool Has(Type type, bool checkAssignable = true, bool checkEnabled = false)
Parameters
Returns
Has<TX>(bool)
Check if the manager has a manageable object of the given type.
public bool Has<TX>(bool checkEnabled = false) where TX : T
Parameters
checkEnabled
bool
Returns
Type Parameters
TX
Initialize(IPlugin)
Initialize the manager with the given plugin including its manageable objects.
public virtual void Initialize(IPlugin plugin)
Parameters
plugin
IPlugin
IsEnabled(IManageable?)
Check if the manageable object is enabled.
public virtual bool IsEnabled(IManageable? manageable)
Parameters
manageable
IManageable
Returns
IsEnabled<TX>(TX?)
Is the manageable object enabled.
public virtual bool IsEnabled<TX>(TX? manageable) where TX : T
Parameters
manageable
TX
Returns
Type Parameters
TX
Load(IPlugin)
Load the manager with the given plugin including its manageable objects. This should be called after all other Managers have been initialized.
public virtual void Load(IPlugin plugin)
Parameters
plugin
IPlugin
OnManageableAdded<TX>(IPlugin, T?, bool)
protected virtual void OnManageableAdded<TX>(IPlugin plugin, T? manageable, bool failIfExists) where TX : T
Parameters
Type Parameters
TX
OnManageableRemoved<TX>(IPlugin, T?)
protected virtual void OnManageableRemoved<TX>(IPlugin plugin, T? manageable) where TX : T
Parameters
plugin
IPluginmanageable
T
Type Parameters
TX
OnReload(IPlugin, ReloadReason)
Called when a reload is requested, can be used to perform custom actions before the reload and override the default reload behavior.
public virtual bool OnReload(IPlugin plugin, ReloadReason reason)
Parameters
plugin
IPluginreason
ReloadReason
Returns
- bool
true to allow default reload behaviour, false to stop
Ready(IPlugin)
Ready the manager with the given plugin including its manageable objects. This should be called after all other Managers have been loaded.
public virtual void Ready(IPlugin plugin)
Parameters
plugin
IPlugin
Reload(ReloadReason)
public virtual void Reload(ReloadReason reason)
Parameters
reason
ReloadReason
Reload(IPlugin, ReloadReason)
Reload the manager with the given plugin including its manageable objects. The manageable objects should be unloaded before calling their Reload method and should then be loaded after.
public virtual void Reload(IPlugin plugin, ReloadReason reason)
Parameters
plugin
IPluginreason
ReloadReason
Remove<TX>(IPlugin)
Remove a manageable object of the given type from the manager.
public void Remove<TX>(IPlugin plugin) where TX : T
Parameters
plugin
IPlugin
Type Parameters
TX
Remove<TX>(IPlugin, TX)
Remove a manageable object of the given type from the manager.
public void Remove<TX>(IPlugin plugin, TX obj) where TX : T
Parameters
plugin
IPluginobj
TX
Type Parameters
TX
RequiredType()
Type of the object that is required.
public Type RequiredType()
Returns
- Type
Returns the type of the required manageable object.
RequiredTypeName()
Type name of the object that is required.
public string RequiredTypeName()
Returns
- string
Returns the name of the required manageable object type.
Select(Func<KeyValuePair<Type, T>, T>)
Select manageable objects using a selector function.
public IEnumerable<T> Select(Func<KeyValuePair<Type, T>, T> selector)
Parameters
selector
Func<KeyValuePair<Type, T>, T>The function to select manageable objects.
Returns
- IEnumerable<T>
Terminate(IPlugin)
Terminate the manager with the given plugin including its manageable objects. This should be called when the plugin is being unloaded or the manager is being disposed.
public virtual void Terminate(IPlugin plugin)
Parameters
plugin
IPlugin
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.
TryInitialize(IManageable, IPlugin)
Try to initialize the manageable object with the given plugin.
public bool TryInitialize(IManageable manageable, IPlugin plugin)
Parameters
manageable
IManageableplugin
IPlugin
Returns
TryLoad(IManageable, IPlugin)
Try to load the manageable object with the given plugin.
public bool TryLoad(IManageable manageable, IPlugin plugin)
Parameters
manageable
IManageableplugin
IPlugin
Returns
TryReady(IManageable, IPlugin)
public bool TryReady(IManageable manageable, IPlugin plugin)
Parameters
manageable
IManageableplugin
IPlugin
Returns
TryReload(IManageable, IPlugin, ReloadReason)
Try to reload the manageable object with the given plugin.
public bool TryReload(IManageable manageable, IPlugin plugin, ReloadReason reason)
Parameters
manageable
IManageableplugin
IPluginreason
ReloadReason
Returns
TryTerminate(IManageable, IPlugin)
Try to unload the manageable object with the given plugin.
public bool TryTerminate(IManageable manageable, IPlugin plugin)
Parameters
manageable
IManageableplugin
IPlugin
Returns
TryUnload(IManageable, IPlugin)
Try to ready the manageable object with the given plugin.
public bool TryUnload(IManageable manageable, IPlugin plugin)
Parameters
manageable
IManageableplugin
IPlugin
Returns
Unload(IPlugin)
Unload the manager with the given plugin including its manageable objects. This should be called before the manager is terminated.
public virtual void Unload(IPlugin plugin)
Parameters
plugin
IPlugin