The Labs \ Source Viewer \ SSCLI \ System.Configuration \ IgnoreSection

  1. //------------------------------------------------------------------------------
  2. // <copyright file="IgnoreSection.cs" company="Microsoft">
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. // </copyright>
  14. //------------------------------------------------------------------------------
  15. namespace System.Configuration
  16. {
  17.     using System.Xml;
  18.    
  19.     public sealed class IgnoreSection : ConfigurationSection
  20.     {
  21.         private static ConfigurationPropertyCollection s_properties;
  22.        
  23.         string _rawXml = string.Empty;
  24.         bool _isModified;
  25.        
  26.         private static ConfigurationPropertyCollection EnsureStaticPropertyBag()
  27.         {
  28.             if (s_properties == null) {
  29.                 ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
  30.                 s_properties = properties;
  31.             }
  32.            
  33.             return s_properties;
  34.         }
  35.        
  36.         public IgnoreSection()
  37.         {
  38.             EnsureStaticPropertyBag();
  39.         }
  40.        
  41.         protected internal override ConfigurationPropertyCollection Properties {
  42.             get { return EnsureStaticPropertyBag(); }
  43.         }
  44.        
  45.         protected internal override bool IsModified()
  46.         {
  47.             return _isModified;
  48.         }
  49.        
  50.         protected internal override void ResetModified()
  51.         {
  52.             _isModified = false;
  53.         }
  54.        
  55.         protected internal override void Reset(ConfigurationElement parentSection)
  56.         {
  57.             _rawXml = string.Empty;
  58.             _isModified = false;
  59.         }
  60.        
  61.         protected internal override void DeserializeSection(XmlReader xmlReader)
  62.         {
  63.             if (!xmlReader.Read() || xmlReader.NodeType != XmlNodeType.Element) {
  64.                 throw new ConfigurationErrorsException(SR.GetString(SR.Config_base_expected_to_find_element), xmlReader);
  65.             }
  66.             _rawXml = xmlReader.ReadOuterXml();
  67.             _isModified = true;
  68.         }
  69.        
  70.         protected internal override string SerializeSection(ConfigurationElement parentSection, string name, ConfigurationSaveMode saveMode)
  71.         {
  72.             return _rawXml;
  73.         }
  74.     }
  75. }

Developer Fusion