本文整理汇总了C#中TimeSpanResult类的典型用法代码示例。如果您正苦于以下问题:C# TimeSpanResult类的具体用法?C# TimeSpanResult怎么用?C# TimeSpanResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TimeSpanResult类属于命名空间,在下文中一共展示了TimeSpanResult类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ParseExactMultiple
internal static TimeSpan ParseExactMultiple(string input, string[] formats, IFormatProvider formatProvider, TimeSpanStyles styles)
{
TimeSpanResult result = new TimeSpanResult();
result.Init(TimeSpanThrowStyle.All);
if (!TryParseExactMultipleTimeSpan(input, formats, formatProvider, styles, ref result))
{
throw result.GetTimeSpanParseException();
}
return result.parsedTimeSpan;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:10,代码来源:TimeSpanParse.cs
示例2: Parse
internal static TimeSpan Parse(string input, IFormatProvider formatProvider)
{
TimeSpanResult result = new TimeSpanResult();
result.Init(TimeSpanThrowStyle.All);
if (!TryParseTimeSpan(input, TimeSpanStandardStyles.Any, formatProvider, ref result))
{
throw result.GetTimeSpanParseException();
}
return result.parsedTimeSpan;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:10,代码来源:TimeSpanParse.cs
示例3: ParseTime
internal bool ParseTime(out long time, ref TimeSpanResult result) {
time = 0;
int unit;
if (!ParseInt(23, out unit, ref result)) {
return false;
}
time = unit * TimeSpan.TicksPerHour;
if (ch != ':') {
result.SetFailure(ParseFailureKind.Format, "Format_BadTimeSpan");
return false;
}
NextChar();
if (!ParseInt(59, out unit, ref result)) {
return false;
}
time += unit * TimeSpan.TicksPerMinute;
if (ch == ':') {
NextChar();
// allow seconds with the leading zero
if (ch != '.') {
if (!ParseInt(59, out unit, ref result)) {
return false;
}
time += unit * TimeSpan.TicksPerSecond;
}
if (ch == '.') {
NextChar();
int f = (int)TimeSpan.TicksPerSecond;
while (f > 1 && ch >= '0' && ch <= '9') {
f /= 10;
time += (ch - '0') * f;
NextChar();
}
}
}
return true;
}
开发者ID:kouvel,项目名称:coreclr,代码行数:37,代码来源:TimeSpanParse.cs
示例4: TryParse
internal static bool TryParse(string input, IFormatProvider formatProvider, out TimeSpan result)
{
TimeSpanResult result2 = new TimeSpanResult();
result2.Init(TimeSpanThrowStyle.None);
if (TryParseTimeSpan(input, TimeSpanStandardStyles.Any, formatProvider, ref result2))
{
result = result2.parsedTimeSpan;
return true;
}
result = new TimeSpan();
return false;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:12,代码来源:TimeSpanParse.cs
示例5: ProcessTerminal_HM_S_D
//
// ProcessTerminal_HM_S_D
//
// Actions: Validate the ambiguous 3-number "Hours:Minutes:Seconds", "Days.Hours:Minutes", or "Hours:Minutes:.Fraction" terminal case
//
private static Boolean ProcessTerminal_HM_S_D(ref TimeSpanRawInfo raw, TimeSpanStandardStyles style, ref TimeSpanResult result) {
if (raw.SepCount != 4 || raw.NumCount != 3 || (style & TimeSpanStandardStyles.RequireFull) != 0) {
result.SetFailure(ParseFailureKind.Format, "Format_BadTimeSpan");
return false;
}
bool inv = ((style & TimeSpanStandardStyles.Invariant) != 0);
bool loc = ((style & TimeSpanStandardStyles.Localized) != 0);
bool positive = false;
bool match = false;
bool overflow = false;
long ticks = 0;
if (inv) {
if (raw.FullHMSMatch(raw.PositiveInvariant)) {
positive = true;
match = TryTimeToTicks(positive, zero, raw.numbers[0], raw.numbers[1], raw.numbers[2], zero, out ticks);
overflow = overflow || !match;
}
if (!match && raw.FullDHMMatch(raw.PositiveInvariant)) {
positive = true;
match = TryTimeToTicks(positive, raw.numbers[0], raw.numbers[1], raw.numbers[2], zero, zero, out ticks);
overflow = overflow || !match;
}
if (!match && raw.PartialAppCompatMatch(raw.PositiveInvariant)) {
positive = true;
match = TryTimeToTicks(positive, zero, raw.numbers[0], raw.numbers[1], zero, raw.numbers[2], out ticks);
overflow = overflow || !match;
}
if (!match && raw.FullHMSMatch(raw.NegativeInvariant)) {
positive = false;
match = TryTimeToTicks(positive, zero, raw.numbers[0], raw.numbers[1], raw.numbers[2], zero, out ticks);
overflow = overflow || !match;
}
if (!match && raw.FullDHMMatch(raw.NegativeInvariant)) {
positive = false;
match = TryTimeToTicks(positive, raw.numbers[0], raw.numbers[1], raw.numbers[2], zero, zero, out ticks);
overflow = overflow || !match;
}
if (!match && raw.PartialAppCompatMatch(raw.NegativeInvariant)) {
positive = false;
match = TryTimeToTicks(positive, zero, raw.numbers[0], raw.numbers[1], zero, raw.numbers[2], out ticks);
overflow = overflow || !match;
}
}
if (loc) {
if (!match && raw.FullHMSMatch(raw.PositiveLocalized)) {
positive = true;
match = TryTimeToTicks(positive, zero, raw.numbers[0], raw.numbers[1], raw.numbers[2], zero, out ticks);
overflow = overflow || !match;
}
if (!match && raw.FullDHMMatch(raw.PositiveLocalized)) {
positive = true;
match = TryTimeToTicks(positive, raw.numbers[0], raw.numbers[1], raw.numbers[2], zero, zero, out ticks);
overflow = overflow || !match;
}
if (!match && raw.PartialAppCompatMatch(raw.PositiveLocalized)) {
positive = true;
match = TryTimeToTicks(positive, zero, raw.numbers[0], raw.numbers[1], zero, raw.numbers[2], out ticks);
overflow = overflow || !match;
}
if (!match && raw.FullHMSMatch(raw.NegativeLocalized)) {
positive = false;
match = TryTimeToTicks(positive, zero, raw.numbers[0], raw.numbers[1], raw.numbers[2], zero, out ticks);
overflow = overflow || !match;
}
if (!match && raw.FullDHMMatch(raw.NegativeLocalized)) {
positive = false;
match = TryTimeToTicks(positive, raw.numbers[0], raw.numbers[1], raw.numbers[2], zero, zero, out ticks);
overflow = overflow || !match;
}
if (!match && raw.PartialAppCompatMatch(raw.NegativeLocalized)) {
positive = false;
match = TryTimeToTicks(positive, zero, raw.numbers[0], raw.numbers[1], zero, raw.numbers[2], out ticks);
overflow = overflow || !match;
}
}
if (match) {
if (!positive) {
ticks = -ticks;
if (ticks > 0) {
result.SetFailure(ParseFailureKind.Overflow, "Overflow_TimeSpanElementTooLarge");
return false;
}
}
result.parsedTimeSpan._ticks = ticks;
return true;
}
if (overflow) {
// we found at least one literal pattern match but the numbers just didn't fit
result.SetFailure(ParseFailureKind.Overflow, "Overflow_TimeSpanElementTooLarge");
//.........这里部分代码省略.........
开发者ID:kouvel,项目名称:coreclr,代码行数:101,代码来源:TimeSpanParse.cs
示例6: TryParseTimeSpan
// ---- SECTION: private static methods that do the actual work ---------*
#region TryParseTimeSpan
//
// TryParseTimeSpan
//
// Actions: Common private Parse method called by both Parse and TryParse
//
private static Boolean TryParseTimeSpan(String input, TimeSpanStandardStyles style, IFormatProvider formatProvider, ref TimeSpanResult result) {
if (input == null) {
result.SetFailure(ParseFailureKind.ArgumentNull, "ArgumentNull_String", null, nameof(input));
return false;
}
input = input.Trim();
if (input == String.Empty) {
result.SetFailure(ParseFailureKind.Format, "Format_BadTimeSpan");
return false;
}
TimeSpanTokenizer tokenizer = new TimeSpanTokenizer();
tokenizer.Init(input);
TimeSpanRawInfo raw = new TimeSpanRawInfo();
raw.Init(DateTimeFormatInfo.GetInstance(formatProvider));
TimeSpanToken tok = tokenizer.GetNextToken();
/* The following loop will break out when we reach the end of the str or
* when we can determine that the input is invalid. */
while (tok.ttt != TTT.End) {
if (!raw.ProcessToken(ref tok, ref result)) {
result.SetFailure(ParseFailureKind.Format, "Format_BadTimeSpan");
return false;
}
tok = tokenizer.GetNextToken();
}
if (!tokenizer.EOL) {
// embedded nulls in the input string
result.SetFailure(ParseFailureKind.Format, "Format_BadTimeSpan");
return false;
}
if (!ProcessTerminalState(ref raw, style, ref result)) {
result.SetFailure(ParseFailureKind.Format, "Format_BadTimeSpan");
return false;
}
return true;
}
开发者ID:kouvel,项目名称:coreclr,代码行数:47,代码来源:TimeSpanParse.cs
示例7: ParseExactMultiple
internal static TimeSpan ParseExactMultiple(String input, String[] formats, IFormatProvider formatProvider, TimeSpanStyles styles) {
TimeSpanResult parseResult = new TimeSpanResult();
parseResult.Init(TimeSpanThrowStyle.All);
if (TryParseExactMultipleTimeSpan(input, formats, formatProvider, styles, ref parseResult)) {
return parseResult.parsedTimeSpan;
}
else {
throw parseResult.GetTimeSpanParseException();
}
}
开发者ID:kouvel,项目名称:coreclr,代码行数:11,代码来源:TimeSpanParse.cs
示例8: Parse
// ---- SECTION: internal static methods called by System.TimeSpan ---------*
//
// [Try]Parse, [Try]ParseExact, and [Try]ParseExactMultiple
//
// Actions: Main methods called from TimeSpan.Parse
#region ParseMethods
internal static TimeSpan Parse(String input, IFormatProvider formatProvider) {
TimeSpanResult parseResult = new TimeSpanResult();
parseResult.Init(TimeSpanThrowStyle.All);
if (TryParseTimeSpan(input, TimeSpanStandardStyles.Any, formatProvider, ref parseResult)) {
return parseResult.parsedTimeSpan;
}
else {
throw parseResult.GetTimeSpanParseException();
}
}
开发者ID:kouvel,项目名称:coreclr,代码行数:17,代码来源:TimeSpanParse.cs
示例9: AddSep
private bool AddSep(String sep, ref TimeSpanResult result) {
if (SepCount >= MaxLiteralTokens || tokenCount >= MaxTokens) {
result.SetFailure(ParseFailureKind.Format, "Format_BadTimeSpan", null);
return false;
}
literals[SepCount++] = sep;
tokenCount++;
return true;
}
开发者ID:kouvel,项目名称:coreclr,代码行数:9,代码来源:TimeSpanParse.cs
示例10: TryParseTimeSpanConstant
private static bool TryParseTimeSpanConstant(string input, ref TimeSpanResult result)
{
StringParser parser2 = new StringParser();
return parser2.TryParse(input, ref result);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:5,代码来源:TimeSpanParse.cs
示例11: TryParseTimeSpan
private static bool TryParseTimeSpan(string input, TimeSpanStandardStyles style, IFormatProvider formatProvider, ref TimeSpanResult result)
{
if (input == null)
{
result.SetFailure(ParseFailureKind.ArgumentNull, "ArgumentNull_String", null, "input");
return false;
}
input = input.Trim();
if (input == string.Empty)
{
result.SetFailure(ParseFailureKind.Format, "Format_BadTimeSpan");
return false;
}
TimeSpanTokenizer tokenizer = new TimeSpanTokenizer();
tokenizer.Init(input);
TimeSpanRawInfo raw = new TimeSpanRawInfo();
raw.Init(DateTimeFormatInfo.GetInstance(formatProvider));
for (TimeSpanToken token = tokenizer.GetNextToken(); token.ttt != TTT.End; token = tokenizer.GetNextToken())
{
if (!raw.ProcessToken(ref token, ref result))
{
result.SetFailure(ParseFailureKind.Format, "Format_BadTimeSpan");
return false;
}
}
if (!tokenizer.EOL)
{
result.SetFailure(ParseFailureKind.Format, "Format_BadTimeSpan");
return false;
}
if (!ProcessTerminalState(ref raw, style, ref result))
{
result.SetFailure(ParseFailureKind.Format, "Format_BadTimeSpan");
return false;
}
return true;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:37,代码来源:TimeSpanParse.cs
示例12: TryParseExactTimeSpan
private static bool TryParseExactTimeSpan(string input, string format, IFormatProvider formatProvider, TimeSpanStyles styles, ref TimeSpanResult 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);
}
TimeSpanStandardStyles none = TimeSpanStandardStyles.None;
if (((format[0] == 'c') || (format[0] == 't')) || (format[0] == 'T'))
{
return TryParseTimeSpanConstant(input, ref result);
}
if (format[0] == 'g')
{
none = TimeSpanStandardStyles.Localized;
}
else if (format[0] == 'G')
{
none = TimeSpanStandardStyles.RequireFull | TimeSpanStandardStyles.Localized;
}
else
{
result.SetFailure(ParseFailureKind.Format, "Format_BadFormatSpecifier");
return false;
}
return TryParseTimeSpan(input, none, formatProvider, ref result);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:41,代码来源:TimeSpanParse.cs
示例13: TryParseExactMultipleTimeSpan
private static bool TryParseExactMultipleTimeSpan(string input, string[] formats, IFormatProvider formatProvider, TimeSpanStyles styles, ref TimeSpanResult 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_BadTimeSpan");
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;
}
TimeSpanResult result2 = new TimeSpanResult();
result2.Init(TimeSpanThrowStyle.None);
if (TryParseExactTimeSpan(input, formats[i], formatProvider, styles, ref result2))
{
result.parsedTimeSpan = result2.parsedTimeSpan;
return true;
}
}
result.SetFailure(ParseFailureKind.Format, "Format_BadTimeSpan");
return false;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:40,代码来源:TimeSpanParse.cs
示例14: TryParseExactMultiple
internal static bool TryParseExactMultiple(string input, string[] formats, IFormatProvider formatProvider, TimeSpanStyles styles, out TimeSpan result)
{
TimeSpanResult result2 = new TimeSpanResult();
result2.Init(TimeSpanThrowStyle.None);
if (TryParseExactMultipleTimeSpan(input, formats, formatProvider, styles, ref result2))
{
result = result2.parsedTimeSpan;
return true;
}
result = new TimeSpan();
return false;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:12,代码来源:TimeSpanParse.cs
示例15: TryParseByFormat
private static bool TryParseByFormat(string input, string format, TimeSpanStyles styles, ref TimeSpanResult result)
{
bool flag = false;
bool flag2 = false;
bool flag3 = false;
bool flag4 = false;
bool flag5 = false;
int num = 0;
int num2 = 0;
int num3 = 0;
int num4 = 0;
int zeroes = 0;
int num6 = 0;
int pos = 0;
int returnValue = 0;
TimeSpanTokenizer tokenizer = new TimeSpanTokenizer();
tokenizer.Init(input, -1);
while (pos < format.Length)
{
int num9;
char failureMessageFormatArgument = format[pos];
switch (failureMessageFormatArgument)
{
case '%':
num9 = DateTimeFormat.ParseNextChar(format, pos);
if ((num9 < 0) || (num9 == 0x25))
{
goto Label_0280;
}
returnValue = 1;
goto Label_02CA;
case '\'':
case '"':
{
StringBuilder builder = new StringBuilder();
if (!DateTimeParse.TryParseQuoteString(format, pos, builder, out returnValue))
{
result.SetFailure(ParseFailureKind.FormatWithParameter, "Format_BadQuote", failureMessageFormatArgument);
return false;
}
if (ParseExactLiteral(ref tokenizer, builder))
{
goto Label_02CA;
}
result.SetFailure(ParseFailureKind.Format, "Format_InvalidString");
return false;
}
case 'F':
returnValue = DateTimeFormat.ParseRepeatPattern(format, pos, failureMessageFormatArgument);
if ((returnValue > 7) || flag5)
{
result.SetFailure(ParseFailureKind.Format, "Format_InvalidString");
return false;
}
ParseExactDigits(ref tokenizer, returnValue, returnValue, out zeroes, out num6);
flag5 = true;
goto Label_02CA;
case 'm':
returnValue = DateTimeFormat.ParseRepeatPattern(format, pos, failureMessageFormatArgument);
if (((returnValue > 2) || flag3) || !ParseExactDigits(ref tokenizer, returnValue, out num3))
{
result.SetFailure(ParseFailureKind.Format, "Format_InvalidString");
return false;
}
flag3 = true;
goto Label_02CA;
case 's':
returnValue = DateTimeFormat.ParseRepeatPattern(format, pos, failureMessageFormatArgument);
if (((returnValue > 2) || flag4) || !ParseExactDigits(ref tokenizer, returnValue, out num4))
{
result.SetFailure(ParseFailureKind.Format, "Format_InvalidString");
return false;
}
flag4 = true;
goto Label_02CA;
case 'd':
{
returnValue = DateTimeFormat.ParseRepeatPattern(format, pos, failureMessageFormatArgument);
int num10 = 0;
if (((returnValue > 8) || flag) || !ParseExactDigits(ref tokenizer, (returnValue < 2) ? 1 : returnValue, (returnValue < 2) ? 8 : returnValue, out num10, out num))
{
result.SetFailure(ParseFailureKind.Format, "Format_InvalidString");
return false;
}
flag = true;
goto Label_02CA;
}
case 'f':
returnValue = DateTimeFormat.ParseRepeatPattern(format, pos, failureMessageFormatArgument);
if (((returnValue <= 7) && !flag5) && ParseExactDigits(ref tokenizer, returnValue, returnValue, out zeroes, out num6))
{
goto Label_0193;
}
result.SetFailure(ParseFailureKind.Format, "Format_InvalidString");
return false;
//.........这里部分代码省略.........
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:TimeSpanParse.cs
示例16: TryParseExactMultipleTimeSpan
//
// TryParseExactMultipleTimeSpan
//
// Actions: Common private ParseExactMultiple method called by both ParseExactMultiple and TryParseExactMultiple
//
private static Boolean TryParseExactMultipleTimeSpan(String input, String[] formats, IFormatProvider formatProvider, TimeSpanStyles styles, ref TimeSpanResult result) {
if (input == null) {
result.SetFailure(ParseFailureKind.ArgumentNull, "ArgumentNull_String", null, nameof(input));
return false;
}
if (formats == null) {
result.SetFailure(ParseFailureKind.ArgumentNull, "ArgumentNull_String", null, nameof(formats));
return false;
}
if (input.Length == 0) {
result.SetFailure(ParseFailureKind.Format, "Format_BadTimeSpan");
return false;
}
if (formats.Length == 0) {
result.SetFailure(ParseFailureKind.Format, "Format_BadFormatSpecifier");
return false;
}
//
// Do a loop through the provided formats and see if we can parse succesfully in
// one of the formats.
//
for (int i = 0; i < formats.Length; i++) {
if (formats[i] == null || formats[i].Length == 0) {
result.SetFailure(ParseFailureKind.Format, "Format_BadFormatSpecifier");
return false;
}
// Create a new non-throwing result each time to ensure the runs are independent.
TimeSpanResult innerResult = new TimeSpanResult();
innerResult.Init(TimeSpanThrowStyle.None);
if(TryParseExactTimeSpan(input, formats[i], formatProvider, styles, ref innerResult)) {
result.parsedTimeSpan = innerResult.parsedTimeSpan;
return true;
}
}
result.SetFailure(ParseFailureKind.Format, "Format_BadTimeSpan");
return (false);
}
开发者ID:kouvel,项目名称:coreclr,代码行数:48,代码来源:TimeSpanParse.cs
示例17: ProcessToken
internal Boolean ProcessToken(ref TimeSpanToken tok, ref TimeSpanResult result) {
if (tok.ttt == TTT.NumOverflow) {
result.SetFailure(ParseFailureKind.Overflow, "Overflow_TimeSpanElementTooLarge", null);
return false;
}
if (tok.ttt != TTT.Sep && tok.ttt != TTT.Num) {
// Some unknown token or a repeat token type in the input
result.SetFailure(ParseFailureKind.Format, "Format_BadTimeSpan", null);
return false;
}
switch (tok.ttt) {
case TTT.Sep:
if (!AddSep(tok.sep, ref result)) return false;
break;
case TTT.Num:
if (tokenCount == 0) {
if (!AddSep(String.Empty, ref result)) return false;
}
if (!AddNum(tok, ref result)) return false;
break;
default:
break;
}
lastSeenTTT = tok.ttt;
Debug.Assert(tokenCount == (SepCount + NumCount), "tokenCount == (SepCount + NumCount)");
return true;
}
开发者ID:kouvel,项目名称:coreclr,代码行数:29,代码来源:TimeSpanParse.cs
示例18: ProcessTerminal_D
private static bool ProcessTerminal_D(ref TimeSpanRawInfo raw, TimeSpanStandardStyles style, ref TimeSpanResult result)
{
if (((raw.SepCount != 2) || (raw.NumCount != 1)) || ((style & TimeSpanStandardStyles.RequireFull) != TimeSpanStandardStyles.None))
{
result.SetFailure(ParseFailureKind.Format, "Format_BadTimeSpan");
return false;
}
bool flag = (style & TimeSpanStandardStyles.Invariant) != TimeSpanStandardStyles.None;
bool flag2 = (style & TimeSpanStandardStyles.Localized) != TimeSpanStandardStyles.None;
bool positive = false;
bool flag4 = false;
if (flag)
{
if (raw.FullDMatch(raw.PositiveInvariant))
{
flag4 = true;
positive = true;
}
if (!flag4 && raw.FullDMatch(raw.NegativeInvariant))
{
flag4 = true;
positive = false;
}
}
if (flag2)
{
if (!flag4 && raw.FullDMatch(raw.PositiveLocalized))
{
flag4 = true;
positive = true;
}
if (!flag4 && raw.FullDMatch(raw.NegativeLocalized))
{
flag4 = true;
positive = false;
}
}
long num = 0L;
if (flag4)
{
if (!TryTimeToTicks(positive, raw.numbers[0], zero, zero, zero, zero, out num))
{
result.SetFailure(ParseFailureKind.Overflow, "Overflow_TimeSpanElementTooLarge");
return false;
}
if (!positive)
{
num = -num;
if (num > 0L)
{
result.SetFailure(ParseFailureKind.Overflow, "Overflow_TimeSpanElementTooLarge");
return false;
}
}
result.parsedTimeSpan._ticks = num;
return true;
}
result.SetFailure(ParseFailureKind.Format, "Format_BadTimeSpan");
return false;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:60,代码来源:TimeSpanParse.cs
示例19: AddNum
private bool AddNum(TimeSpanToken num, ref TimeSpanResult result) {
if (NumCount >= MaxNumericTokens || tokenCount >= MaxTokens) {
result.SetFailure(ParseFailureKind.Format, "Format_BadTimeSpan", null);
return false;
}
numbers[NumCount++] = num;
tokenCount++;
return true;
}
开发者ID:kouvel,项目名称:coreclr,代码行数:9,代码来源:TimeSpanParse.cs
示例20: TryParseExactTimeSpan
//
// TryParseExactTimeSpan
//
// Actions: Common private ParseExact method called by both ParseExact and TryParseExact
//
private static Boolean TryParseExactTimeSpan(String input, String format, IFormatProvider formatProvider, TimeSpanStyles styles, ref TimeSpanResult result) {
if (input == null) {
result.SetFailure(ParseFailureKind.ArgumentNull, "ArgumentNull_String", null, nameof(input));
return false;
}
if (format == null) {
result.SetFailure(ParseFailureKind.ArgumentNull, "ArgumentNull_String", null, nameof(format));
return false;
}
if (format.Length == 0) {
result.SetFailure(ParseFailureKind.Format, "Format_BadFormatSpecifier");
return false;
}
if (format.Length == 1) {
TimeSpanStandardStyles style = TimeSpanStandardStyles.None;
if (format[0] == 'c' || format[0] == 't' || format[0] == 'T') {
// fast path for legacy style TimeSpan formats.
return TryParseTimeSpanConstant(input, ref result);
}
else if (format[0] == 'g') {
style = TimeSpanStandardStyles.Localized;
}
else if (format[0] == 'G') {
style = TimeSpanStandardStyles.Localized | TimeSpanStandardStyles.RequireFull;
}
else {
result.SetFailure(ParseFailureKind.Format, "Format_BadFormatSpecifier");
return false;
}
return TryParseTimeSpan(input, style, formatProvider, ref result);
}
return TryParseByFormat(input, format, styles, ref result);
}
开发者ID:kouvel,项目名称:coreclr,代码行数:41,代码来源:TimeSpanParse.cs
注:本文中的TimeSpanResult类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论