Exemplo n.º 1
0
        /// <summary>
        /// Is this mask equals to another string mask
        /// </summary>
        /// <param name="b"></param>
        /// <returns></returns>
        public bool Equals(StringMask mask)
        {
            if (Length != mask.Length)
            {
                return(false);
            }

            for (int i = 0; i < Length; i++)
            {
                if (this[i] != mask[i])
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Splits the string using a string a seperators
        /// </summary>
        /// <param name="strs"></param>
        /// <param name="count"></param>
        /// <param name="stringSplitOptions"></param>
        /// <returns></returns>
        public StringMask[] Split(IEnumerable <string> strs, int count, StringSplitOptions stringSplitOptions)
        {
            Queue indexes    = new Queue();
            int   encounters = 0;

            for (int i = start; i < end; i++)
            {
                bool found = false;
                foreach (string str in strs)
                {
                    if (CompareStringFromIndex(str, i - start))
                    {
                        found = true;
                        break;
                    }
                }
                if (found && (count == -1 || encounters < count))
                {
                    indexes.Enqueue(i);
                    encounters++;
                    i += str.Length;
                }
            }

            indexes.Enqueue(end);
            int last      = start;
            int maskIndex = 0;

            StringMask[] mask = new StringMask[indexes.Count];

            while (indexes.Count != 0)
            {
                int pop = (int)indexes.Dequeue();

                mask[maskIndex] = new StringMask(this.str, last +
                                                 (stringSplitOptions == StringSplitOptions.RemoveEmptyEntries ? str.Length : 0),
                                                 pop);

                maskIndex++;
                last = pop;
            }

            return(mask);
        }
Exemplo n.º 3
0
 public StringMaskEnumrator(StringMask mask)
 {
     this.mask = mask;
     index     = -1;
 }