Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / Tools / System.Activities.Presentation / System / Activities / Presentation / Base / Core / Internal / PropertyEditing / State / PropertyState.cs / 1305376 / PropertyState.cs
//---------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------- namespace System.Activities.Presentation.Internal.PropertyEditing.State { using System; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Runtime; //// Simple state object that knows how to remember state for a single property. // The only thing it currently remembers is whether the property's sub-properties // are expanded or collapsed. // internal class PropertyState : PersistedState { private const bool DefaultSubPropertiesExpanded = false; private string _propertyName; private bool _subPropertiesExpanded = DefaultSubPropertiesExpanded; //// Basic ctor // // Property to wrap around [SuppressMessage("Microsoft.Performance", "CA1805:DoNotInitializeUnnecessarily")] public PropertyState(string propertyName) { Fx.Assert(!string.IsNullOrEmpty(propertyName), "Expected a full property name"); _propertyName = propertyName; } //// We key these state objects by their property names // public override object Key { get { return _propertyName; } } //// Returns true if any of the contained values differ from the default // public override bool IsSignificant { get { return _subPropertiesExpanded != DefaultSubPropertiesExpanded; } } //// Gets or sets a flag indicating whether the sub-properties of the contained // property have been expanded or collapsed. // public bool SubPropertiesExpanded { get { return _subPropertiesExpanded; } set { _subPropertiesExpanded = value; } } //// Serializes this object into a simple string (AppDomains like strings). // // Format: PropertyName,SubPropertiesExpanded;NextPropertyName,SubPropertiesExpanded;... // Where bools are recorded as 0 = false and 1 = true // //Serialized version of this state object (may be null) protected override string SerializeCore() { return string.Concat( PersistedStateUtilities.Escape(_propertyName), ',', PersistedStateUtilities.BoolToDigit(_subPropertiesExpanded)); } //// Attempts to deserialize a string into a PropertyState object // // String to deserialize //Instance of PropertyState if the serialized string was valid, null otherwise. public static PropertyState Deserialize(string propertyStateString) { string[] args = propertyStateString.Split(','); if (args == null || args.Length != 2) { return null; } bool? subPropertiesExpanded = PersistedStateUtilities.DigitToBool(args[1]); if (subPropertiesExpanded == null) { return null; } string propertyName = PersistedStateUtilities.Unescape(args[0]); if (string.IsNullOrEmpty(propertyName)) { return null; } PropertyState propertyState = new PropertyState(propertyName); propertyState.SubPropertiesExpanded = (bool)subPropertiesExpanded; return propertyState; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------- namespace System.Activities.Presentation.Internal.PropertyEditing.State { using System; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Runtime; //// Simple state object that knows how to remember state for a single property. // The only thing it currently remembers is whether the property's sub-properties // are expanded or collapsed. // internal class PropertyState : PersistedState { private const bool DefaultSubPropertiesExpanded = false; private string _propertyName; private bool _subPropertiesExpanded = DefaultSubPropertiesExpanded; //// Basic ctor // // Property to wrap around [SuppressMessage("Microsoft.Performance", "CA1805:DoNotInitializeUnnecessarily")] public PropertyState(string propertyName) { Fx.Assert(!string.IsNullOrEmpty(propertyName), "Expected a full property name"); _propertyName = propertyName; } //// We key these state objects by their property names // public override object Key { get { return _propertyName; } } //// Returns true if any of the contained values differ from the default // public override bool IsSignificant { get { return _subPropertiesExpanded != DefaultSubPropertiesExpanded; } } //// Gets or sets a flag indicating whether the sub-properties of the contained // property have been expanded or collapsed. // public bool SubPropertiesExpanded { get { return _subPropertiesExpanded; } set { _subPropertiesExpanded = value; } } //// Serializes this object into a simple string (AppDomains like strings). // // Format: PropertyName,SubPropertiesExpanded;NextPropertyName,SubPropertiesExpanded;... // Where bools are recorded as 0 = false and 1 = true // //Serialized version of this state object (may be null) protected override string SerializeCore() { return string.Concat( PersistedStateUtilities.Escape(_propertyName), ',', PersistedStateUtilities.BoolToDigit(_subPropertiesExpanded)); } //// Attempts to deserialize a string into a PropertyState object // // String to deserialize //Instance of PropertyState if the serialized string was valid, null otherwise. public static PropertyState Deserialize(string propertyStateString) { string[] args = propertyStateString.Split(','); if (args == null || args.Length != 2) { return null; } bool? subPropertiesExpanded = PersistedStateUtilities.DigitToBool(args[1]); if (subPropertiesExpanded == null) { return null; } string propertyName = PersistedStateUtilities.Unescape(args[0]); if (string.IsNullOrEmpty(propertyName)) { return null; } PropertyState propertyState = new PropertyState(propertyName); propertyState.SubPropertiesExpanded = (bool)subPropertiesExpanded; return propertyState; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- EncodingDataItem.cs
- IUnknownConstantAttribute.cs
- SyndicationSerializer.cs
- WsatServiceCertificate.cs
- WebPartConnectionCollection.cs
- IdentifierElement.cs
- ObjectSelectorEditor.cs
- XmlMtomReader.cs
- WindowsScroll.cs
- SimpleWorkerRequest.cs
- OleDbTransaction.cs
- TemplateKeyConverter.cs
- MultiPropertyDescriptorGridEntry.cs
- XmlWellformedWriter.cs
- DataColumn.cs
- SoapObjectWriter.cs
- DataGridRelationshipRow.cs
- NativeActivityFaultContext.cs
- HatchBrush.cs
- CellPartitioner.cs
- CodeGenerator.cs
- HtmlTableRowCollection.cs
- TemplateLookupAction.cs
- OleDbInfoMessageEvent.cs
- TextEditorParagraphs.cs
- SelectedDatesCollection.cs
- UnsafeNativeMethods.cs
- ChannelPoolSettingsElement.cs
- FlowDocumentReader.cs
- ServiceModelEnumValidatorAttribute.cs
- LineBreak.cs
- MenuRenderer.cs
- CodeCommentStatementCollection.cs
- MenuItemStyle.cs
- TemplateEditingVerb.cs
- PowerModeChangedEventArgs.cs
- TemplateBamlRecordReader.cs
- WinFormsComponentEditor.cs
- RuntimeConfigLKG.cs
- Metafile.cs
- OneOfTypeConst.cs
- MetafileHeaderWmf.cs
- ClientConfigurationSystem.cs
- ColorTransform.cs
- SecurityRuntime.cs
- ControlCollection.cs
- DBCommand.cs
- StructuralCache.cs
- PrinterUnitConvert.cs
- Int64Converter.cs
- SqlRewriteScalarSubqueries.cs
- TaiwanLunisolarCalendar.cs
- TreeNode.cs
- SudsParser.cs
- ChannelReliableSession.cs
- Latin1Encoding.cs
- SimpleTypeResolver.cs
- Visitor.cs
- ComponentManagerBroker.cs
- _NtlmClient.cs
- DataBindingsDialog.cs
- CodeAccessSecurityEngine.cs
- GroupBox.cs
- XmlSerializationGeneratedCode.cs
- GeometryDrawing.cs
- TypeUnloadedException.cs
- TimersDescriptionAttribute.cs
- ConfigXmlComment.cs
- MultiByteCodec.cs
- SqlVersion.cs
- InstanceCreationEditor.cs
- WebPartConnectionsCancelEventArgs.cs
- CryptoStream.cs
- ColorConverter.cs
- GridViewRowPresenterBase.cs
- SafeSecurityHandles.cs
- PropertyReferenceSerializer.cs
- WorkflowOperationErrorHandler.cs
- PointValueSerializer.cs
- Rect3D.cs
- UIElement3DAutomationPeer.cs
- SocketManager.cs
- PathData.cs
- CaseInsensitiveOrdinalStringComparer.cs
- VariableQuery.cs
- SupportsEventValidationAttribute.cs
- UriSection.cs
- DescriptionAttribute.cs
- ParentQuery.cs
- IsolatedStorage.cs
- SystemFonts.cs
- FreeFormDesigner.cs
- DictionaryManager.cs
- XmlUtf8RawTextWriter.cs
- ISessionStateStore.cs
- PostBackOptions.cs
- FixUpCollection.cs
- CopyNodeSetAction.cs
- WebPartVerbsEventArgs.cs
- UnauthorizedWebPart.cs