本文整理匯總了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);
}