Esempio n. 1
0
 private static bool TryParseExactMultipleNumberSpan(string input, string[] formats, IFormatProvider formatProvider, NumberSpanStyles styles, ref NumberSpanResult result)
 {
     if (input == null)
     {
         result.SetFailure(ParseFailureKind.ArgumentNull, "ArgumentNull_String", null, "input");
         return false;
     }
     if (formats == null)
     {
         result.SetFailure(ParseFailureKind.ArgumentNull, "ArgumentNull_String", null, "formats");
         return false;
     }
     if (input.Length == 0)
     {
         result.SetFailure(ParseFailureKind.Format, "Format_BadNumberSpan");
         return false;
     }
     if (formats.Length == 0)
     {
         result.SetFailure(ParseFailureKind.Format, "Format_BadFormatSpecifier");
         return false;
     }
     for (int i = 0; i < formats.Length; i++)
     {
         if (formats[i] == null || formats[i].Length == 0)
         {
             result.SetFailure(ParseFailureKind.Format, "Format_BadFormatSpecifier");
             return false;
         }
         NumberSpanResult result2 = new NumberSpanResult();
         result2.Init(NumberSpanThrowStyle.None);
         if (TryParseExactNumberSpan(input, formats[i], formatProvider, styles, ref result2))
         {
             result._parsedNumberSpan = result2._parsedNumberSpan;
             return true;
         }
     }
     result.SetFailure(ParseFailureKind.Format, "Format_BadNumberSpan");
     return false;
 }
Esempio n. 2
0
 internal static bool TryParseExactMultiple(string input, string[] formats, IFormatProvider formatProvider, NumberSpanStyles styles, out NumberSpan result)
 {
     NumberSpanResult result2 = new NumberSpanResult();
     result2.Init(NumberSpanThrowStyle.None);
     if (TryParseExactMultipleNumberSpan(input, formats, formatProvider, styles, ref result2))
     {
         result = result2._parsedNumberSpan;
         return true;
     }
     result = new NumberSpan();
     return false;
 }
Esempio n. 3
0
 internal static void ValidateStyles(NumberSpanStyles style, string parameterName)
 {
     if (style != NumberSpanStyles.None && style != NumberSpanStyles.AssumeNegative)
         throw new ArgumentException("Argument_InvalidNumberSpanStyles", parameterName);
 }
Esempio n. 4
0
 internal static NumberSpan ParseExactMultiple(string input, string[] formats, IFormatProvider formatProvider, NumberSpanStyles styles)
 {
     NumberSpanResult result = new NumberSpanResult();
     result.Init(NumberSpanThrowStyle.All);
     if (!TryParseExactMultipleNumberSpan(input, formats, formatProvider, styles, ref result))
         throw result.GetNumberSpanParseException();
     return result._parsedNumberSpan;
 }
Esempio n. 5
0
 private static bool TryParseExactNumberSpan(string input, string format, IFormatProvider formatProvider, NumberSpanStyles styles, ref NumberSpanResult result)
 {
     if (input == null)
     {
         result.SetFailure(ParseFailureKind.ArgumentNull, "ArgumentNull_String", null, "input");
         return false;
     }
     if (format == null)
     {
         result.SetFailure(ParseFailureKind.ArgumentNull, "ArgumentNull_String", null, "format");
         return false;
     }
     if (format.Length == 0)
     {
         result.SetFailure(ParseFailureKind.Format, "Format_BadFormatSpecifier");
         return false;
     }
     //if (format.Length != 1)
     //    return TryParseByFormat(input, format, styles, ref result);
     NumberSpanStandardStyles none = NumberSpanStandardStyles.None;
     if (format[0] == 'c' || format[0] == 't' || format[0] == 'T')
         return TryParseNumberSpanConstant(input, ref result);
     if (format[0] == 'g')
         none = NumberSpanStandardStyles.Localized;
     else if (format[0] == 'G')
         none = NumberSpanStandardStyles.RequireFull | NumberSpanStandardStyles.Localized;
     else
     {
         result.SetFailure(ParseFailureKind.Format, "Format_BadFormatSpecifier");
         return false;
     }
     return TryParseNumberSpan(input, none, formatProvider, ref result);
 }