public virtual object Create(Object parent, object configContextObj, XmlNode section)
        {
            // if called through client config don't even load HttpRuntime
            if (!HandlerBase.IsServerConfiguration(configContextObj))
            {
                return(null);
            }

            bool   bTemp                    = false;
            int    iTemp                    = 0;
            uint   uiTemp                   = 0;
            string sTemp                    = null;
            int    maxWorkerThreads         = 0;
            int    maxIoThreads             = 0;
            int    minWorkerThreads         = 0;
            int    minIoThreads             = 0;
            int    responseDeadlockInterval = 0;

            HandlerBase.GetAndRemoveBooleanAttribute(section, "enable", ref bTemp);
            GetAndRemoveProcessModelTimeout(section, "timeout", ref iTemp);
            GetAndRemoveProcessModelTimeout(section, "idleTimeout", ref iTemp);
            GetAndRemoveProcessModelTimeout(section, "shutdownTimeout", ref iTemp);
            GetAndRemoveIntegerOrInfiniteAttribute(section, "requestLimit", ref iTemp);
            GetAndRemoveIntegerOrInfiniteAttribute(section, "requestQueueLimit", ref iTemp);
            GetAndRemoveIntegerOrInfiniteAttribute(section, "restartQueueLimit", ref iTemp);
            HandlerBase.GetAndRemoveIntegerAttribute(section, "memoryLimit", ref iTemp);
            GetAndRemoveUnsignedIntegerAttribute(section, "cpuMask", ref uiTemp);
            HandlerBase.GetAndRemoveEnumAttribute(section, "logLevel", typeof(LogLevelEnum), ref iTemp);
            HandlerBase.GetAndRemoveStringAttribute(section, "userName", ref sTemp);
            HandlerBase.GetAndRemoveStringAttribute(section, "password", ref sTemp);
            HandlerBase.GetAndRemoveBooleanAttribute(section, "webGarden", ref bTemp);
            GetAndRemoveProcessModelTimeout(section, "clientConnectedCheck", ref iTemp);
            HandlerBase.GetAndRemoveStringAttribute(section, "comImpersonationLevel", ref sTemp);
            HandlerBase.GetAndRemoveStringAttribute(section, "comAuthenticationLevel", ref sTemp);
            GetAndRemoveProcessModelTimeout(section, "responseDeadlockInterval", ref responseDeadlockInterval);
            GetAndRemoveProcessModelTimeout(section, "responseRestartDeadlockInterval", ref iTemp);
            HandlerBase.GetAndRemovePositiveIntegerAttribute(section, "maxWorkerThreads", ref maxWorkerThreads);
            HandlerBase.GetAndRemovePositiveIntegerAttribute(section, "maxIoThreads", ref maxIoThreads);
            HandlerBase.GetAndRemovePositiveIntegerAttribute(section, "minWorkerThreads", ref minWorkerThreads);
            HandlerBase.GetAndRemovePositiveIntegerAttribute(section, "minIoThreads", ref minIoThreads);
            HandlerBase.GetAndRemoveStringAttribute(section, "serverErrorMessageFile", ref sTemp);
            GetAndRemoveIntegerOrInfiniteAttribute(section, "requestAcks", ref iTemp);
            GetAndRemoveProcessModelTimeout(section, "pingFrequency", ref iTemp);
            GetAndRemoveProcessModelTimeout(section, "pingTimeout", ref iTemp);
            GetAndRemoveIntegerOrInfiniteAttribute(section, "asyncOption", ref iTemp);


            HandlerBase.CheckForUnrecognizedAttributes(section);
            HandlerBase.CheckForChildNodes(section);

            return(new ProcessModelConfig(maxWorkerThreads, maxIoThreads, minWorkerThreads, minIoThreads, responseDeadlockInterval));
        }
Example #2
0
        /*
         * Create
         *
         * Given a partially composed config object (possibly null)
         * and some input from the config system, return a
         * further partially composed config object
         */
        internal Object InternalCreate(Object parent, XmlNode node)
        {
            HandlerMap map;

            // start list as shallow clone of parent

            if (parent == null)
            {
                map = new HandlerMap();
            }
            else
            {
                map = new HandlerMap((HandlerMap)parent);
            }

            map.BeginGroup();

            // process XML section
            HandlerBase.CheckForUnrecognizedAttributes(node);

            foreach (XmlNode child in node.ChildNodes)
            {
                // skip whitespace and comments

                if (HandlerBase.IsIgnorableAlsoCheckForNonElement(child))
                {
                    continue;
                }

                // process <add> and <clear> elements

                if (child.Name.Equals("add"))
                {
                    String verb      = HandlerBase.RemoveRequiredAttribute(child, "verb");
                    String path      = HandlerBase.RemoveRequiredAttribute(child, "path");
                    String classname = HandlerBase.RemoveRequiredAttribute(child, "type");

                    int     phase     = 1;
                    XmlNode phaseNode = HandlerBase.GetAndRemoveIntegerAttribute(child, "phase", ref phase);
                    if (phaseNode != null)
                    {
                        ValidatePhase(phase, phaseNode);
                    }

                    bool validate = true;
                    HandlerBase.GetAndRemoveBooleanAttribute(child, "validate", ref validate);


                    HandlerBase.CheckForUnrecognizedAttributes(child);
                    HandlerBase.CheckForChildNodes(child);

                    try {
                        map.Add(new HandlerMapping(verb, path, classname, !validate), phase);
                    }
                    catch (Exception e) {
                        throw new ConfigurationException(e.Message, e, child);
                    }
                }
                else if (child.Name.Equals("remove"))
                {
                    String verb     = HandlerBase.RemoveRequiredAttribute(child, "verb");
                    String path     = HandlerBase.RemoveRequiredAttribute(child, "path");
                    bool   validate = true;
                    HandlerBase.GetAndRemoveBooleanAttribute(child, "validate", ref validate);


                    HandlerBase.CheckForUnrecognizedAttributes(child);
                    HandlerBase.CheckForChildNodes(child);

                    if (!map.RemoveMapping(verb, path) && validate)
                    {
                        throw new ConfigurationException(
                                  HttpRuntime.FormatResourceString(SR.No_mapping_to_remove, verb, path),
                                  child);
                    }
                }
                else if (child.Name.Equals("clear"))
                {
                    int     phase     = 1;
                    XmlNode phaseNode = HandlerBase.GetAndRemoveIntegerAttribute(child, "phase", ref phase);
                    HandlerBase.CheckForUnrecognizedAttributes(child);
                    HandlerBase.CheckForChildNodes(child);

                    if (phaseNode == null)
                    {
                        map.ClearAll();
                    }
                    else
                    {
                        ValidatePhase(phase, phaseNode);
                        map.ClearPhase(phase);
                    }
                }
                else
                {
                    HandlerBase.ThrowUnrecognizedElement(child);
                }
            }

            map.EndGroup();

            return(map);
        }