1 //----------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 //----------------------------------------------------------------
4 namespace System.Activities.Presentation.Internal.PropertyEditing
7 using System.Collections.Generic;
8 using System.Diagnostics;
11 using System.Activities.Presentation.Internal.PropertyEditing.State;
14 // Simple wrapper around a dictionary of PropertyStates keyed by the property names.
16 internal class PropertyStateContainer : PersistedStateContainer
19 private static PropertyStateContainer _instance;
21 // The ctor is private because we use this class as a singleton
22 private PropertyStateContainer()
27 // Gets a static instance of this class
29 public static PropertyStateContainer Instance
32 if (_instance == null)
34 _instance = new PropertyStateContainer();
42 // Gets the PropertyState for the specified category. If one does not exist
43 // yet, it will be created automatically, guaranteeing a non-null return value.
45 // <param name="propertyName">Name of the property itself</param>
46 // <returns>A non-null instance of PropertyState</returns>
47 public PropertyState GetPropertyState(string propertyName)
49 return (PropertyState)this.GetState(propertyName);
53 // Creates a default state object based on the specified key
55 // <param name="key">Key of the state object</param>
56 // <returns>Default state object</returns>
57 protected override PersistedState CreateDefaultState(object key)
59 return new PropertyState(key as string);
63 // Deserializes the specified string value into a state object
65 // <param name="serializedValue">Serialized value of the state object</param>
66 // <returns>Deserialized instance of the state object</returns>
67 protected override PersistedState DeserializeState(string serializedValue)
69 return PropertyState.Deserialize(serializedValue);