File size: 2,266 Bytes
8c763fb | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Text;
namespace Microsoft.Management.UI.Internal
{
/// <summary>
/// Base proxy class for other classes which wish to have save and restore functionality.
/// </summary>
/// <typeparam name="T">There are no restrictions on T.</typeparam>
[SuppressMessage("Microsoft.MSInternal", "CA903:InternalNamespaceShouldNotContainPublicTypes")]
public abstract class StateDescriptor<T>
{
private Guid id;
private string name;
/// <summary>
/// Creates a new instances of the StateDescriptor class and creates a new GUID.
/// </summary>
protected StateDescriptor()
{
this.Id = Guid.NewGuid();
}
/// <summary>
/// Constructor overload to provide name.
/// </summary>
/// <param name="name">The friendly name for the StateDescriptor.</param>
protected StateDescriptor(string name)
: this()
{
this.Name = name;
}
/// <summary>
/// Gets the global unique identification number.
/// </summary>
public Guid Id
{
get
{
return this.id;
}
protected set
{
this.id = value;
}
}
/// <summary>
/// Gets or sets the friendly display name.
/// </summary>
public string Name
{
get
{
return this.name;
}
set
{
this.name = value;
}
}
/// <summary>
/// Saves a snapshot of the subject's current state.
/// </summary>
/// <param name="subject">The object whose state will be saved.</param>
public abstract void SaveState(T subject);
/// <summary>
/// Restores the state of subject to the saved state.
/// </summary>
/// <param name="subject">The object whose state will be restored.</param>
public abstract void RestoreState(T subject);
}
}
|