本文整理汇总了C#中CalendarId类的典型用法代码示例。如果您正苦于以下问题:C# CalendarId类的具体用法?C# CalendarId怎么用?C# CalendarId使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CalendarId类属于命名空间,在下文中一共展示了CalendarId类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetCalendars
internal static int GetCalendars(string localeName, bool useUserOverride, CalendarId[] calendars)
{
// NOTE: there are no 'user overrides' on Linux
int count = Interop.GlobalizationInterop.GetCalendars(localeName, calendars, calendars.Length);
// ensure there is at least 1 calendar returned
if (count == 0 && calendars.Length > 0)
{
calendars[0] = CalendarId.GREGORIAN;
count = 1;
}
return count;
}
开发者ID:kouvel,项目名称:coreclr,代码行数:14,代码来源:CalendarData.Unix.cs
示例2: LoadCalendarDataFromSystem
private bool LoadCalendarDataFromSystem(String localeName, CalendarId calendarId)
{
bool result = true;
result &= GetCalendarInfo(localeName, calendarId, CalendarDataType.NativeName, out this.sNativeName);
result &= GetCalendarInfo(localeName, calendarId, CalendarDataType.MonthDay, out this.sMonthDay);
this.sMonthDay = NormalizeDatePattern(this.sMonthDay);
result &= EnumDatePatterns(localeName, calendarId, CalendarDataType.ShortDates, out this.saShortDates);
result &= EnumDatePatterns(localeName, calendarId, CalendarDataType.LongDates, out this.saLongDates);
result &= EnumDatePatterns(localeName, calendarId, CalendarDataType.YearMonths, out this.saYearMonths);
result &= EnumCalendarInfo(localeName, calendarId, CalendarDataType.DayNames, out this.saDayNames);
result &= EnumCalendarInfo(localeName, calendarId, CalendarDataType.AbbrevDayNames, out this.saAbbrevDayNames);
result &= EnumCalendarInfo(localeName, calendarId, CalendarDataType.SuperShortDayNames, out this.saSuperShortDayNames);
result &= EnumMonthNames(localeName, calendarId, CalendarDataType.MonthNames, out this.saMonthNames);
result &= EnumMonthNames(localeName, calendarId, CalendarDataType.AbbrevMonthNames, out this.saAbbrevMonthNames);
result &= EnumMonthNames(localeName, calendarId, CalendarDataType.MonthGenitiveNames, out this.saMonthGenitiveNames);
result &= EnumMonthNames(localeName, calendarId, CalendarDataType.AbbrevMonthGenitiveNames, out this.saAbbrevMonthGenitiveNames);
result &= EnumEraNames(localeName, calendarId, CalendarDataType.EraNames, out this.saEraNames);
result &= EnumEraNames(localeName, calendarId, CalendarDataType.AbbrevEraNames, out this.saAbbrevEraNames);
return result;
}
开发者ID:kouvel,项目名称:coreclr,代码行数:22,代码来源:CalendarData.Unix.cs
示例3: InitializeEraNames
private void InitializeEraNames(string localeName, CalendarId calendarId)
{
// Note that the saEraNames only include "A.D." We don't have localized names for other calendars available from windows
switch (calendarId)
{
// For Localized Gregorian we really expect the data from the OS.
case CalendarId.GREGORIAN:
// Fallback for CoreCLR < Win7 or culture.dll missing
if (this.saEraNames == null || this.saEraNames.Length == 0 || String.IsNullOrEmpty(this.saEraNames[0]))
{
this.saEraNames = new String[] { "A.D." };
}
break;
// The rest of the calendars have constant data, so we'll just use that
case CalendarId.GREGORIAN_US:
case CalendarId.JULIAN:
this.saEraNames = new String[] { "A.D." };
break;
case CalendarId.HEBREW:
this.saEraNames = new String[] { "C.E." };
break;
case CalendarId.HIJRI:
case CalendarId.UMALQURA:
if (localeName == "dv-MV")
{
// Special case for Divehi
this.saEraNames = new String[] { "\x0780\x07a8\x0796\x07b0\x0783\x07a9" };
}
else
{
this.saEraNames = new String[] { "\x0628\x0639\x062F \x0627\x0644\x0647\x062C\x0631\x0629" };
}
break;
case CalendarId.GREGORIAN_ARABIC:
case CalendarId.GREGORIAN_XLIT_ENGLISH:
case CalendarId.GREGORIAN_XLIT_FRENCH:
// These are all the same:
this.saEraNames = new String[] { "\x0645" };
break;
case CalendarId.GREGORIAN_ME_FRENCH:
this.saEraNames = new String[] { "ap. J.-C." };
break;
case CalendarId.TAIWAN:
if (SystemSupportsTaiwaneseCalendar())
{
this.saEraNames = new String[] { "\x4e2d\x83ef\x6c11\x570b" };
}
else
{
this.saEraNames = new String[] { String.Empty };
}
break;
case CalendarId.KOREA:
this.saEraNames = new String[] { "\xb2e8\xae30" };
break;
case CalendarId.THAI:
this.saEraNames = new String[] { "\x0e1e\x002e\x0e28\x002e" };
break;
case CalendarId.JAPAN:
case CalendarId.JAPANESELUNISOLAR:
this.saEraNames = JapaneseCalendar.EraNames();
break;
case CalendarId.PERSIAN:
if (this.saEraNames == null || this.saEraNames.Length == 0 || String.IsNullOrEmpty(this.saEraNames[0]))
{
this.saEraNames = new String[] { "\x0647\x002e\x0634" };
}
break;
default:
// Most calendars are just "A.D."
this.saEraNames = Invariant.saEraNames;
break;
}
}
开发者ID:noahfalk,项目名称:corert,代码行数:82,代码来源:CalendarData.cs
示例4: GetCalendarMonthInfo
////////////////////////////////////////////////////////////////////////
//
// Get the native month names
//
// Parameters:
// OUT pOutputStrings The output string[] value.
//
////////////////////////////////////////////////////////////////////////
private static bool GetCalendarMonthInfo(string localeName, CalendarId calendar, uint calType, out string[] outputStrings)
{
//
// We'll need a new array of 13 items
//
string[] results = new string[13];
// Get each one of them
for (int i = 0; i < 13; i++, calType++)
{
if (!CallGetCalendarInfoEx(localeName, calendar, calType, out results[i]))
results[i] = "";
}
outputStrings = results;
return true;
}
开发者ID:niemyjski,项目名称:corert,代码行数:26,代码来源:CalendarData.Win32.cs
示例5: CallEnumCalendarInfo
private static unsafe bool CallEnumCalendarInfo(string localeName, CalendarId calendar, uint calType, uint lcType, out string[] data)
{
EnumData context = new EnumData();
context.userOverride = null;
context.strings = new LowLevelList<string>();
// First call GetLocaleInfo if necessary
if (((lcType != 0) && ((lcType & CAL_NOUSEROVERRIDE) == 0)) &&
// Get user locale, see if it matches localeName.
// Note that they should match exactly, including letter case
GetUserDefaultLocaleName() == localeName)
{
// They want user overrides, see if the user calendar matches the input calendar
CalendarId userCalendar = (CalendarId)Interop.mincore.GetLocaleInfoExInt(localeName, LOCALE_ICALENDARTYPE);
// If the calendars were the same, see if the locales were the same
if (userCalendar == calendar)
{
// They matched, get the user override since locale & calendar match
string res = Interop.mincore.GetLocaleInfoEx(localeName, lcType);
// if it succeeded remember the override for the later callers
if (res != "")
{
// Remember this was the override (so we can look for duplicates later in the enum function)
context.userOverride = res;
// Add to the result strings.
context.strings.Add(res);
}
}
}
GCHandle contextHandle = GCHandle.Alloc(context);
try
{
Interop.mincore_private.EnumCalendarInfoExExCallback callback = new Interop.mincore_private.EnumCalendarInfoExExCallback(EnumCalendarInfoCallback);
Interop.mincore_private.LParamCallbackContext ctx = new Interop.mincore_private.LParamCallbackContext();
ctx.lParam = (IntPtr)contextHandle;
// Now call the enumeration API. Work is done by our callback function
Interop.mincore_private.EnumCalendarInfoExEx(callback, localeName, (uint)calendar, null, calType, ctx);
}
finally
{
contextHandle.Free();
}
// Now we have a list of data, fail if we didn't find anything.
if (context.strings.Count == 0)
{
data = null;
return false;
}
string[] output = context.strings.ToArray();
if (calType == CAL_SABBREVERASTRING || calType == CAL_SERASTRING)
{
// Eras are enumerated backwards. (oldest era name first, but
// Japanese calendar has newest era first in array, and is only
// calendar with multiple eras)
Array.Reverse(output, 0, output.Length);
}
data = output;
return true;
}
开发者ID:niemyjski,项目名称:corert,代码行数:69,代码来源:CalendarData.Win32.cs
示例6: CallGetCalendarInfoEx
private static bool CallGetCalendarInfoEx(string localeName, CalendarId calendar, uint calType, out int data)
{
return (Interop.mincore.GetCalendarInfoEx(localeName, (uint)calendar, IntPtr.Zero, calType | CAL_RETURN_NUMBER, IntPtr.Zero, 0, out data) != 0);
}
开发者ID:niemyjski,项目名称:corert,代码行数:4,代码来源:CalendarData.Win32.cs
示例7: CalendarIdToCultureName
private static String CalendarIdToCultureName(CalendarId calendarId)
{
switch (calendarId)
{
case CalendarId.GREGORIAN_US:
return "fa-IR"; // "fa-IR" Iran
case CalendarId.JAPAN:
return "ja-JP"; // "ja-JP" Japan
case CalendarId.TAIWAN:
return "zh-TW"; // zh-TW Taiwan
case CalendarId.KOREA:
return "ko-KR"; // "ko-KR" Korea
case CalendarId.HIJRI:
case CalendarId.GREGORIAN_ARABIC:
case CalendarId.UMALQURA:
return "ar-SA"; // "ar-SA" Saudi Arabia
case CalendarId.THAI:
return "th-TH"; // "th-TH" Thailand
case CalendarId.HEBREW:
return "he-IL"; // "he-IL" Israel
case CalendarId.GREGORIAN_ME_FRENCH:
return "ar-DZ"; // "ar-DZ" Algeria
case CalendarId.GREGORIAN_XLIT_ENGLISH:
case CalendarId.GREGORIAN_XLIT_FRENCH:
return "ar-IQ"; // "ar-IQ"; Iraq
default:
// Default to gregorian en-US
break;
}
return "en-US";
}
开发者ID:niemyjski,项目名称:corert,代码行数:41,代码来源:CalendarData.Win32.cs
示例8: LoadCalendarDataFromSystem
private bool LoadCalendarDataFromSystem(String localeName, CalendarId calendarId)
{
bool ret = true;
uint useOverrides = this.bUseUserOverrides ? 0 : CAL_NOUSEROVERRIDE;
//
// Windows doesn't support some calendars right now, so remap those.
//
switch (calendarId)
{
case CalendarId.JAPANESELUNISOLAR: // Data looks like Japanese
calendarId = CalendarId.JAPAN;
break;
case CalendarId.JULIAN: // Data looks like gregorian US
case CalendarId.CHINESELUNISOLAR: // Algorithmic, so actual data is irrelevent
case CalendarId.SAKA: // reserved to match Office but not implemented in our code, so data is irrelevent
case CalendarId.LUNAR_ETO_CHN: // reserved to match Office but not implemented in our code, so data is irrelevent
case CalendarId.LUNAR_ETO_KOR: // reserved to match Office but not implemented in our code, so data is irrelevent
case CalendarId.LUNAR_ETO_ROKUYOU: // reserved to match Office but not implemented in our code, so data is irrelevent
case CalendarId.KOREANLUNISOLAR: // Algorithmic, so actual data is irrelevent
case CalendarId.TAIWANLUNISOLAR: // Algorithmic, so actual data is irrelevent
calendarId = CalendarId.GREGORIAN_US;
break;
}
//
// Special handling for some special calendar due to OS limitation.
// This includes calendar like Taiwan calendar, UmAlQura calendar, etc.
//
CheckSpecialCalendar(ref calendarId, ref localeName);
// Numbers
ret &= CallGetCalendarInfoEx(localeName, calendarId, CAL_ITWODIGITYEARMAX | useOverrides, out this.iTwoDigitYearMax);
// Strings
ret &= CallGetCalendarInfoEx(localeName, calendarId, CAL_SCALNAME, out this.sNativeName);
ret &= CallGetCalendarInfoEx(localeName, calendarId, CAL_SMONTHDAY | useOverrides, out this.sMonthDay);
// String Arrays
// Formats
ret &= CallEnumCalendarInfo(localeName, calendarId, CAL_SSHORTDATE, LOCALE_SSHORTDATE | useOverrides, out this.saShortDates);
ret &= CallEnumCalendarInfo(localeName, calendarId, CAL_SLONGDATE, LOCALE_SLONGDATE | useOverrides, out this.saLongDates);
// Get the YearMonth pattern.
ret &= CallEnumCalendarInfo(localeName, calendarId, CAL_SYEARMONTH, LOCALE_SYEARMONTH, out this.saYearMonths);
// Day & Month Names
// These are all single calType entries, 1 per day, so we have to make 7 or 13 calls to collect all the names
// Day
// Note that we're off-by-one since managed starts on sunday and windows starts on monday
ret &= GetCalendarDayInfo(localeName, calendarId, CAL_SDAYNAME7, out this.saDayNames);
ret &= GetCalendarDayInfo(localeName, calendarId, CAL_SABBREVDAYNAME7, out this.saAbbrevDayNames);
// Month names
ret &= GetCalendarMonthInfo(localeName, calendarId, CAL_SMONTHNAME1, out this.saMonthNames);
ret &= GetCalendarMonthInfo(localeName, calendarId, CAL_SABBREVMONTHNAME1, out this.saAbbrevMonthNames);
//
// The following LCTYPE are not supported in some platforms. If the call fails,
// don't return a failure.
//
GetCalendarDayInfo(localeName, calendarId, CAL_SSHORTESTDAYNAME7, out this.saSuperShortDayNames);
// Gregorian may have genitive month names
if (calendarId == CalendarId.GREGORIAN)
{
GetCalendarMonthInfo(localeName, calendarId, CAL_SMONTHNAME1 | CAL_RETURN_GENITIVE_NAMES, out this.saMonthGenitiveNames);
GetCalendarMonthInfo(localeName, calendarId, CAL_SABBREVMONTHNAME1 | CAL_RETURN_GENITIVE_NAMES, out this.saAbbrevMonthGenitiveNames);
}
// Calendar Parts Names
// This doesn't get always get localized names for gregorian (not available in windows < 7)
// so: eg: coreclr on win < 7 won't get these
CallEnumCalendarInfo(localeName, calendarId, CAL_SERASTRING, 0, out this.saEraNames);
CallEnumCalendarInfo(localeName, calendarId, CAL_SABBREVERASTRING, 0, out this.saAbbrevEraNames);
//
// Calendar Era Info
// Note that calendar era data (offsets, etc) is hard coded for each calendar since this
// data is implementation specific and not dynamic (except perhaps Japanese)
//
// Clean up the escaping of the formats
this.saShortDates = CultureData.ReescapeWin32Strings(this.saShortDates);
this.saLongDates = CultureData.ReescapeWin32Strings(this.saLongDates);
this.saYearMonths = CultureData.ReescapeWin32Strings(this.saYearMonths);
this.sMonthDay = CultureData.ReescapeWin32String(this.sMonthDay);
return ret;
}
开发者ID:niemyjski,项目名称:corert,代码行数:92,代码来源:CalendarData.Win32.cs
示例9: AbbreviatedGenitiveMonthNames
// Genitive month names
internal string[] AbbreviatedGenitiveMonthNames(CalendarId calendarId)
{
return GetCalendar(calendarId).saAbbrevMonthGenitiveNames;
}
开发者ID:kyulee1,项目名称:corert,代码行数:5,代码来源:CultureData.cs
示例10: GenitiveMonthNames
// Genitive month names
internal string[] GenitiveMonthNames(CalendarId calendarId)
{
return GetCalendar(calendarId).saMonthGenitiveNames;
}
开发者ID:kyulee1,项目名称:corert,代码行数:5,代码来源:CultureData.cs
示例11: MonthNames
// month names
internal string[] MonthNames(CalendarId calendarId)
{
return GetCalendar(calendarId).saMonthNames;
}
开发者ID:kyulee1,项目名称:corert,代码行数:5,代码来源:CultureData.cs
示例12: SuperShortDayNames
// The super short day names
internal string[] SuperShortDayNames(CalendarId calendarId)
{
return GetCalendar(calendarId).saSuperShortDayNames;
}
开发者ID:kyulee1,项目名称:corert,代码行数:5,代码来源:CultureData.cs
示例13: AbbreviatedDayNames
// abbreviated day names
internal string[] AbbreviatedDayNames(CalendarId calendarId)
{
// Get abbreviated day names for this calendar from the OS if necessary
return GetCalendar(calendarId).saAbbrevDayNames;
}
开发者ID:kyulee1,项目名称:corert,代码行数:6,代码来源:CultureData.cs
示例14: DayNames
// day names
internal string[] DayNames(CalendarId calendarId)
{
return GetCalendar(calendarId).saDayNames;
}
开发者ID:kyulee1,项目名称:corert,代码行数:5,代码来源:CultureData.cs
示例15: YearMonths
// (user can override) date year/month format.
internal String[] YearMonths(CalendarId calendarId)
{
return GetCalendar(calendarId).saYearMonths;
}
开发者ID:kyulee1,项目名称:corert,代码行数:5,代码来源:CultureData.cs
示例16: GetTwoDigitYearMax
// Get native two digit year max
internal static int GetTwoDigitYearMax(CalendarId calendarId)
{
int twoDigitYearMax = -1;
if (!CallGetCalendarInfoEx(null, calendarId, (uint)CAL_ITWODIGITYEARMAX, out twoDigitYearMax))
{
twoDigitYearMax = -1;
}
return twoDigitYearMax;
}
开发者ID:niemyjski,项目名称:corert,代码行数:12,代码来源:CalendarData.Win32.cs
示例17: GetCalendarData
internal static CalendarData GetCalendarData(CalendarId calendarId)
{
//
// Get a calendar.
// Unfortunately we depend on the locale in the OS, so we need a locale
// no matter what. So just get the appropriate calendar from the
// appropriate locale here
//
// Get a culture name
// TODO: Note that this doesn't handle the new calendars (lunisolar, etc)
String culture = CalendarIdToCultureName(calendarId);
// Return our calendar
return CultureInfo.GetCultureInfo(culture).m_cultureData.GetCalendar(calendarId);
}
开发者ID:niemyjski,项目名称:corert,代码行数:16,代码来源:CalendarData.Win32.cs
示例18: LeapYearMonthNames
// Leap year month names
// Note: This only applies to Hebrew, and it basically adds a "1" to the 6th month name
// the non-leap names skip the 7th name in the normal month name array
internal string[] LeapYearMonthNames(CalendarId calendarId)
{
return GetCalendar(calendarId).saLeapYearMonthNames;
}
开发者ID:kyulee1,项目名称:corert,代码行数:7,代码来源:CultureData.cs
示例19: GetCalendars
// Call native side to figure out which calendars are allowed
internal static int GetCalendars(String localeName, bool useUserOverride, CalendarId[] calendars)
{
EnumCalendarsData data = new EnumCalendarsData();
data.userOverride = 0;
data.calendars = new LowLevelList<int>();
// First call GetLocaleInfo if necessary
if (useUserOverride)
{
// They want user overrides, see if the user calendar matches the input calendar
int userCalendar = Interop.mincore.GetLocaleInfoExInt(localeName, LOCALE_ICALENDARTYPE);
// If we got a default, then use it as the first calendar
if (userCalendar != 0)
{
data.userOverride = userCalendar;
data.calendars.Add(userCalendar);
}
}
GCHandle contextHandle = GCHandle.Alloc(data);
try
{
Interop.mincore_private.EnumCalendarInfoExExCallback callback = new Interop.mincore_private.EnumCalendarInfoExExCallback(EnumCalendarsCallback);
Interop.mincore_private.LParamCallbackContext context = new Interop.mincore_private.LParamCallbackContext();
context.lParam = (IntPtr)contextHandle;
// Now call the enumeration API. Work is done by our callback function
Interop.mincore_private.EnumCalendarInfoExEx(callback, localeName, ENUM_ALL_CALENDARS, null, CAL_ICALINTVALUE, context);
}
finally
{
contextHandle.Free();
}
// Copy to the output array
for (int i = 0; i < Math.Min(calendars.Length, data.calendars.Count); i++)
calendars[i] = (CalendarId)data.calendars[i];
// Now we have a list of data, return the count
return data.calendars.Count;
}
开发者ID:niemyjski,项目名称:corert,代码行数:44,代码来源:CalendarData.Win32.cs
示例20: MonthDay
// month/day format (single string, no override)
internal String MonthDay(CalendarId calendarId)
{
return GetCalendar(calendarId).sMonthDay;
}
开发者ID:kyulee1,项目名称:corert,代码行数:5,代码来源:CultureData.cs
注:本文中的CalendarId类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论