本文整理汇总了C#中System.Globalization.CultureInfo.GetOrCurrentCulture方法的典型用法代码示例。如果您正苦于以下问题:C# CultureInfo.GetOrCurrentCulture方法的具体用法?C# CultureInfo.GetOrCurrentCulture怎么用?C# CultureInfo.GetOrCurrentCulture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Globalization.CultureInfo
的用法示例。
在下文中一共展示了CultureInfo.GetOrCurrentCulture方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TimeFormatter
public TimeFormatter(CultureInfo culture,
string dateTimeFormat = null,
string shortDateFormat = null,
string longTimeFormat = null,
string shortTimeFormat = null,
string contextSeparator = DefaultContextSeparator,
string startEndSeparator = DefaultStartEndSeparator,
string durationSeparator = DefaultDurationSeparator,
DurationFormatKind durationFormatKind = DurationFormatKind.Compact,
bool useDurationSeconds = false,
bool useIsoIntervalNotation = false) {
Culture = culture.GetOrCurrentCulture();
DateTimeFormat = dateTimeFormat;
ShortDateFormat = shortDateFormat;
LongTimeFormat = longTimeFormat;
ShortTimeFormat = shortTimeFormat;
ContextSeparator = contextSeparator ?? DefaultContextSeparator;
StartEndSeparator = startEndSeparator ?? DefaultStartEndSeparator;
DurationSeparator = durationSeparator ?? DefaultDurationSeparator;
DurationKind = durationFormatKind;
UseDurationSeconds = useDurationSeconds;
UseIsoIntervalNotation = useIsoIntervalNotation;
}
示例2: GetCalendarWeekRuleAndFirstDayOfWeek
/// <summary>
/// <paramref name="weekOfYearRule"/> 에 따라 <paramref name="weekRule"/>과 <paramref name="firstDayOfWeek"/> 를 결정합니다.
/// </summary>
/// <param name="culture">문화권</param>
/// <param name="weekOfYearRule">주차 계산을 위한 룰</param>
/// <param name="weekRule">한해의 첫주를 산정하는 규칙</param>
/// <param name="firstDayOfWeek">한주의 첫번째 요일</param>
public static void GetCalendarWeekRuleAndFirstDayOfWeek(CultureInfo culture,
WeekOfYearRuleKind? weekOfYearRule,
out CalendarWeekRule weekRule,
out DayOfWeek firstDayOfWeek) {
if(weekOfYearRule.GetValueOrDefault(WeekOfYearRuleKind.Calendar) == WeekOfYearRuleKind.Calendar) {
weekRule = culture.GetOrCurrentCulture().DateTimeFormat.CalendarWeekRule;
firstDayOfWeek = culture.GetOrCurrentCulture().DateTimeFormat.FirstDayOfWeek;
}
else {
weekRule = CalendarWeekRule.FirstFourDayWeek;
firstDayOfWeek = DayOfWeek.Monday;
}
if(IsDebugEnabled)
log.Debug("WeekOfyearRuleKind에 따른 CalendarWeekRule, FirstDayOfWeek 정보를 결정했습니다!!! " +
@"culture=[{0}], weekOfYearRule=[{1}], weekRule=[{2}], firstDayOfWeek=[{3}]",
culture, weekOfYearRule, weekRule, firstDayOfWeek);
}
示例3: IsSameWeek
/// <summary>
/// 두 DateTime 값이 주(Week) 단위까지 같은지 판단합니다.
/// </summary>
public static bool IsSameWeek(this DateTime left, DateTime right, CultureInfo culture, CalendarWeekRule weekRule,
DayOfWeek firstDayOfWeek, WeekOfYearRuleKind weekOfYearRuleKind) {
culture = culture.GetOrCurrentCulture();
var leftYearWeek = GetWeekOfYear(left, culture, weekRule, firstDayOfWeek, weekOfYearRuleKind);
var rightYearWeek = GetWeekOfYear(right, culture, weekRule, firstDayOfWeek, weekOfYearRuleKind);
return Equals(leftYearWeek, rightYearWeek);
}
示例4: GetResources
/// <summary>
/// 지정한 문화권의 모든 리소스 정보를 Hashtable로 반환한다.
/// </summary>
public Hashtable GetResources(CultureInfo culture) {
if(IsDebugEnabled)
log.Debug("Get resources map... resourceType=[{0}], culture=[{1}]", ResourceName, culture);
var resourceMap = new Hashtable();
try {
culture = culture.GetOrCurrentCulture();
using(var cmd = GetResourcesCommand(culture.Name))
using(var reader = Ado.ExecuteReader(cmd)) {
while(reader.Read()) {
var key = reader.AsString("ResourceKey");
var value = reader.AsString("ResourceValue");
resourceMap.Add(key, value);
}
}
}
catch(Exception ex) {
if(log.IsErrorEnabled) {
log.Error("리소스를 얻는데 실패했습니다. culture=[{0}]", culture);
log.Error(ex);
}
throw;
}
return resourceMap;
}
示例5: GetFirstDayOfWeek
/// <summary>
/// 주차 계산 룰과 문화권에 따른 한주의 첫번째 요일을 구합니다.
/// </summary>
/// <param name="culture">문화권</param>
/// <param name="weekOfYearRule">주차 계산 룰</param>
/// <returns></returns>
public static DayOfWeek GetFirstDayOfWeek(CultureInfo culture = null,
WeekOfYearRuleKind? weekOfYearRule = null) {
return weekOfYearRule.GetValueOrDefault(WeekOfYearRuleKind.Calendar) == WeekOfYearRuleKind.Iso8601
? DayOfWeek.Monday
: culture.GetOrCurrentCulture().DateTimeFormat.FirstDayOfWeek;
}
示例6: GetCalendarWeekRule
/// <summary>
/// 주차 계산 룰과 문화권에 따른 주차 계산 룰을 구합니다.
/// </summary>
/// <param name="culture">문화권</param>
/// <param name="weekOfYearRule">주차 계산 룰</param>
/// <returns></returns>
public static CalendarWeekRule GetCalendarWeekRule(CultureInfo culture = null,
WeekOfYearRuleKind? weekOfYearRule = null) {
return weekOfYearRule.GetValueOrDefault(WeekOfYearRuleKind.Calendar) == WeekOfYearRuleKind.Iso8601
? CalendarWeekRule.FirstFourDayWeek
: culture.GetOrCurrentCulture().DateTimeFormat.CalendarWeekRule;
}