/// <summary> /// Determines whether the format string is valid. /// </summary> /// <param name="token">The token to evaluate.</param> /// <returns> /// <c>true</c> if the specified format contains the text; otherwise, <c>false</c>. /// </returns> internal static bool EvaluateFormat(string token) { if ((token == null) || (token == string.Empty)) { return(false); } string str = DefaultTokens.TrimSquareBracket(token); if ((str == null) || (str == string.Empty)) { return(false); } str = str.ToLower(); char ch = '\0'; for (int i = 0; i < str.Length; i++) { if (ch == '\0') { ch = str[i]; } if (((ch != HoursABSContent) && (ch != MinuteABSContent)) && (ch != SecondABSContent)) { return(false); } if (ch != str[i]) { return(false); } } return(true); }
/// <summary> /// Determines whether the format string is valid. /// </summary> /// <param name="token">The token to evaluate.</param> /// <returns> /// <c>true</c> if the specified format contains the text; otherwise, <c>false</c>. /// </returns> internal static bool EvaluateFormat(string token) { if ((token == null) || (token == string.Empty)) { return(false); } string str = DefaultTokens.TrimSquareBracket(token); return(((str != null) && !(str == string.Empty)) && DefaultTokens.IsEquals(str[0], DefaultTokens.Dollar, false)); }
/// <summary> /// Determines whether the format string is valid. /// </summary> /// <param name="token">The token to evaluate.</param> /// <returns> /// <c>true</c> if the specified format contains the text; otherwise, <c>false</c>. /// </returns> internal static bool EvaluateFormat(string token) { if ((token == null) || (token == string.Empty)) { return(false); } string str = DefaultTokens.TrimSquareBracket(token); if ((str == null) || (str == string.Empty)) { return(false); } return(str.StartsWith("DBNum", (StringComparison)StringComparison.CurrentCultureIgnoreCase)); }
/// <summary> /// Creates a new DB number format. /// </summary> /// <param name="token">The string expression for the format.</param> public DBNumberFormatPart(string token) : base(token) { if (!EvaluateFormat(token)) { throw new ArgumentException(ResourceStrings.FormatterIllegaTokenError); } this.token = token; string s = DefaultTokens.TrimSquareBracket(token).Remove(0, "dbnum".Length); this.type = int.Parse(s); if ((this.type < 0) || (this.type > 3)) { throw new ArgumentException(ResourceStrings.FormatterIllegaTokenError); } }
/// <summary> /// Creates a new locale format with the specified token. /// </summary> /// <param name="token">The string expression for the format.</param> public LocaleIDFormatPart(string token) : base(token) { this.locateID = -1; if (token == null) { throw new ArgumentNullException("token"); } if (token == string.Empty) { throw new FormatException(ResourceStrings.FormatterIllegaTokenError); } this.content = DefaultTokens.TrimSquareBracket(token); string content = this.content; if ((content == null) || (content == string.Empty)) { throw new FormatException(ResourceStrings.FormatterIllegaTokenError); } if (!DefaultTokens.IsEquals(content[0], DefaultTokens.Dollar, false)) { throw new FormatException(ResourceStrings.FormatterIllegaTokenError); } content = content.Remove(0, 1); int index = content.IndexOf(DefaultTokens.HyphenMinus); if (index > -1) { this.currencySymbol = content.Substring(0, index); content = content.Remove(0, index); } else { this.currencySymbol = content; return; } if (!DefaultTokens.IsEquals(content[0], DefaultTokens.HyphenMinus, false)) { throw new FormatException(ResourceStrings.FormatterIllegaTokenError); } content = content.Remove(0, 1); if (content.Length <= 0) { throw new FormatException(ResourceStrings.FormatterIllegaTokenError); } this.locateID = NumberHelper.ParseHexString(content); }
/// <summary> /// Determines whether the format string is valid. /// </summary> /// <param name="token">The token to evaluate.</param> /// <returns> /// <c>true</c> if the specified format contains the text; otherwise, <c>false</c>. /// </returns> internal static bool EvaluateFormat(string token) { if ((token == null) || (token == string.Empty)) { return(false); } string str = DefaultTokens.TrimSquareBracket(token); if ((str == null) || (str == string.Empty)) { return(false); } if (str.Length < 3) { return(false); } if (char.IsNumber(token[token.Length - 1])) { return(token.StartsWith("Color", (StringComparison)StringComparison.CurrentCultureIgnoreCase)); } return(token[0] != token[1]); }
/// <summary> /// Creates a new color format. /// </summary> /// <param name="token">The string expression for the color format.</param> /// <remarks>Use a string expression such as "[red]" or "[blue]" to specify the color format.</remarks> public ColorFormatPart(string token) : base(token) { this.foreColor = Colors.Black; this.index = -1; string color = DefaultTokens.TrimSquareBracket(token); if ((color == null) || (color == string.Empty)) { throw new ArgumentException(ResourceStrings.FormatterIllegaTokenError); } try { Windows.UI.Color?nullable = FormatterColorHelper.FromStringValue(color); if (nullable.HasValue) { this.foreColor = nullable.Value; this.colorName = color; return; } if (color.Length > "Color".Length) { color = color.Remove(0, "Color".Length); int result = -1; if ((int.TryParse(color, out result) && (result >= 1)) && (result <= 0x38)) { this.foreColor = FormatterColorHelper.ColorFromIndex(result); this.index = result; return; } } } catch { } throw new ArgumentException(ResourceStrings.FormatterIllegaTokenError); }
/// <summary> /// Creates a new condition format with the specified string expression. /// </summary> /// <param name="token">The string expression for this format.</param> /// <remarks>Examples of conditional string expressions are "[>10]" and "[>=0]".</remarks> public ConditionFormatPart(string token) : base(token) { string str = DefaultTokens.TrimSquareBracket(token); if (string.IsNullOrEmpty(str)) { throw new ArgumentException(ResourceStrings.FormatterIllegaTokenError); } StringBuilder builder = null; int num = 0; while (num < str.Length) { char c = str[num]; if (!DefaultTokens.IsOperator(c)) { break; } if (builder == null) { builder = new StringBuilder(); } builder.Append(c); num++; } if (builder == null) { throw new ArgumentException(ResourceStrings.FormatterIllegaTokenError); } string str2 = builder.ToString(); builder = null; switch (str2) { case "<": this.compareOperator = GeneralCompareType.LessThan; break; case "<=": this.compareOperator = GeneralCompareType.LessThanOrEqualsTo; break; case "=": this.compareOperator = GeneralCompareType.EqualsTo; break; case ">=": this.compareOperator = GeneralCompareType.GreaterThanOrEqualsTo; break; case ">": this.compareOperator = GeneralCompareType.GreaterThan; break; case "<>": this.compareOperator = GeneralCompareType.NotEqualsTo; break; default: throw new ArgumentException(ResourceStrings.FormatterIllegaTokenError); } while (num < str.Length) { char ch2 = str[num]; if (DefaultTokens.IsOperator(ch2)) { throw new ArgumentException(ResourceStrings.FormatterIllegaTokenError); } if (builder == null) { builder = new StringBuilder(); } builder.Append(ch2); num++; } if (builder == null) { throw new ArgumentException(ResourceStrings.FormatterIllegaTokenError); } if (!double.TryParse(builder.ToString(), out this.value)) { throw new ArgumentException(ResourceStrings.FormatterIllegaTokenError); } }