// <summary> // Attempts to deserialize a string into a CategoryState object // </summary> // <param name="categoryStateString">String to deserialize</param> // <returns>Instance of CategoryState if the serialized string was valid, null otherwise.</returns> public static CategoryState Deserialize(string categoryStateString) { string[] args = categoryStateString.Split(','); if (args == null || args.Length != 3) { return(null); } bool?categoryExpanded = PersistedStateUtilities.DigitToBool(args[1]); bool?advancedSectionExpanded = PersistedStateUtilities.DigitToBool(args[2]); if (categoryExpanded == null || advancedSectionExpanded == null) { return(null); } string categoryName = PersistedStateUtilities.Unescape(args[0]); if (string.IsNullOrEmpty(categoryName)) { return(null); } CategoryState categoryState = new CategoryState(categoryName); categoryState.CategoryExpanded = (bool)categoryExpanded; categoryState.AdvancedSectionExpanded = (bool)advancedSectionExpanded; return(categoryState); }
// <summary> // Attempts to deserialize a string into a CategoryState object // </summary> // <param name="categoryStateString">String to deserialize</param> // <returns>Instance of CategoryState if the serialized string was valid, null otherwise.</returns> public static CategoryState Deserialize(string categoryStateString) { string[] args = categoryStateString.Split(','); if (args == null || args.Length != 3) { return null; } bool? categoryExpanded = PersistedStateUtilities.DigitToBool(args[1]); bool? advancedSectionExpanded = PersistedStateUtilities.DigitToBool(args[2]); if (categoryExpanded == null || advancedSectionExpanded == null) { return null; } string categoryName = PersistedStateUtilities.Unescape(args[0]); if (string.IsNullOrEmpty(categoryName)) { return null; } CategoryState categoryState = new CategoryState(categoryName); categoryState.CategoryExpanded = (bool)categoryExpanded; categoryState.AdvancedSectionExpanded = (bool)advancedSectionExpanded; return categoryState; }
// <summary> // Deserializes the specified string value into a state object // </summary> // <param name="serializedValue">Serialized value of the state object</param> // <returns>Deserialized instance of the state object</returns> protected override PersistedState DeserializeState(string serializedValue) { return(CategoryState.Deserialize(serializedValue)); }