internal ProtocolsConfiguration(XmlNode section)
        {
            // process XML section in order and apply the directives

            HandlerBase.CheckForUnrecognizedAttributes(section);

            foreach (XmlNode child in section.ChildNodes)
            {
                // skip whitespace and comments
                if (IsIgnorableAlsoCheckForNonElement(child))
                {
                    continue;
                }

                // process <add> elements

                if (child.Name == "add")
                {
                    String id     = HandlerBase.RemoveRequiredAttribute(child, "id");
                    String phType = HandlerBase.RemoveRequiredAttribute(child, "processHandlerType");
                    String ahType = HandlerBase.RemoveRequiredAttribute(child, "appDomainHandlerType");

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

                    HandlerBase.CheckForUnrecognizedAttributes(child);
                    HandlerBase.CheckForNonCommentChildNodes(child);

                    // check duplicate Id

                    /* TEMPORARY allow duplicates for easy Indigo machine.config update
                     * if (_protocolEntries[id] != null) {
                     *  throw new ConfigurationErrorsException(
                     *                  SR.GetString(SR.Dup_protocol_id, id),
                     *                  child);
                     * }
                     */

                    // add entry

                    /* TEMPORARY hide errors and ignore bad <add> tags
                     * to let breaking changes through */
                    try {
                        _protocolEntries[id] = new ProtocolsConfigurationEntry(
                            id, phType, ahType, validate,
                            ConfigurationErrorsException.GetFilename(child),
                            ConfigurationErrorsException.GetLineNumber(child));
                    }
                    catch {
                    }
                }
                else
                {
                    HandlerBase.ThrowUnrecognizedElement(child);
                }
            }
        }
Beispiel #2
0
        //
        // Handle <file src=""/> elements
        //
        static void ProcessFile(ArrayList fileList, XmlNode node)
        {
            string  filename = null;
            XmlNode attr     = HandlerBase.GetAndRemoveRequiredStringAttribute(node, "src", ref filename);

            HandlerBase.CheckForUnrecognizedAttributes(node);
            HandlerBase.CheckForNonCommentChildNodes(node);

            fileList.Add(new Pair(filename, attr));
        }
Beispiel #3
0
        //
        // Handle the <result> tag
        //
        static void ProcessResult(HttpCapabilitiesDefaultProvider capabilitiesEvaluator, XmlNode node)
        {
            bool inherit = true;

            HandlerBase.GetAndRemoveBooleanAttribute(node, "inherit", ref inherit);
            if (inherit == false)
            {
                capabilitiesEvaluator.ClearParent();
            }

            Type    resultType = null;
            XmlNode attribute  = HandlerBase.GetAndRemoveTypeAttribute(node, "type", ref resultType);

            if (attribute != null)
            {
                if (resultType.Equals(capabilitiesEvaluator._resultType) == false)
                {
                    // be sure the new type is assignable to the parent type
                    HandlerBase.CheckAssignableType(attribute, capabilitiesEvaluator._resultType, resultType);
                    capabilitiesEvaluator._resultType = resultType;
                }
            }

            int cacheTime = 0;

            attribute = HandlerBase.GetAndRemovePositiveIntegerAttribute(node, "cacheTime", ref cacheTime);
            //NOTE: we continue to parse the cacheTime for backwards compat
            // it has never been used.  Customer scenarios don't require this support.
            if (attribute != null)
            {
                capabilitiesEvaluator.CacheTime = TimeSpan.FromSeconds(cacheTime);
            }

            HandlerBase.CheckForUnrecognizedAttributes(node);
            HandlerBase.CheckForNonCommentChildNodes(node);
        }
Beispiel #4
0
        //
        // Create a rule from an element
        //
        static CapabilitiesRule RuleFromElement(ParseState parseState, XmlNode element)
        {
            int                 ruletype;
            DelayedRegex        regex;
            CapabilitiesPattern pat;

            // grab tag name

            if (element.Name == "filter")
            {
                ruletype = CapabilitiesRule.Filter;
            }
            else if (element.Name == "case")
            {
                ruletype = CapabilitiesRule.Case;
            }
            else if (element.Name == "use")
            {
                HandlerBase.CheckForNonCommentChildNodes(element);

                string var   = HandlerBase.RemoveRequiredAttribute(element, "var");
                string strAs = HandlerBase.RemoveAttribute(element, "as");
                HandlerBase.CheckForUnrecognizedAttributes(element);

                if (strAs == null)
                {
                    strAs = String.Empty;
                }

                parseState.Evaluator.AddDependency(var);

                return(new CapabilitiesUse(var, strAs));
            }
            else
            {
                throw new ConfigurationErrorsException(
                          SR.GetString(SR.Unknown_tag_in_caps_config, element.Name),
                          element);
            }

            // grab attributes
            String matchpat = HandlerBase.RemoveAttribute(element, "match");
            String testpat  = HandlerBase.RemoveAttribute(element, "with");

            HandlerBase.CheckForUnrecognizedAttributes(element);

            if (matchpat == null)
            {
                if (testpat != null)
                {
                    throw new ConfigurationErrorsException(SR.GetString(SR.Cannot_specify_test_without_match), element);
                }
                regex = null;
                pat   = null;
            }
            else
            {
                try {
                    regex = new DelayedRegex(matchpat);
                }
                catch (Exception e) {
                    throw new ConfigurationErrorsException(e.Message, e, element);
                }

                if (testpat == null)
                {
                    pat = CapabilitiesPattern.Default;
                }
                else
                {
                    pat = new CapabilitiesPattern(testpat);
                }
            }

            // grab contents
            ArrayList subrules = RuleListFromElement(parseState, element, false);

            return(new CapabilitiesSection(ruletype, regex, pat, subrules));
        }