[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 / CategoryStateContainer.cs
1 //----------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation.  All rights reserved.
3 //----------------------------------------------------------------
4 namespace System.Activities.Presentation.Internal.PropertyEditing.State 
5 {
6     using System;
7     using System.Collections.Generic;
8     using System.Diagnostics;
9
10     // <summary>
11     // Simple wrapper around a dictionary of CategoryStates keyed by the category names.
12     // </summary>
13     internal class CategoryStateContainer : PersistedStateContainer 
14     {
15
16         // <summary>
17         // Gets the CategoryState for the specified category.  If one does not exist
18         // yet, it will be created automatically, guaranteeing a non-null return value.
19         // </summary>
20         // <param name="categoryName">Name of the requested category</param>
21         // <returns>A non-null instance of CategoryState</returns>
22         public CategoryState GetCategoryState(string categoryName) 
23         {
24             return (CategoryState)this.GetState(categoryName);
25         }
26
27         // <summary>
28         // Creates a default state object based on the specified key
29         // </summary>
30         // <param name="key">Key of the state object</param>
31         // <returns>Default state object</returns>
32         protected override PersistedState CreateDefaultState(object key) 
33         {
34             return new CategoryState(key as string);
35         }
36
37         // <summary>
38         // Deserializes the specified string value into a state object
39         // </summary>
40         // <param name="serializedValue">Serialized value of the state object</param>
41         // <returns>Deserialized instance of the state object</returns>
42         protected override PersistedState DeserializeState(string serializedValue) 
43         {
44             return CategoryState.Deserialize(serializedValue);
45         }
46     }
47 }