当前位置: 首页>>代码示例>>C#>>正文


C# PersianCalendar.GetType方法代码示例

本文整理汇总了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
            //*****************************************************************************
        }
开发者ID:saiesh86,项目名称:TravelBlog,代码行数:56,代码来源:CultureHelper.cs

示例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;
        }
开发者ID:sinaaslani,项目名称:kids.bmi.ir,代码行数:30,代码来源:PersianDateTimeFormatInfo.cs


注:本文中的System.Globalization.PersianCalendar.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。