mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-29 09:18:01 +01:00
* Replace all 342 `== null` with `is null`
* Replace 354 `!= null` with `is { }`
* Wrap these in conditionals since they break tests against Release configuration
The members they depend on do not exist in Release configuration
* Split these up and dispose properly
This test needs to be revisited for several reasons at some point.
* Fix release configuration tests
* Declare interface these already support
* Annotate constructor properly and use throw helper
* Move class to its own file
* Rename these files so they nest in the solution explorer
* Make this a record type and remove now-redundant/illegal members
* Reference passing to avoid some struct copies
* Simplify this
* Carry reference passing through as appropriate
* Turn this into a record struct
* Remove unused internal constructor and its test
It was only used by that test.
* Simplify this constructor
* This should be a property
* Simplify constructor
* Simplify GetHashCode
* Mark this ignored just in case
* Missed a couple of opportunities for reference passing
* record struct already does this by value
* Remove unused class
* Simplify the type initializer and Reset method
* Implement INotifyCollectionChanged and IDictionary by delegating to ColorSchemes
* Fix for reflection-based configuration
* Make CI build happy by disambiguiating this attribute
55 lines
2.3 KiB
C#
55 lines
2.3 KiB
C#
namespace Terminal.Gui;
|
|
|
|
/// <summary>The execution state for a <see cref="Toplevel"/> view.</summary>
|
|
public class RunState : IDisposable
|
|
{
|
|
/// <summary>Initializes a new <see cref="RunState"/> class.</summary>
|
|
/// <param name="view"></param>
|
|
public RunState (Toplevel view) { Toplevel = view; }
|
|
|
|
/// <summary>The <see cref="Toplevel"/> belonging to this <see cref="RunState"/>.</summary>
|
|
public Toplevel Toplevel { get; internal set; }
|
|
|
|
/// <summary>Releases all resource used by the <see cref="RunState"/> object.</summary>
|
|
/// <remarks>Call <see cref="Dispose()"/> when you are finished using the <see cref="RunState"/>.</remarks>
|
|
/// <remarks>
|
|
/// <see cref="Dispose()"/> method leaves the <see cref="RunState"/> in an unusable state. After calling
|
|
/// <see cref="Dispose()"/>, you must release all references to the <see cref="RunState"/> so the garbage collector can
|
|
/// reclaim the memory that the <see cref="RunState"/> was occupying.
|
|
/// </remarks>
|
|
public void Dispose ()
|
|
{
|
|
Dispose (true);
|
|
GC.SuppressFinalize (this);
|
|
#if DEBUG_IDISPOSABLE
|
|
WasDisposed = true;
|
|
#endif
|
|
}
|
|
|
|
/// <summary>Releases all resource used by the <see cref="RunState"/> object.</summary>
|
|
/// <param name="disposing">If set to <see langword="true"/> we are disposing and should dispose held objects.</param>
|
|
protected virtual void Dispose (bool disposing)
|
|
{
|
|
if (Toplevel is { } && disposing)
|
|
{
|
|
throw new InvalidOperationException (
|
|
"You must clean up (Dispose) the Toplevel before calling Application.RunState.Dispose"
|
|
);
|
|
}
|
|
}
|
|
|
|
#if DEBUG_IDISPOSABLE
|
|
/// <summary>For debug (see DEBUG_IDISPOSABLE define) purposes to verify objects are being disposed properly</summary>
|
|
public bool WasDisposed;
|
|
|
|
/// <summary>For debug (see DEBUG_IDISPOSABLE define) purposes to verify objects are being disposed properly</summary>
|
|
public int DisposedCount = 0;
|
|
|
|
/// <summary>For debug (see DEBUG_IDISPOSABLE define) purposes; the runstate instances that have been created</summary>
|
|
public static List<RunState> Instances = new ();
|
|
|
|
/// <summary>Creates a new RunState object.</summary>
|
|
public RunState () { Instances.Add (this); }
|
|
#endif
|
|
}
|