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
- DrawListViewColumnHeaderEventArgs.cs
- XmlSchema.cs
- SamlAttribute.cs
- FormatException.cs
- GlyphCache.cs
- VScrollProperties.cs
- DateTimeUtil.cs
- ListBase.cs
- FunctionQuery.cs
- ModuleBuilder.cs
- PatternMatchRules.cs
- RangeContentEnumerator.cs
- SelectionRangeConverter.cs
- ProxyGenerator.cs
- BamlResourceSerializer.cs
- IgnoreFlushAndCloseStream.cs
- ToolStripItemDataObject.cs
- _HTTPDateParse.cs
- SqlTypeSystemProvider.cs
- RelationshipType.cs
- ToolStripItemImageRenderEventArgs.cs
- DataGridViewLinkCell.cs
- ToolStripScrollButton.cs
- DataGridHelper.cs
- QuaternionRotation3D.cs
- DesignOnlyAttribute.cs
- EntityViewContainer.cs
- ToolTipAutomationPeer.cs
- ArcSegment.cs
- LinkedResourceCollection.cs
- ExpressionCopier.cs
- ResolveNameEventArgs.cs
- OLEDB_Util.cs
- QuaternionConverter.cs
- DateTimeFormat.cs
- SafeSecurityHelper.cs
- validationstate.cs
- WebServiceTypeData.cs
- RawTextInputReport.cs
- XmlCountingReader.cs
- FormClosingEvent.cs
- RecordManager.cs
- ScrollChrome.cs
- ImageMapEventArgs.cs
- HScrollBar.cs
- X509Extension.cs
- ConnectionConsumerAttribute.cs
- WindowsSpinner.cs
- DispatchOperation.cs
- ChildDocumentBlock.cs
- httpserverutility.cs
- DataStreamFromComStream.cs
- DesignerTransactionCloseEvent.cs
- SchemaNames.cs
- BinaryMethodMessage.cs
- ExpressionParser.cs
- InkCanvasAutomationPeer.cs
- FrameworkElementAutomationPeer.cs
- SRef.cs
- QilName.cs
- CommandConverter.cs
- WindowsProgressbar.cs
- ContentElement.cs
- CachedTypeface.cs
- ColumnClickEvent.cs
- UnrecognizedAssertionsBindingElement.cs
- EntryWrittenEventArgs.cs
- ModelEditingScope.cs
- HttpCacheParams.cs
- UserInitiatedRoutedEventPermissionAttribute.cs
- SpotLight.cs
- CustomWebEventKey.cs
- DataGridCellEditEndingEventArgs.cs
- DbProviderFactory.cs
- ReachSerializationCacheItems.cs
- MemberDomainMap.cs
- SamlAttributeStatement.cs
- XmlSchemas.cs
- SafeSecurityHandles.cs
- SharedPerformanceCounter.cs
- HtmlElementErrorEventArgs.cs
- MergablePropertyAttribute.cs
- ParserExtension.cs
- CredentialCache.cs
- AbstractSvcMapFileLoader.cs
- BitmapEffectDrawingContextState.cs
- DataGridViewLinkColumn.cs
- ConsoleTraceListener.cs
- OrderedDictionary.cs
- XmlSchemaInfo.cs
- CheckBox.cs
- ContainerParaClient.cs
- SAPICategories.cs
- RemotingConfiguration.cs
- HtmlTernaryTree.cs
- FindCriteriaCD1.cs
- CacheDependency.cs
- CatalogPart.cs
- RequestChannelBinder.cs
- DataGridPagingPage.cs