本文整理汇总了C#中TimeSpanResult.Init方法的典型用法代码示例。如果您正苦于以下问题:C# TimeSpanResult.Init方法的具体用法?C# TimeSpanResult.Init怎么用?C# TimeSpanResult.Init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeSpanResult
的用法示例。
在下文中一共展示了TimeSpanResult.Init方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例3: TryParseExactMultiple
internal static Boolean TryParseExactMultiple(String input, String[] formats, IFormatProvider formatProvider, TimeSpanStyles styles, out TimeSpan result) {
TimeSpanResult parseResult = new TimeSpanResult();
parseResult.Init(TimeSpanThrowStyle.None);
if (TryParseExactMultipleTimeSpan(input, formats, formatProvider, styles, ref parseResult)) {
result = parseResult.parsedTimeSpan;
return true;
}
else {
result = default(TimeSpan);
return false;
}
}
示例4: 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();
}
}
示例5: TryParse
internal static Boolean TryParse(String input, IFormatProvider formatProvider, out TimeSpan result) {
TimeSpanResult parseResult = new TimeSpanResult();
parseResult.Init(TimeSpanThrowStyle.None);
if (TryParseTimeSpan(input, TimeSpanStandardStyles.Any, formatProvider, ref parseResult)) {
result = parseResult.parsedTimeSpan;
return true;
}
else {
result = default(TimeSpan);
return false;
}
}
示例6: 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();
}
}
示例7: 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);
}
示例8: 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;
}
示例9: 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;
}
示例10: 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;
}