Table of Contents

Class ManagerBase<T, TM>

Namespace
RisingV.Shared.Managers
Assembly
RisingV.Shared.dll

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

Map<Type, bool>

LoadedMap

protected readonly Map<Type, bool> LoadedMap

Field Value

Map<Type, bool>

PluginsMap

protected readonly Map<Type, List<IPlugin>> PluginsMap

Field Value

Map<Type, List<IPlugin>>

ReadyMap

protected readonly Map<Type, bool> ReadyMap

Field Value

Map<Type, bool>

ReloadingMap

protected readonly Map<string, bool> ReloadingMap

Field Value

Map<string, bool>

Properties

AllowAutoReload

Indicates whether this manager allows auto-reloading of manageable objects.

public virtual bool AllowAutoReload { get; }

Property Value

bool

IsFullReloading

public bool IsFullReloading { get; protected set; }

Property Value

bool

IsInitialized

Indicates whether the manager is initialized.

public bool IsInitialized { get; protected set; }

Property Value

bool

IsLoaded

Indicates whether the manager is finished loading.

public bool IsLoaded { get; protected set; }

Property Value

bool

IsReady

Indicates whether the manager is ready to be used.

public bool IsReady { get; protected set; }

Property Value

bool

Log

protected abstract Logger Log { get; }

Property Value

Logger

UnsubscribeEventsOnRemoval

Indicates whether this manager should unsubscribe from events when manageable objects are removed.

public bool UnsubscribeEventsOnRemoval { get; set; }

Property Value

bool

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

plugin IPlugin
failIfExists bool

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 IPlugin

The plugin that is requesting the manageable object.

type Type

The type of the manageable object to get.

failIfExists bool

If 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

plugin IPlugin
manageable TX
failIfExists bool

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

type Type
dependentPlugins List<IPlugin>

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 IPlugin

The plugin that is reloading the manageable objects.

force bool

If true, forces the reload regardless of the file changes.

CanAutoReloadAll(IReadOnlyList<FileChange>)

protected virtual bool CanAutoReloadAll(IReadOnlyList<FileChange> fileChanges)

Parameters

fileChanges IReadOnlyList<FileChange>

Returns

bool

Count()

Count the number of manageable objects that are managed by this manager.

public int Count()

Returns

int

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 string

An 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

bool

Equals(object?)

Determines whether the specified object is equal to the current object.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

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

type Type
required bool

Returns

T

GetDependentPlugins(params IPlugin[]?)

public List<IPlugin> GetDependentPlugins(params IPlugin[]? additionalPlugins)

Parameters

additionalPlugins IPlugin[]

Returns

List<IPlugin>

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

type Type
additionalPlugins IPlugin[]

Returns

List<IPlugin>

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

string

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

typeName string
checkAssignable bool
checkEnabled bool

Returns

bool

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

type Type
checkAssignable bool
checkEnabled bool

Returns

bool

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

bool

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

bool

IsEnabled<TX>(TX?)

Is the manageable object enabled.

public virtual bool IsEnabled<TX>(TX? manageable) where TX : T

Parameters

manageable TX

Returns

bool

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

plugin IPlugin
manageable T
failIfExists bool

Type Parameters

TX

OnManageableRemoved<TX>(IPlugin, T?)

protected virtual void OnManageableRemoved<TX>(IPlugin plugin, T? manageable) where TX : T

Parameters

plugin IPlugin
manageable 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 IPlugin
reason 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 IPlugin
reason 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 IPlugin
obj 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 IManageable
plugin IPlugin

Returns

bool

TryLoad(IManageable, IPlugin)

Try to load the manageable object with the given plugin.

public bool TryLoad(IManageable manageable, IPlugin plugin)

Parameters

manageable IManageable
plugin IPlugin

Returns

bool

TryReady(IManageable, IPlugin)

public bool TryReady(IManageable manageable, IPlugin plugin)

Parameters

manageable IManageable
plugin IPlugin

Returns

bool

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 IManageable
plugin IPlugin
reason ReloadReason

Returns

bool

TryTerminate(IManageable, IPlugin)

Try to unload the manageable object with the given plugin.

public bool TryTerminate(IManageable manageable, IPlugin plugin)

Parameters

manageable IManageable
plugin IPlugin

Returns

bool

TryUnload(IManageable, IPlugin)

Try to ready the manageable object with the given plugin.

public bool TryUnload(IManageable manageable, IPlugin plugin)

Parameters

manageable IManageable
plugin IPlugin

Returns

bool

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