Esempio n. 1
0
 public ConnectionManagementData(object parent)
 {
     data = new Hashtable(CaseInsensitiveHashCodeProvider.DefaultInvariant,
                          CaseInsensitiveComparer.DefaultInvariant);
     if (parent != null && parent is ConnectionManagementData)
     {
         ConnectionManagementData p = (ConnectionManagementData)parent;
         foreach (string k in p.data.Keys)
         {
             data [k] = p.data [k];
         }
     }
 }
		public virtual object Create (object parent, object configContext, XmlNode section)
		{
			ConnectionManagementData cmd = new ConnectionManagementData (parent);
#if (XML_DEP)			
			if (section.Attributes != null && section.Attributes.Count != 0)
				HandlersUtil.ThrowException ("Unrecognized attribute", section);

			XmlNodeList httpHandlers = section.ChildNodes;
			foreach (XmlNode child in httpHandlers) {
				XmlNodeType ntype = child.NodeType;
				if (ntype == XmlNodeType.Whitespace || ntype == XmlNodeType.Comment)
					continue;

				if (ntype != XmlNodeType.Element)
					HandlersUtil.ThrowException ("Only elements allowed", child);
				
				string name = child.Name;
				if (name == "clear") {
					if (child.Attributes != null && child.Attributes.Count != 0)
						HandlersUtil.ThrowException ("Unrecognized attribute", child);

					cmd.Clear ();
					continue;
				}

				//LAMESPEC: the MS doc says that <remove name="..."/> but they throw an exception
				// if you use that. "address" is correct.

				string address = HandlersUtil.ExtractAttributeValue ("address", child);
				if (name == "add") {
					string maxcnc = HandlersUtil.ExtractAttributeValue ("maxconnection", child, true);
					if (child.Attributes != null && child.Attributes.Count != 0)
						HandlersUtil.ThrowException ("Unrecognized attribute", child);

					cmd.Add (address, maxcnc);
					continue;
				}

				if (name == "remove") {
					if (child.Attributes != null && child.Attributes.Count != 0)
						HandlersUtil.ThrowException ("Unrecognized attribute", child);

					cmd.Remove (address);
					continue;
				}

				HandlersUtil.ThrowException ("Unexpected element", child);
			}
#endif			

			return cmd;
		}
Esempio n. 3
0
		static ServicePointManager ()
		{
#if !NET_2_1
#if CONFIGURATION_DEP
			object cfg = ConfigurationManager.GetSection (configKey);
			ConnectionManagementSection s = cfg as ConnectionManagementSection;
			if (s != null) {
				manager = new ConnectionManagementData (null);
				foreach (ConnectionManagementElement e in s.ConnectionManagement)
					manager.Add (e.Address, e.MaxConnection);

				defaultConnectionLimit = (int) manager.GetMaxConnections ("*");				
				return;
			}
#endif
			manager = (ConnectionManagementData) ConfigurationSettings.GetConfig (configKey);
			if (manager != null) {
				defaultConnectionLimit = (int) manager.GetMaxConnections ("*");				
			}
#endif
		}
Esempio n. 4
0
        public virtual object Create(object parent, object configContext, XmlNode section)
        {
            ConnectionManagementData cmd = new ConnectionManagementData(parent);

            if (section.Attributes != null && section.Attributes.Count != 0)
            {
                HandlersUtil.ThrowException("Unrecognized attribute", section);
            }

            XmlNodeList httpHandlers = section.ChildNodes;

            foreach (XmlNode child in httpHandlers)
            {
                XmlNodeType ntype = child.NodeType;
                if (ntype == XmlNodeType.Whitespace || ntype == XmlNodeType.Comment)
                {
                    continue;
                }

                if (ntype != XmlNodeType.Element)
                {
                    HandlersUtil.ThrowException("Only elements allowed", child);
                }

                string name = child.Name;
                if (name == "clear")
                {
                    if (child.Attributes != null && child.Attributes.Count != 0)
                    {
                        HandlersUtil.ThrowException("Unrecognized attribute", child);
                    }

                    cmd.Clear();
                    continue;
                }

                //LAMESPEC: the MS doc says that <remove name="..."/> but they throw an exception
                // if you use that. "address" is correct.

                string address = HandlersUtil.ExtractAttributeValue("address", child);
                if (name == "add")
                {
                    string maxcnc = HandlersUtil.ExtractAttributeValue("maxconnection", child, true);
                    if (child.Attributes != null && child.Attributes.Count != 0)
                    {
                        HandlersUtil.ThrowException("Unrecognized attribute", child);
                    }

                    cmd.Add(address, maxcnc);
                    continue;
                }

                if (name == "remove")
                {
                    if (child.Attributes != null && child.Attributes.Count != 0)
                    {
                        HandlersUtil.ThrowException("Unrecognized attribute", child);
                    }

                    cmd.Remove(address);
                    continue;
                }

                HandlersUtil.ThrowException("Unexpected element", child);
            }

            return(cmd);
        }