Exemplo n.º 1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="info"></param>
 /// <param name="blank"></param>
 /// <param name="saveLiteral"></param>
 /// <param name="ignoreMaskBlank"></param>
 public LegacyMaskManager(LegacyMaskInfo info, char blank, bool saveLiteral, bool ignoreMaskBlank) : base(new LegacyMaskManagerState(info))
 {
     this._info            = info;
     this._saveLiteral     = saveLiteral;
     this._blank           = blank;
     this._ignoreMaskBlank = ignoreMaskBlank;
 }
Exemplo n.º 2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="info"></param>
 /// <param name="caseConversion"></param>
 static void PatchZeroLengthMaskInfo(LegacyMaskInfo info, char caseConversion)
 {
     if (info.Count == 0)
     {
         info.container.Add(new LegacyMaskChar(".", caseConversion, 0, 0x7fffffff));
     }
 }
Exemplo n.º 3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="info"></param>
 /// <param name="elements"></param>
 /// <param name="cursorPositionElement"></param>
 /// <param name="cursorPositionInsideElement"></param>
 /// <param name="selectionAnchorElement"></param>
 /// <param name="selectionAnchorInsideElement"></param>
 public LegacyMaskManagerState(LegacyMaskInfo info, string[] elements, int cursorPositionElement, int cursorPositionInsideElement, int selectionAnchorElement, int selectionAnchorInsideElement)
 {
     this.Info     = info;
     this.Elements = elements;
     this.CursorPositionElement        = cursorPositionElement;
     this.CursorPositionInsideElement  = cursorPositionInsideElement;
     this.SelectionAnchorElement       = selectionAnchorElement;
     this.SelectionAnchorInsideElement = selectionAnchorInsideElement;
 }
Exemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="mask"></param>
        /// <param name="maskCulture"></param>
        /// <returns></returns>
        public static LegacyMaskInfo GetRegularMaskInfo(string mask, CultureInfo maskCulture)
        {
            LegacyMaskInfo info           = new LegacyMaskInfo();
            string         str            = mask;
            char           caseConversion = 'A';

            while (str.Length > 0)
            {
                int    index;
                string str3;
                char   literal = str[0];
                string str2    = str.Substring(1);
                switch (literal)
                {
                case '*':
                    info.PatchQuantifier(0, 0x7fffffff);
                    break;

                case '+':
                    info.PatchQuantifier(1, 0x7fffffff);
                    break;

                case '.':
                    info.container.Add(new LegacyMaskChar(".", caseConversion, 1, 1));
                    break;

                case '$':
                    foreach (char ch5 in maskCulture.NumberFormat.CurrencySymbol)
                    {
                        info.container.Add(new LegacyMaskLiteral(ch5));
                    }
                    break;

                case '<':
                    if (!str.StartsWith("<>"))
                    {
                        caseConversion = 'L';
                        break;
                    }
                    str2           = str.Substring(2);
                    caseConversion = 'A';
                    break;

                case '>':
                    caseConversion = 'U';
                    break;

                case '?':
                    info.PatchQuantifier(0, 1);
                    break;

                case '[':
                    index = str2.Replace(@"\]", @"\}").IndexOf(']');
                    if (index < 0)
                    {
                        throw new ArgumentException("Incorrect mask: ']' expected after '['");
                    }
                    str3 = str.Substring(0, index + 2);
                    str2 = str.Substring(index + 2);
                    info.container.Add(new LegacyMaskChar(str3, caseConversion, 1, 1));
                    break;

                case '\\':
                    if (str2.Length == 0)
                    {
                        throw new ArgumentException(@"Incorrect mask: character expected after '\'");
                    }
                    literal = str2[0];
                    str2    = str2.Substring(1);
                    if (literal == 'd' || literal == 'w' || literal == 'D' || literal == 'W')
                    {
                        info.container.Add(new LegacyMaskChar(@"\" + literal, caseConversion, 1, 1));
                    }
                    else
                    {
                        info.container.Add(new LegacyMaskLiteral(literal));
                    }
                    break;

                case '{':
                    int length = str2.IndexOf('}');
                    if (length == 0)
                    {
                        throw new ArgumentException("Incorrect mask: '}' expected after '{'");
                    }
                    string[] strArray = str2.Substring(0, length).Split(new char[] { ',' });
                    str2 = str.Substring(length + 2);
                    if (strArray.Length != 1)
                    {
                        if (strArray.Length != 2)
                        {
                            throw new ArgumentException("Incorrect mask: invalid quantifier format");
                        }
                        int min = int.Parse(strArray[0], CultureInfo.InvariantCulture);
                        int max = (strArray[1].Length == 0) ? 0x7fffffff : int.Parse(strArray[1], CultureInfo.InvariantCulture);
                        info.PatchQuantifier(min, max);
                    }
                    else
                    {
                        int num3 = int.Parse(strArray[0], CultureInfo.InvariantCulture);
                        info.PatchQuantifier(num3, num3);
                    }
                    break;

                default:
                    info.container.Add(new LegacyMaskLiteral(literal));
                    break;
                }
                str = str2;
            }
            PatchZeroLengthMaskInfo(info, caseConversion);
            return(info);
        }
Exemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="mask"></param>
        /// <param name="maskCulture"></param>
        /// <returns></returns>
        public static LegacyMaskInfo GetSimpleMaskInfo(string mask, CultureInfo maskCulture)
        {
            LegacyMaskInfo info           = new LegacyMaskInfo();
            string         str            = mask;
            char           caseConversion = 'A';

            while (str.Length > 0)
            {
                string currencySymbol;
                char   c    = str[0];
                string str2 = str.Substring(1);
                switch (c)
                {
                case '#':
                    info.container.Add(new LegacyMaskChar(@"(\d|[+]|[-])", caseConversion, 0, 1));
                    break;

                case '$':
                    currencySymbol = maskCulture.NumberFormat.CurrencySymbol;
                    int num3 = 0;
                    while (num3 < currencySymbol.Length)
                    {
                        char ch5 = currencySymbol[num3];
                        info.container.Add(new LegacyMaskLiteral(ch5));
                        num3++;
                    }
                    break;

                case '0':
                case '9':
                    info.container.Add(new LegacyMaskChar(@"\d", caseConversion, (c == '0') ? 1 : 0, 1));
                    break;

                case '<':
                    if (!str.StartsWith("<>"))
                    {
                        caseConversion = 'L';
                        break;
                    }
                    str2           = str.Substring(2);
                    caseConversion = 'A';
                    break;

                case '>':
                    caseConversion = 'U';
                    break;

                case 'A':
                case 'a':
                    info.container.Add(new LegacyMaskChar(@"(\p{L}|\d)", caseConversion, char.IsUpper(c) ? 1 : 0, 1));
                    break;

                case 'C':
                case 'c':
                    info.container.Add(new LegacyMaskChar(".", caseConversion, char.IsUpper(c) ? 1 : 0, 1));
                    break;

                case 'l':
                case 'L':
                    info.container.Add(new LegacyMaskChar(@"\p{L}", caseConversion, char.IsUpper(c) ? 1 : 0, 1));
                    break;

                case '\\':
                    if (str2.Length == 0)
                    {
                        throw new ArgumentException(@"Incorrect mask: character expected after '\'");
                    }
                    c    = str2[0];
                    str2 = str2.Substring(1);
                    info.container.Add(new LegacyMaskLiteral(c));
                    break;

                default:
                    info.container.Add(new LegacyMaskLiteral(c));
                    break;
                }
                str = str2;
            }
            PatchZeroLengthMaskInfo(info, caseConversion);
            return(info);
        }
Exemplo n.º 6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="info"></param>
 public LegacyMaskManagerState(LegacyMaskInfo info) : this(info, info.GetElementsEmpty(), 0, 0, 0, 0)
 {
 }