示例#1
0
        public override IScrubfuTagOptions GetOptions(string optionsText = null)
        {
            var options = new MaskTagOptions();

            if (string.IsNullOrEmpty(optionsText))
            {
                optionsText = OptionsText;
            }

            if (string.IsNullOrEmpty(optionsText))
            {
                return(options);
            }

            var optionParts = optionsText.SplitWithValues(";");

            var maskOffsets = optionParts[0].SplitWithValues(",");

            if (int.TryParse(maskOffsets[0], out int outStartVal))
            {
                options.MaskStartOffset = outStartVal;
            }

            if (int.TryParse(maskOffsets[1], out int outEndVal))
            {
                options.MaskEndOffset = outEndVal;
            }

            if (optionParts.Length < 2)
            {
                return(options);
            }

            if (optionParts[1].IsWrappedByString("'"))
            {
                options.MaskChar = char.Parse(optionParts[1].Substring(1, 1));
            }
            else if (optionParts[1].IsEscaped())
            {
                options.MaskChar = char.Parse(optionParts[1].Substring(1, 1));
            }
            else
            {
                options.MaskChar = char.Parse(optionParts[1].Substring(0, 1));
            }

            if (optionParts.Length < 3)
            {
                return(options);
            }

            if (!string.IsNullOrEmpty(optionParts[2]))
            {
                options.IgnoreStrings = optionParts[2].SplitWithValues(",");
            }

            RemoveSingleQuotesAndUnescapeIgnoreStrings(ref options);

            return(options);
        }
示例#2
0
 private static void RemoveSingleQuotesAndUnescapeIgnoreStrings(ref MaskTagOptions options)
 {
     // Remove leading and trailing single quotes, but leave any single quotes that are meant to be part of the ignore string
     for (var i = 0; i < options.IgnoreStrings.Length; i++)
     {
         options.IgnoreStrings[i] = Regex.Unescape(options.IgnoreStrings[i].RemoveSurroundingQuotes());
     }
 }