System.Diagnostics.DiagnosticsConfigurationHandler.Create C# (CSharp) Method

Create() public method

public Create ( object parent, object configContext, XmlNode section ) : object
parent object
configContext object
section System.Xml.XmlNode
return object
        public virtual object Create(object parent, object configContext, XmlNode section) {
            bool foundSwitches = false;
            bool foundAssert = false;
            bool foundTrace = false;
            bool foundCounters = false;

            HandlerBase.CheckForUnrecognizedAttributes(section);

            // Since the tracing and switch code lives in System.Dll and config is in System.Configuration.dll
            // the settings just go into a hashtable to communicate to the values to the diagnostics code in System.dll
            Hashtable parentConfig = (Hashtable)parent;
            Hashtable config;
            if (parentConfig == null)
                config = new Hashtable();
            else
                config = (Hashtable)parentConfig.Clone();

            foreach (XmlNode child in section.ChildNodes) {
                if (HandlerBase.IsIgnorableAlsoCheckForNonElement(child))
                    continue;

                switch (child.Name) {
                    case "switches":                        
                        if (foundSwitches)
                            throw new ConfigurationErrorsException(SR.GetString(SR.ConfigSectionsUnique, "switches"));
                        foundSwitches = true;
            
                        HandleSwitches(config, child, configContext);
                        break;
                    case "assert":
                        if (foundAssert)
                            throw new ConfigurationErrorsException(SR.GetString(SR.ConfigSectionsUnique, "assert"));
                        foundAssert = true;

                        HandleAssert(config, child, configContext);
                        break;
                    case "trace":
                        if (foundTrace)
                            throw new ConfigurationErrorsException(SR.GetString(SR.ConfigSectionsUnique, "trace"));
                        foundTrace = true;

                        HandleTrace(config, child, configContext);
                        break;
                    case "performanceCounters":                      
                        if (foundCounters)
                            throw new ConfigurationErrorsException(SR.GetString(SR.ConfigSectionsUnique, "performanceCounters"));
                        foundCounters = true;

                        HandleCounters((Hashtable)parent, config, child, configContext);                                                    
                        break;
                    default:
                        HandlerBase.ThrowUnrecognizedElement(child);
                        break;
                } // switch(child.Name)
                
                HandlerBase.CheckForUnrecognizedAttributes(child);
            }
            return config;
        }