Class StateTransitionTransaction
A class to represent a transaction for changing the state of loaded mods.
Implements
Inherited Members
Namespace: IPA.Loader
Assembly: IPA.Loader.dll
Syntax
public sealed class StateTransitionTransaction : IDisposable
Properties
| Improve this Doc View SourceDisabledPlugins
Gets a list of plugins that are disabled according to this transaction's current state.
Declaration
public IEnumerable<PluginMetadata> DisabledPlugins { get; }
Property Value
Type | Description |
---|---|
IEnumerable<PluginMetadata> |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | if this object has been disposed |
EnabledPlugins
Gets a list of plugins that are enabled according to this transaction's current state.
Declaration
public IEnumerable<PluginMetadata> EnabledPlugins { get; }
Property Value
Type | Description |
---|---|
IEnumerable<PluginMetadata> |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | if this object has been disposed |
WillNeedRestart
Gets whether or not a game restart will be necessary to fully apply this transaction.
Declaration
public bool WillNeedRestart { get; }
Property Value
Type | Description |
---|---|
Boolean | true if any mod who's state is changed cannot be changed at runtime, false otherwise |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | if this object has been disposed |
Methods
| Improve this Doc View SourceCommit()
Commits this transaction to actual state, enabling and disabling plugins as necessary.
Declaration
public Task Commit()
Returns
Type | Description |
---|---|
Task | a Task which completes whenever all disables complete |
Remarks
After this completes, this transaction will be disposed.
The Task that is returned will error if any of the mods being disabled error. It is up to the caller to handle these in a sane way, like logging them. If nothing else, do something like this:
// get your transaction...
var complete = transaction.Commit();
await complete.ContinueWith(t => {
if (t.IsFaulted)
Logger.log.Error($"Error disabling plugins: {t.Exception}");
});
If you are running in a coroutine, you can use WaitForTask(Task) instead of await.
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | if this object has been disposed |
InvalidOperationException | if the plugins' state no longer matches this transaction's original state |
Disable(PluginMetadata, Boolean)
Disables a plugin in this transaction.
Declaration
public bool Disable(PluginMetadata meta, bool autoDependents = true)
Parameters
Type | Name | Description |
---|---|---|
PluginMetadata | meta | the plugin to disable |
Boolean | autoDependents | whether or not to automatically disable all dependents of the plugin |
Returns
Type | Description |
---|---|
Boolean | true if the transaction's state was changed, false otherwise |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | if this object has been disposed |
ArgumentException | if |
See Also
| Improve this Doc View SourceDisable(PluginMetadata, out IEnumerable<PluginMetadata>, Boolean)
Disables a plugin in this transaction.
Declaration
public bool Disable(PluginMetadata meta, out IEnumerable<PluginMetadata> enabledDependents, bool autoDependents = false)
Parameters
Type | Name | Description |
---|---|---|
PluginMetadata | meta | the plugin to disable |
IEnumerable<PluginMetadata> | enabledDependents | null if successful, otherwise a set of plugins that need to be disabled first |
Boolean | autoDependents | whether or not to automatically disable all dependents of the plugin |
Returns
Type | Description |
---|---|
Boolean | true if the transaction's state was changed, false otherwise |
Remarks
enabledDependents
will only be set when autoDependents
is false.
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | if this object has been disposed |
ArgumentException | if |
Dispose()
Disposes and discards this transaction without committing it.
Declaration
public void Dispose()
Enable(PluginMetadata, Boolean)
Enables a plugin in this transaction.
Declaration
public bool Enable(PluginMetadata meta, bool autoDeps = true)
Parameters
Type | Name | Description |
---|---|---|
PluginMetadata | meta | the plugin to enable |
Boolean | autoDeps | whether or not to automatically enable all dependencies of the plugin |
Returns
Type | Description |
---|---|
Boolean | true if the transaction's state was changed, false otherwise |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | if this object has been disposed |
ArgumentException | if |
See Also
| Improve this Doc View SourceEnable(PluginMetadata, out IEnumerable<PluginMetadata>, Boolean)
Enables a plugin in this transaction.
Declaration
public bool Enable(PluginMetadata meta, out IEnumerable<PluginMetadata> disabledDeps, bool autoDeps = false)
Parameters
Type | Name | Description |
---|---|---|
PluginMetadata | meta | the plugin to enable |
IEnumerable<PluginMetadata> | disabledDeps | null if successful, otherwise a set of plugins that need to be enabled first |
Boolean | autoDeps | whether or not to automatically enable all dependencies |
Returns
Type | Description |
---|---|
Boolean | true if the transaction's state was changed, false otherwise |
Remarks
disabledDeps
will only be set when autoDeps
is false.
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | if this object has been disposed |
ArgumentException | if |
IsDisabled(PluginMetadata)
Checks if a plugin is disabled according to this transaction's current state.
Declaration
public bool IsDisabled(PluginMetadata meta)
Parameters
Type | Name | Description |
---|---|---|
PluginMetadata | meta | the plugin to check |
Returns
Type | Description |
---|---|
Boolean | true if the plugin is disabled, false otherwise |
Remarks
This should be roughly equivalent to DisabledPlugins.Contains(meta)
, but more performant.
This should also always return the inverse of IsEnabled(PluginMetadata) for valid plugins.
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | if this object has been disposed |
See Also
| Improve this Doc View SourceIsEnabled(PluginMetadata)
Checks if a plugin is enabled according to this transaction's current state.
Declaration
public bool IsEnabled(PluginMetadata meta)
Parameters
Type | Name | Description |
---|---|---|
PluginMetadata | meta | the plugin to check |
Returns
Type | Description |
---|---|
Boolean | true if the plugin is enabled, false otherwise |
Remarks
This should be roughly equivalent to EnabledPlugins.Contains(meta)
, but more performant.
This should also always return the inverse of IsDisabled(PluginMetadata) for valid plugins.
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | if this object has been disposed |