Exemplo n.º 1
0
        /// <summary> Private method for parsing the &lt;tag-rules&gt; from the XML file.</summary>
        /// <param name="tagAttributeListNode">The top level of &lt;tag-rules&gt;</param>
        /// <param name="parseContext">The <see cref="ParseContext"/> containing the tag rules dictionary to fill.</param>
        private static void ParseTagRules(XmlNode tagAttributeListNode, ParseContext parseContext)
        {
            foreach (XmlElement tagNode in PolicyParserUtil.GetChildrenByTagName(tagAttributeListNode, "tag"))
            {
                string tagName = XmlUtil.GetAttributeValue(tagNode, "name");

                var tag = new Tag(tagName)
                {
                    Action            = XmlUtil.GetAttributeValue(tagNode, "action"),
                    AllowedAttributes = GetTagAllowedAttributes(tagNode, tagName, parseContext)
                };

                parseContext.tagRules.Add(tagName.ToLowerInvariant(), tag);
            }
        }
Exemplo n.º 2
0
        internal Policy MutateTag(Tag tag)
        {
            var    newTagRules    = new Dictionary <string, Tag>(tagRules);
            string tagNameToLower = tag.Name.ToLowerInvariant();

            if (newTagRules.ContainsKey(tagNameToLower))
            {
                newTagRules[tagNameToLower] = tag;
            }
            else
            {
                newTagRules.Add(tagNameToLower, tag);
            }

            return(new InternalPolicy(this, directives, newTagRules));
        }