Пример #1
0
        private void ExtractValues(string elementName, XmlReader reader)
        {
            for (int i = 0; i < reader.AttributeCount; ++i)
            {
                reader.MoveToAttribute(i);

                string name  = reader.Name;
                string value = reader.Value;

                if (E.Equals(name))
                {
                    this.element = value.ToElement();
                }
                else if (K.Equals(name))
                {
                    this.keys = value;
                }
                else if (V.Equals(name))
                {
                    this.values = value;
                }
                else if (CAT.Equals(name))
                {
                    this.cat = value;
                }
                else if (CLOSED.Equals(name))
                {
                    this.closed = value.ToClosed();
                }
                else if (ZOOM_MIN.Equals(name))
                {
                    this.zoomMin = XmlUtils.ParseNonNegativeByte(name, value);
                }
                else if (ZOOM_MAX.Equals(name))
                {
                    this.zoomMax = XmlUtils.ParseNonNegativeByte(name, value);
                }
                else
                {
                    throw XmlUtils.CreateXmlReaderException(elementName, name, value, i);
                }
            }

            Validate(elementName);

            this.keyList   = new List <string>(this.keys.Split(SPLIT_PATTERN, StringSplitOptions.RemoveEmptyEntries));
            this.valueList = new List <string>(this.values.Split(SPLIT_PATTERN, StringSplitOptions.RemoveEmptyEntries));

            this.elementMatcher = getElementMatcher(this.element);
            this.closedMatcher  = GetClosedMatcher(this.closed);

            this.elementMatcher = RuleOptimizer.optimize(this.elementMatcher, this.ruleStack);
            this.closedMatcher  = RuleOptimizer.optimize(this.closedMatcher, this.ruleStack);
        }
Пример #2
0
        private readonly List <Rule> subRules;                        // NOSONAR NOPMD we need specific interface

        public Rule(RuleBuilder ruleBuilder)
        {
            this.cat            = ruleBuilder.cat;
            this.closedMatcher  = ruleBuilder.closedMatcher;
            this.elementMatcher = ruleBuilder.elementMatcher;
            this.zoomMax        = ruleBuilder.zoomMax;
            this.zoomMin        = ruleBuilder.zoomMin;

            this.renderInstructions = new List <RenderInstruction>(4);
            this.subRules           = new List <Rule>(4);
        }
Пример #3
0
        internal static ClosedMatcher optimize(ClosedMatcher closedMatcher, Stack <Rule> ruleStack)
        {
            if (closedMatcher is AnyMatcher)
            {
                return(closedMatcher);
            }

            foreach (var rule in ruleStack)
            {
                if (rule.closedMatcher.IsCoveredBy(closedMatcher))
                {
                    return(AnyMatcher.INSTANCE);
                }
                else if (!closedMatcher.IsCoveredBy(rule.closedMatcher))
                {
                    LOGGER.Warn("unreachable rule (closed)");
                }
            }

            return(closedMatcher);
        }
Пример #4
0
 public bool IsCoveredBy(ClosedMatcher closedMatcher)
 {
     return(closedMatcher.Matches(Closed.NO));
 }
Пример #5
0
 public bool IsCoveredBy(ClosedMatcher closedMatcher)
 {
     return(closedMatcher == this);
 }