public WhitespaceRuleLookup(IList <WhitespaceRule> rules) : this()
        {
            WhitespaceRule         rule;
            InternalWhitespaceRule ruleInternal;

            Debug.Assert(rules != null);

            for (int i = rules.Count - 1; i >= 0; i--)
            {
                // Make a copy of each rule
                rule         = rules[i];
                ruleInternal = new InternalWhitespaceRule(rule.LocalName, rule.NamespaceName, rule.PreserveSpace, -i);

                if (rule.LocalName == null || rule.NamespaceName == null)
                {
                    // Wildcard, so add to wildcards array
                    _wildcards.Add(ruleInternal);
                }
                else
                {
                    // Exact name, so add to hashtable
                    _qnames[ruleInternal] = ruleInternal;
                }
            }

            // Create a temporary (not thread-safe) InternalWhitespaceRule used for lookups
            _ruleTemp = new InternalWhitespaceRule();
        }
        /// <summary>
        /// Create a new lookup internal class from the specified WhitespaceRules. 
        /// </summary>
        public WhitespaceRuleLookup(IList<WhitespaceRule> rules) : this()
        {
            WhitespaceRule rule;
            InternalWhitespaceRule ruleInternal;
            Debug.Assert(rules != null);

            for (int i = rules.Count - 1; i >= 0; i--)
            {
                // Make a copy of each rule
                rule = rules[i];
                ruleInternal = new InternalWhitespaceRule(rule.LocalName, rule.NamespaceName, rule.PreserveSpace, -i);

                if (rule.LocalName == null || rule.NamespaceName == null)
                {
                    // Wildcard, so add to wildcards array
                    _wildcards.Add(ruleInternal);
                }
                else
                {
                    // Exact name, so add to hashtable
                    _qnames[ruleInternal] = ruleInternal;
                }
            }

            // Create a temporary (not thread-safe) InternalWhitespaceRule used for lookups
            _ruleTemp = new InternalWhitespaceRule();
        }
Exemple #3
0
            public override bool Equals(object obj)
            {
                Debug.Assert(obj is InternalWhitespaceRule);
                InternalWhitespaceRule that = obj as InternalWhitespaceRule;

                Debug.Assert(LocalName != null && that.LocalName != null);
                Debug.Assert(NamespaceName != null && that.NamespaceName != null);
                return((object)LocalName == (object)LocalName && (object)NamespaceName == (object)that.NamespaceName);
            }
            public override bool Equals(object obj)
            {
                Debug.Assert(obj is InternalWhitespaceRule);
                InternalWhitespaceRule that = obj as InternalWhitespaceRule;

                Debug.Assert(LocalName != null && that.LocalName != null);
                Debug.Assert(NamespaceName != null && that.NamespaceName != null);

                // string == operator compares object references first and if they are not the same compares contents
                // of the compared strings. As a result we do not have to cast strings to objects to force reference
                // comparison for atomized LocalNames and NamespaceNames.
                return(LocalName == that.LocalName && NamespaceName == that.NamespaceName);
            }