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

  1. //------------------------------------------------------------------------------
  2. // <copyright file="SingleTagSectionHandler.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.Collections;
  18.     using System.Xml;
  19.    
  20. /**
  21.     * Single-tag dictionary config factory
  22.     *
  23.     * Use for tags of the form: <MySingleTag key1="value1" ... keyN="valueN"/>
  24.     */   
  25.     /// <devdoc>
  26.     /// </devdoc>
  27.     public class SingleTagSectionHandler : IConfigurationSectionHandler
  28.     {
  29. /**
  30.         * Create
  31.         *
  32.         * Given a partially composed config object (possibly null)
  33.         * and some input from the config system, return a
  34.         * further partially composed config object
  35.         */       
  36.         /// <devdoc>
  37.         /// <para>[To be supplied.]</para>
  38.         /// </devdoc>
  39.         public virtual object Create(object parent, object context, XmlNode section)
  40.         {
  41.             Hashtable result;
  42.            
  43.             // start result off as a shallow clone of the parent
  44.            
  45.             if (parent == null)
  46.                 result = new Hashtable();
  47.             else
  48.                 result = new Hashtable((IDictionary)parent);
  49.            
  50.             // verify that there are no children
  51.            
  52.             HandlerBase.CheckForChildNodes(section);
  53.            
  54.             // iterate through each XML section in order and apply the directives
  55.            
  56.             foreach (XmlAttribute attribute in section.Attributes) {
  57.                 // handle name-value pairs
  58.                 result[attribute.Name] = attribute.Value;
  59.             }
  60.            
  61.             return result;
  62.         }
  63.     }
  64. }

Developer Fusion