mirror of
https://github.com/Stone-Red-Code/DesktopMagic.git
synced 2026-09-04 08:56:15 +02:00
Add plugin state persistence via PersistStateAttribute serialization
This commit is contained in:
@@ -50,4 +50,13 @@ public interface IPluginData
|
||||
/// <param name="message">The message to display.</param>
|
||||
/// <param name="title">The title of the message box.</param>
|
||||
void ShowMessage(string message, string title);
|
||||
|
||||
/// <summary>
|
||||
/// Saves the current state of fields and properties marked with <see cref="PersistStateAttribute"/>
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// State is automatically saved when the plugin stops, but this method can be called
|
||||
/// to save state at any time, such as after important user interactions.
|
||||
/// </remarks>
|
||||
void SaveState();
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
|
||||
namespace DesktopMagic.Api;
|
||||
|
||||
/// <summary>
|
||||
/// Marks a field or property to be automatically persisted between plugin sessions.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The field or property must be JSON serializable. Complex types should have parameterless constructors.
|
||||
/// State is saved when the plugin stops and loaded when it starts.
|
||||
/// </remarks>
|
||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
|
||||
public sealed class PersistStateAttribute : Attribute
|
||||
{
|
||||
}
|
||||
Reference in New Issue
Block a user