本文整理汇总了C#中TimeSpanStyles类的典型用法代码示例。如果您正苦于以下问题:C# TimeSpanStyles类的具体用法?C# TimeSpanStyles怎么用?C# TimeSpanStyles使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TimeSpanStyles类属于命名空间,在下文中一共展示了TimeSpanStyles类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: TryParseExactNullable
public static TimeSpan? TryParseExactNullable(string value, string format, IFormatProvider provider, TimeSpanStyles styles)
{
TimeSpan result;
if (!TimeSpan.TryParseExact(value, format, provider, styles, out result))
return null;
return result;
}
开发者ID:brennanfee,项目名称:FluentConversions,代码行数:8,代码来源:TimeSpanStringParser.cs
示例2: 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
示例3: ParseExact
public TimeSpan ParseExact(IEnumerable<string> formats, TimeSpanStyles styles, TimeSpan defaultValue = default(TimeSpan))
{
return ParseExact(formats, CultureInfo.CurrentCulture, styles, defaultValue);
}
开发者ID:brennanfee,项目名称:FluentConversions,代码行数:4,代码来源:TimeSpanConversionsDefault.cs
示例4: TryParseExactHelper
void TryParseExactHelper (string input, string [] formats, bool error, string expected, IFormatProvider formatProvider = null,
TimeSpanStyles styles = TimeSpanStyles.None)
{
TimeSpan result;
bool success;
success = TimeSpan.TryParseExact (input, formats, formatProvider, styles, out result);
Assert.AreEqual (!error, success);
if (!error)
Assert.AreEqual (expected, result.ToString ());
}
开发者ID:Xtremrules,项目名称:dot42,代码行数:11,代码来源:TestTimeSpan.cs
示例5: 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
示例6: 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;
}
}
开发者ID:kouvel,项目名称:coreclr,代码行数:13,代码来源:TimeSpanParse.cs
示例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);
}
开发者ID:kouvel,项目名称:coreclr,代码行数:48,代码来源:TimeSpanParse.cs
示例8: 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
示例9: TryParseTimeSpanExactMultiple
public static Boolean TryParseTimeSpanExactMultiple(String value, String[] formats, IFormatProvider provider, TimeSpanStyles styles, out TimeSpan result)
{
return FormatProvider.TimeSpanParse.TryParseExactMultiple(value, formats, provider, styles, out result);
}
开发者ID:tijoytom,项目名称:corert,代码行数:4,代码来源:FormatProvider.cs
示例10: ParseTimeSpanExact
public static TimeSpan ParseTimeSpanExact(String value, String format, IFormatProvider provider, TimeSpanStyles styles)
{
return FormatProvider.TimeSpanParse.ParseExact(value, format, provider, styles);
}
开发者ID:tijoytom,项目名称:corert,代码行数:4,代码来源:FormatProvider.cs
示例11: TryParseExactDefault
public static TimeSpan TryParseExactDefault(string value, IEnumerable<string> formats, IFormatProvider provider, TimeSpanStyles styles, TimeSpan defaultValue)
{
TimeSpan result;
return !TimeSpan.TryParseExact(value, formats.ToArray(), provider, styles, out result) ? defaultValue : result;
}
开发者ID:brennanfee,项目名称:FluentConversions,代码行数:5,代码来源:TimeSpanStringParser.cs
示例12: ParseExactCulture
public TimeSpan ParseExactCulture(IEnumerable<string> formats, TimeSpanStyles styles = TimeSpanStyles.None)
{
return ParseExact(formats, CultureInfo.CurrentCulture, styles);
}
开发者ID:brennanfee,项目名称:FluentConversions,代码行数:4,代码来源:TimeSpanConversionsStandard.cs
示例13: ParseExact
public TimeSpan ParseExact(IEnumerable<string> formats, IFormatProvider provider, TimeSpanStyles styles = TimeSpanStyles.None)
{
return TimeSpan.ParseExact(_input, formats.ToArray(), provider, styles);
}
开发者ID:brennanfee,项目名称:FluentConversions,代码行数:4,代码来源:TimeSpanConversionsStandard.cs
示例14: 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
示例15: ParseExactCulture
public TimeSpan ParseExactCulture(string format, TimeSpanStyles styles, TimeSpan defaultValue = default(TimeSpan))
{
return ParseExact(format, CultureInfo.CurrentCulture, styles, defaultValue);
}
开发者ID:brennanfee,项目名称:FluentConversions,代码行数:4,代码来源:TimeSpanConversionsDefault.cs
示例16: ParseExact
public TimeSpan? ParseExact(IEnumerable<string> formats, IFormatProvider provider, TimeSpanStyles styles = TimeSpanStyles.None)
{
return TimeSpanStringParser.TryParseExactNullable(_input, formats, provider, styles);
}
开发者ID:brennanfee,项目名称:FluentConversions,代码行数:4,代码来源:TimeSpanConversionsNullable.cs
示例17: ParseTimeSpanExactMultiple
public static TimeSpan ParseTimeSpanExactMultiple(String value, String[] formats, IFormatProvider provider, TimeSpanStyles styles)
{
return FormatProvider.TimeSpanParse.ParseExactMultiple(value, formats, provider, styles);
}
开发者ID:tijoytom,项目名称:corert,代码行数:4,代码来源:FormatProvider.cs
示例18: ParseExactCulture
public TimeSpan? ParseExactCulture(string format, TimeSpanStyles styles = TimeSpanStyles.None)
{
return ParseExact(format, CultureInfo.CurrentCulture, styles);
}
开发者ID:brennanfee,项目名称:FluentConversions,代码行数:4,代码来源:TimeSpanConversionsNullable.cs
示例19: ToTimeSpanExact
/// <summary>
/// 将字符串分析为Timespan
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static TimeSpan ToTimeSpanExact(this string value, string[] format, IFormatProvider formatProvider = null, TimeSpanStyles styles = TimeSpanStyles.None)
{
TimeSpan ts;
if (TimeSpan.TryParseExact(value, format, formatProvider, styles, out ts))
return ts;
return TimeSpan.Zero;
}
开发者ID:iraychen,项目名称:FSLib.Extension,代码行数:13,代码来源:FishStringExtension.cs
示例20: ParseExactInvariant
public TimeSpan? ParseExactInvariant(string format, TimeSpanStyles styles = TimeSpanStyles.None)
{
return ParseExact(format, CultureInfo.InvariantCulture, styles);
}
开发者ID:brennanfee,项目名称:FluentConversions,代码行数:4,代码来源:TimeSpanConversionsNullable.cs
注:本文中的TimeSpanStyles类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论