[corlib] Avoid unnecessary ephemeron array resizes
[mono.git] / mcs / class / referencesource / System.Activities.Presentation / System.Activities.Presentation / System / Activities / Presentation / Base / Core / Internal / PropertyEditing / State / PersistedState.cs
1 //----------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation.  All rights reserved.
3 //----------------------------------------------------------------
4 namespace System.Activities.Presentation.Internal.PropertyEditing.State 
5 {
6     using System;
7
8     // <summary>
9     // Simple base class for persisted state objects so that we can reuse a chunk of the logic
10     // from one persistent state storage to another.
11     // </summary>
12     internal abstract class PersistedState 
13     {
14
15         // <summary>
16         // Gets a value indicating whether the content of the state object is significant
17         // enough that it warrants serialization
18         // </summary>
19         public abstract bool IsSignificant 
20         { get; }
21
22         // <summary>
23         // Gets an object that we use as a key to key off this state instance
24         // </summary>
25         public abstract object Key 
26         { get; }
27
28         // <summary>
29         // Serializes this state into a string that can be persisted across app domains.
30         // If the content of this state is not significant enough to persist, null is returned.
31         // </summary>
32         // <returns>Serialization of this state object, or null if not significant enough.</returns>
33         public string Serialize() 
34         {
35             return IsSignificant ? SerializeCore() : null;
36         }
37
38         // <summary>
39         // Serializes this object into a string.
40         // </summary>
41         // <returns>String representation of this object.</returns>
42         protected abstract string SerializeCore();
43     }
44 }