2 // System.Net.Configuration.NetConfigurationHandler.cs
5 // Jerome Laban (jlaban@wanadoo.fr)
6 // Gonzalo Paniagua Javier (gonzalo@ximian.com)
8 // (C) 2003 Ximian, Inc (http://www.ximian.com)
9 // (c) 2004 Novell, Inc. (http://www.novell.com)
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 using System.Collections;
34 using System.Configuration;
38 using XmlNode = System.Object;
41 namespace System.Net.Configuration
43 class NetConfigurationHandler : IConfigurationSectionHandler
45 public virtual object Create (object parent, object configContext, XmlNode section)
47 NetConfig config = new NetConfig ();
49 if (section.Attributes != null && section.Attributes.Count != 0)
50 HandlersUtil.ThrowException ("Unrecognized attribute", section);
52 XmlNodeList reqHandlers = section.ChildNodes;
53 foreach (XmlNode child in reqHandlers) {
54 XmlNodeType ntype = child.NodeType;
55 if (ntype == XmlNodeType.Whitespace || ntype == XmlNodeType.Comment)
58 if (ntype != XmlNodeType.Element)
59 HandlersUtil.ThrowException ("Only elements allowed", child);
61 string name = child.Name;
63 string enabled = HandlersUtil.ExtractAttributeValue ("enabled", child, false);
64 if (child.Attributes != null && child.Attributes.Count != 0)
65 HandlersUtil.ThrowException ("Unrecognized attribute", child);
67 if (enabled == "true")
68 config.ipv6Enabled = true;
69 else if (enabled != "false")
70 HandlersUtil.ThrowException ("Invalid boolean value", child);
75 if (name == "httpWebRequest") {
76 string max = HandlersUtil.ExtractAttributeValue
77 ("maximumResponseHeadersLength", child, true);
79 // this one is just ignored
80 HandlersUtil.ExtractAttributeValue ("useUnsafeHeaderParsing", child, true);
82 if (child.Attributes != null && child.Attributes.Count != 0)
83 HandlersUtil.ThrowException ("Unrecognized attribute", child);
87 int val = Int32.Parse (max.Trim ());
89 HandlersUtil.ThrowException ("Must be -1 or >= 0", child);
91 config.MaxResponseHeadersLength = val;
94 HandlersUtil.ThrowException ("Invalid int value", child);
100 HandlersUtil.ThrowException ("Unexpected element", child);