Example #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;
 }
Example #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;
 }
Example #3
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;
 }
Example #4
0
 internal static bool TryParse(string input, IFormatProvider formatProvider, out NumberSpan result)
 {
     NumberSpanResult result2 = new NumberSpanResult();
     result2.Init(NumberSpanThrowStyle.None);
     if (TryParseNumberSpan(input, NumberSpanStandardStyles.Any, formatProvider, ref result2))
     {
         result = result2._parsedNumberSpan;
         return true;
     }
     result = new NumberSpan();
     return false;
 }
Example #5
0
 internal static NumberSpan Parse(string input, IFormatProvider formatProvider)
 {
     NumberSpanResult result = new NumberSpanResult();
     result.Init(NumberSpanThrowStyle.All);
     if (!TryParseNumberSpan(input, NumberSpanStandardStyles.Any, formatProvider, ref result))
         throw result.GetNumberSpanParseException();
     return result._parsedNumberSpan;
 }