コード例 #1
0
 /// <summary>
 /// Create
 /// </summary>
 public static TokenDescription Create(TokenKeyWords keyWords,
                                       int priority = DefaultPriority - 200,
                                       TokenClassification classification = TokenClassification.Unknown)
 {
     return(new TokenDescriptionKeyWords(keyWords, priority)
     {
         Classification = classification
     });
 }
コード例 #2
0
        /// <summary>
        /// Create
        /// </summary>
        public static TokenDescription Create(IEnumerable <string> words,
                                              int priority = DefaultPriority,
                                              TokenDescriptionOptions options    = TokenDescriptionOptions.None,
                                              TokenClassification classification = TokenClassification.Unknown)
        {
            bool          caseSensitive = !((options & TokenDescriptionOptions.IgnoreCase) == TokenDescriptionOptions.IgnoreCase);
            TokenKeyWords keyWords      = new TokenKeyWords(caseSensitive, words);

            return(new TokenDescriptionKeyWords(keyWords, priority)
            {
                Classification = classification
            });
        }
        /// <summary>
        /// Equals
        /// </summary>
        public bool Equals(TokenKeyWords other)
        {
            if (object.ReferenceEquals(this, other))
            {
                return(true);
            }
            else if (null == other)
            {
                return(false);
            }

            if (m_IsCaseSensitive != other.m_IsCaseSensitive)
            {
                return(false);
            }
            else if (m_Items.Count != other.m_Items.Count)
            {
                return(false);
            }

            HashSet <string> hs = new HashSet <string>(
                m_Items,
                m_IsCaseSensitive ? StringComparer.Ordinal : StringComparer.OrdinalIgnoreCase);

            if (other.m_Items.Any(item => !hs.Contains(item)))
            {
                return(false);
            }

            unchecked {
                if (Enumerable.Range(0, char.MaxValue)
                    .Any(index => m_IsIdentifierLetter((char)index) != other.m_IsIdentifierLetter((char)index)))
                {
                    return(false);
                }
            }

            return(true);
        }
 /// <summary>
 /// Standard constructor
 /// </summary>
 public TokenDescriptionKeyWords(TokenKeyWords keyWords) : this(keyWords, 800)
 {
 }
 /// <summary>
 /// Standard constructor
 /// </summary>
 public TokenDescriptionKeyWords(TokenKeyWords keyWords, int priority)
     : base(priority, keyWords.IsCaseSensitive ? TokenDescriptionOptions.None : TokenDescriptionOptions.IgnoreCase)
 {
     m_KeyWords = keyWords ?? throw new ArgumentNullException("keyWords");
 }