Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Configuration / System / Configuration / ConfigurationSection.cs / 1305376 / ConfigurationSection.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Configuration { using System; using System.Collections.Specialized; using System.Configuration.Internal; using System.IO; using System.Reflection; using System.Security; using System.Text; using System.Xml; using System.Globalization; using System.Runtime.Versioning; public abstract class ConfigurationSection : ConfigurationElement { private SectionInformation _section; // Constructor // protected ConfigurationSection() { _section = new SectionInformation( this ); } // SectionInformation property // // Retrieve the class associated with the Section information // public SectionInformation SectionInformation { get { return _section; } } // GetRuntimeObject // // Return the Runtime Object for this Section // protected internal virtual object GetRuntimeObject() { return this; } protected internal override bool IsModified() { return ( SectionInformation.IsModifiedFlags() || base.IsModified() ); } protected internal override void ResetModified() { SectionInformation.ResetModifiedFlags(); base.ResetModified(); } protected internal virtual void DeserializeSection(XmlReader reader) { if (!reader.Read() || reader.NodeType != XmlNodeType.Element) { throw new ConfigurationErrorsException(SR.GetString(SR.Config_base_expected_to_find_element), reader); } DeserializeElement(reader, false); } protected internal virtual string SerializeSection(ConfigurationElement parentElement, string name, ConfigurationSaveMode saveMode) { if (CurrentConfiguration != null && CurrentConfiguration.TargetFramework != null && !ShouldSerializeSectionInTargetVersion(CurrentConfiguration.TargetFramework)) { return string.Empty; } ValidateElement(this, null, true); ConfigurationElement TempElement = CreateElement(this.GetType()); TempElement.Unmerge(this, parentElement, saveMode); StringWriter strWriter = new StringWriter(CultureInfo.InvariantCulture); XmlTextWriter writer = new XmlTextWriter(strWriter); writer.Formatting = Formatting.Indented; writer.Indentation = 4; writer.IndentChar = ' '; TempElement.DataToWriteInternal = (saveMode != ConfigurationSaveMode.Minimal); if (CurrentConfiguration != null && CurrentConfiguration.TargetFramework != null) _configRecord.SectionsStack.Push(this); TempElement.SerializeToXmlElement(writer, name); if (CurrentConfiguration != null && CurrentConfiguration.TargetFramework != null) _configRecord.SectionsStack.Pop(); writer.Flush(); return strWriter.ToString(); } protected internal virtual bool ShouldSerializePropertyInTargetVersion(ConfigurationProperty property, string propertyName, FrameworkName targetFramework, ConfigurationElement parentConfigurationElement) { return true; } protected internal virtual bool ShouldSerializeElementInTargetVersion(ConfigurationElement element, string elementName, FrameworkName targetFramework) { return true; } protected internal virtual bool ShouldSerializeSectionInTargetVersion(FrameworkName targetFramework) { return true; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Configuration { using System; using System.Collections.Specialized; using System.Configuration.Internal; using System.IO; using System.Reflection; using System.Security; using System.Text; using System.Xml; using System.Globalization; using System.Runtime.Versioning; public abstract class ConfigurationSection : ConfigurationElement { private SectionInformation _section; // Constructor // protected ConfigurationSection() { _section = new SectionInformation( this ); } // SectionInformation property // // Retrieve the class associated with the Section information // public SectionInformation SectionInformation { get { return _section; } } // GetRuntimeObject // // Return the Runtime Object for this Section // protected internal virtual object GetRuntimeObject() { return this; } protected internal override bool IsModified() { return ( SectionInformation.IsModifiedFlags() || base.IsModified() ); } protected internal override void ResetModified() { SectionInformation.ResetModifiedFlags(); base.ResetModified(); } protected internal virtual void DeserializeSection(XmlReader reader) { if (!reader.Read() || reader.NodeType != XmlNodeType.Element) { throw new ConfigurationErrorsException(SR.GetString(SR.Config_base_expected_to_find_element), reader); } DeserializeElement(reader, false); } protected internal virtual string SerializeSection(ConfigurationElement parentElement, string name, ConfigurationSaveMode saveMode) { if (CurrentConfiguration != null && CurrentConfiguration.TargetFramework != null && !ShouldSerializeSectionInTargetVersion(CurrentConfiguration.TargetFramework)) { return string.Empty; } ValidateElement(this, null, true); ConfigurationElement TempElement = CreateElement(this.GetType()); TempElement.Unmerge(this, parentElement, saveMode); StringWriter strWriter = new StringWriter(CultureInfo.InvariantCulture); XmlTextWriter writer = new XmlTextWriter(strWriter); writer.Formatting = Formatting.Indented; writer.Indentation = 4; writer.IndentChar = ' '; TempElement.DataToWriteInternal = (saveMode != ConfigurationSaveMode.Minimal); if (CurrentConfiguration != null && CurrentConfiguration.TargetFramework != null) _configRecord.SectionsStack.Push(this); TempElement.SerializeToXmlElement(writer, name); if (CurrentConfiguration != null && CurrentConfiguration.TargetFramework != null) _configRecord.SectionsStack.Pop(); writer.Flush(); return strWriter.ToString(); } protected internal virtual bool ShouldSerializePropertyInTargetVersion(ConfigurationProperty property, string propertyName, FrameworkName targetFramework, ConfigurationElement parentConfigurationElement) { return true; } protected internal virtual bool ShouldSerializeElementInTargetVersion(ConfigurationElement element, string elementName, FrameworkName targetFramework) { return true; } protected internal virtual bool ShouldSerializeSectionInTargetVersion(FrameworkName targetFramework) { return true; } } } // 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
- Constants.cs
- ControlAdapter.cs
- GlobalizationAssembly.cs
- LinkDescriptor.cs
- RecipientInfo.cs
- SHA256Managed.cs
- WebControlsSection.cs
- StoryFragments.cs
- SynchronizedRandom.cs
- FixedSOMSemanticBox.cs
- RuleProcessor.cs
- RegexCapture.cs
- Array.cs
- XmlILStorageConverter.cs
- COM2DataTypeToManagedDataTypeConverter.cs
- TypeConverterAttribute.cs
- VersionedStreamOwner.cs
- PointF.cs
- RealProxy.cs
- SmiRequestExecutor.cs
- PassportAuthentication.cs
- StaticDataManager.cs
- ControlAdapter.cs
- PropertyConverter.cs
- SelectingProviderEventArgs.cs
- ObjectCacheHost.cs
- CultureTableRecord.cs
- UnsafeNativeMethods.cs
- DataGridItem.cs
- OleDbError.cs
- _ConnectStream.cs
- InputMethodStateTypeInfo.cs
- CharEnumerator.cs
- FileSystemEnumerable.cs
- oledbconnectionstring.cs
- Lasso.cs
- RelationshipSet.cs
- WorkflowExecutor.cs
- Bezier.cs
- DBSqlParser.cs
- DesignerActionPropertyItem.cs
- IntMinMaxAggregationOperator.cs
- SqlBooleanizer.cs
- MultiPageTextView.cs
- UInt32.cs
- RTLAwareMessageBox.cs
- XPathNodeHelper.cs
- ReadOnlyDataSourceView.cs
- _NegotiateClient.cs
- FilterEventArgs.cs
- EnumMemberAttribute.cs
- InfoCardCryptoHelper.cs
- WebExceptionStatus.cs
- ExpressionDumper.cs
- TextServicesLoader.cs
- PageHandlerFactory.cs
- StylusPointPropertyInfo.cs
- FontUnit.cs
- PartialArray.cs
- MessageSmuggler.cs
- ZipIOCentralDirectoryBlock.cs
- BindableAttribute.cs
- DetailsViewModeEventArgs.cs
- PeoplePickerWrapper.cs
- Set.cs
- PersonalizationStateInfo.cs
- storagemappingitemcollection.viewdictionary.cs
- DesignerGenericWebPart.cs
- MessageSecurityOverMsmq.cs
- ExpressionNode.cs
- IntSecurity.cs
- TextPenaltyModule.cs
- ColorTransformHelper.cs
- DataServiceRequestArgs.cs
- ListViewItem.cs
- _Events.cs
- SHA512Managed.cs
- TrackBarRenderer.cs
- Blend.cs
- SqlUdtInfo.cs
- QuaternionAnimation.cs
- CodeTypeReferenceSerializer.cs
- CutCopyPasteHelper.cs
- PhysicalAddress.cs
- CollectionViewGroupRoot.cs
- CustomErrorsSectionWrapper.cs
- CheckPair.cs
- Vector3DCollectionValueSerializer.cs
- Tag.cs
- OrCondition.cs
- HtmlInputCheckBox.cs
- RequestDescription.cs
- DetailsViewPageEventArgs.cs
- TextTreeRootNode.cs
- CopyOnWriteList.cs
- XamlInt32CollectionSerializer.cs
- TagPrefixAttribute.cs
- WizardForm.cs
- TypeConverter.cs
- PageMediaSize.cs