本文整理汇总了C#中System.Globalization.CultureInfo.NullCheck方法的典型用法代码示例。如果您正苦于以下问题:C# CultureInfo.NullCheck方法的具体用法?C# CultureInfo.NullCheck怎么用?C# CultureInfo.NullCheck使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Globalization.CultureInfo
的用法示例。
在下文中一共展示了CultureInfo.NullCheck方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Singularize
/// <summary>
/// Singularizes a word
/// </summary>
/// <param name="Word">Word to singularize</param>
/// <param name="Culture">Culture info used to singularize the word (defaults to current culture)</param>
/// <returns>The word singularized</returns>
public static string Singularize(this string Word, CultureInfo Culture = null)
{
if (Word.IsNullOrEmpty())
return "";
Culture = Culture.NullCheck(CultureInfo.CurrentCulture);
return PluralizationService.CreateService(Culture).Singularize(Word);
}
示例2: FirstDayOfWeek
/// <summary>
/// Returns the first day of a week based on the date sent in
/// </summary>
/// <param name="Date">Date to get the first day of the week from</param>
/// <param name="CultureInfo">The culture to use (defaults to current culture)</param>
/// <returns>The first day of the week</returns>
public static DateTime FirstDayOfWeek(this DateTime Date,CultureInfo CultureInfo=null)
{
Date.ThrowIfNull("Date");
return Date.AddDays(CultureInfo.NullCheck(CultureInfo.CurrentCulture).DateTimeFormat.FirstDayOfWeek - Date.DayOfWeek).Date;
}
示例3: LastDayOfWeek
/// <summary>
/// Returns the last day of a week based on the date sent in
/// </summary>
/// <param name="Date">Date to get the last day of the week from</param>
/// <param name="CultureInfo">The culture to use (defaults to current culture)</param>
/// <returns>The last day of the week</returns>
public static DateTime LastDayOfWeek(this DateTime Date, CultureInfo CultureInfo = null)
{
Date.ThrowIfNull("Date");
return Date.FirstDayOfWeek(CultureInfo.NullCheck(CultureInfo.CurrentCulture)).AddDays(6);
}
示例4: Pluralize
/// <summary>
/// Pluralizes a word
/// </summary>
/// <param name="word">Word to pluralize</param>
/// <param name="culture">Culture info used to pluralize the word (defaults to current culture)</param>
/// <returns>The word pluralized</returns>
public static string Pluralize(this string word, CultureInfo culture = null)
{
if (word.IsNullOrEmpty())
return "";
culture = culture.NullCheck(CultureInfo.CurrentCulture);
return PluralizationService.CreateService(culture).Pluralize(word);
}