本文整理汇总了C#中System.Globalization.PersianCalendar.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# PersianCalendar.GetType方法的具体用法?C# PersianCalendar.GetType怎么用?C# PersianCalendar.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Globalization.PersianCalendar
的用法示例。
在下文中一共展示了PersianCalendar.GetType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPersianCulture
public static CultureInfo GetPersianCulture()
{
//*****************************************************************************
//*****************************2008-04-02 By A. Samarian*****Begin*************
//Modified:2010-09-18
//Modified by: Asad Samarian
//*****************************************************************************
CultureInfo persianCulture = new CultureInfo("fa-IR");
DateTimeFormatInfo info = persianCulture.DateTimeFormat;
info.DayNames = new string[] { "یکشنبه", "دوشنبه", "ﺳﻪشنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه" };
info.AbbreviatedDayNames = new string[] { "ی", "د", "س", "چ", "پ", "ج", "ش" };
info.MonthNames = new string[] { "فروردین", "ارديبهشت", "خرداد", "تير", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند", "" };
info.AbbreviatedMonthNames = new string[] { "فروردین", "ارديبهشت", "خرداد", "تير", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند", "" };
//It Seems .NET 4 use Genitive manes for months.
info.MonthGenitiveNames = new string[] { "فروردین", "ارديبهشت", "خرداد", "تير", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند", "" };
info.AbbreviatedMonthGenitiveNames = new string[] { "فروردین", "ارديبهشت", "خرداد", "تير", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند", "" };
info.AMDesignator = "ق.ظ";
info.PMDesignator = "ب.ظ";
info.ShortDatePattern = "yyyy/MM/dd";
info.LongDatePattern = "dddd dd MMMM yyyy";
info.FullDateTimePattern = "dddd dd MMMM yyyy, HH:mm:ss";
info.FirstDayOfWeek = DayOfWeek.Saturday;
PersianCalendar cal = new PersianCalendar();
// 2010-07-18 this part throws an error under .NET 4, Asad says it is still needed for 3.5
if (ConfigHelper.GetBoolProperty("UseNet35PersianHelper", false)) //this setting is true in the We.config for 3.5 .NET but not 4.0
{
typeof(DateTimeFormatInfo).GetField("calendar", BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic).SetValue(info, cal);
object obj = typeof(DateTimeFormatInfo).GetField("m_cultureTableRecord",
BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic).GetValue(info);
obj.GetType().GetMethod("UseCurrentCalendar",
BindingFlags.NonPublic | BindingFlags.Instance).Invoke(obj, new object[] { cal.GetType().GetProperty("ID", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(cal, null) });
//typeof(DateTimeFormatInfo).GetField("calendar", BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic).SetValue(info, cal);
//typeof(CultureInfo).GetField("calendar", BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic).SetValue(persianCulture, cal);
}
typeof(DateTimeFormatInfo).GetField("calendar", BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic).SetValue(info, cal);
typeof(CultureInfo).GetField("calendar", (BindingFlags.NonPublic | (BindingFlags.Public | BindingFlags.Instance))).SetValue(persianCulture, cal);
persianCulture.DateTimeFormat = info;
persianCulture.NumberFormat.CurrencyDecimalDigits = 0;
return persianCulture;
//*****************************************************************************
//*************************2008-04-02 By A. Samarian*****End*******************
//Modified:2010-09-18
//Modified by: Asad Samarian
//*****************************************************************************
}
示例2: SetPersianCalendar
public static void SetPersianCalendar()
{
CultureInfo info = new CultureInfo("fa-IR")
{
NumberFormat = { DigitSubstitution = DigitShapes.NativeNational }
};
DateTimeFormatInfo dateTimeFormat = info.DateTimeFormat;
dateTimeFormat.AMDesignator = "ق.ظ";
dateTimeFormat.PMDesignator = "ب.ظ";
dateTimeFormat.DateSeparator = "/";
dateTimeFormat.ShortDatePattern = "yyyy/MM/dd";
dateTimeFormat.FirstDayOfWeek = DayOfWeek.Saturday;
dateTimeFormat.AbbreviatedDayNames = new[] { "ی", "د", "س", "چ", "پ", "ج", "ش" };
dateTimeFormat.DayNames = new[] { "یکشنبه", "دوشنبه", "سهشنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه" };
dateTimeFormat.MonthGenitiveNames = new[] { "فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند", "" };
dateTimeFormat.ShortestDayNames = new[] { "ی", "د", "س", "چ", "پ", "ج", "ش" };
dateTimeFormat.AbbreviatedMonthNames = new[] { "فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند", "" };
dateTimeFormat.MonthNames = new[] { "فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند", "" };
PersianCalendar calendar = new PersianCalendar();
typeof(DateTimeFormatInfo).GetField("calendar", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance).SetValue(dateTimeFormat, calendar);
object obj2 = typeof(DateTimeFormatInfo).GetField("m_cultureTableRecord", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance).GetValue(dateTimeFormat);
obj2.GetType().GetMethod("UseCurrentCalendar", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(obj2, new[] { calendar.GetType().GetProperty("ID", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(calendar, null) });
typeof(CultureInfo).GetField("calendar", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance).SetValue(info, calendar);
Thread.CurrentThread.CurrentCulture = info;
Thread.CurrentThread.CurrentUICulture = info;
CultureInfo.CurrentCulture.DateTimeFormat = dateTimeFormat;
CultureInfo.CurrentUICulture.DateTimeFormat = dateTimeFormat;
}