public PersianCulture(string cultureName, bool useUserOverride)
            : base(cultureName, useUserOverride)
        {
            //Temporary Value for cal.
            cal = base.OptionalCalendars[0];

            //populating new list of optional calendars.
            var optionalCalendars = new List<Calendar>();
            optionalCalendars.AddRange(base.OptionalCalendars);
            optionalCalendars.Insert(0, new PersianCalendar());


            Type formatType = typeof(DateTimeFormatInfo);
            Type calendarType = typeof(Calendar);


            PropertyInfo idProperty = calendarType.GetProperty("ID", BindingFlags.Instance | BindingFlags.NonPublic);
            FieldInfo optionalCalendarfield = formatType.GetField("optionalCalendars",
                                                                  BindingFlags.Instance | BindingFlags.NonPublic);

            //populating new list of optional calendar ids
            var newOptionalCalendarIDs = new Int32[optionalCalendars.Count];
            for (int i = 0; i < newOptionalCalendarIDs.Length; i++)
                newOptionalCalendarIDs[i] = (Int32)idProperty.GetValue(optionalCalendars[i], null);

            optionalCalendarfield.SetValue(DateTimeFormat, newOptionalCalendarIDs);

            optionals = optionalCalendars.ToArray();
            cal = optionals[0];
            DateTimeFormat.Calendar = optionals[0];

            DateTimeFormat.MonthNames = new[] { "فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند", "" };
            DateTimeFormat.MonthGenitiveNames = new[] { "فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند", "" };
            DateTimeFormat.AbbreviatedMonthNames = new[] { "فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند", "" };
            DateTimeFormat.AbbreviatedMonthGenitiveNames = new[] { "فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند", "" };


            DateTimeFormat.AbbreviatedDayNames = new string[] { "ی", "د", "س", "چ", "پ", "ج", "ش" };
            DateTimeFormat.ShortestDayNames = new string[] { "ی", "د", "س", "چ", "پ", "ج", "ش" };
            DateTimeFormat.DayNames = new string[] { "یکشنبه", "دوشنبه", "ﺳﻪشنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه" };

            DateTimeFormat.AMDesignator = "ق.ظ";
            DateTimeFormat.PMDesignator = "ب.ظ";


            //DateTimeFormat.ShortDatePattern = "yyyy/MM/dd";
            //DateTimeFormat.LongDatePattern = "yyyy/MM/dd";

            //DateTimeFormat.SetAllDateTimePatterns(new[] { "yyyy/MM/dd" }, 'd');
            //DateTimeFormat.SetAllDateTimePatterns(new[] { "dddd, dd MMMM yyyy" }, 'D');
            //DateTimeFormat.SetAllDateTimePatterns(new[] { "yyyy MMMM" }, 'y');
            //DateTimeFormat.SetAllDateTimePatterns(new[] { "yyyy MMMM" }, 'Y');


        }
	protected override void SetUp() {
		gcal = new GregorianCalendar();
		jucal = new JulianCalendar();
		hical = new HijriCalendar();
		hecal = new HebrewCalendar();
		jacal = new JapaneseCalendar();
		tacal = new TaiwanCalendar();
		kcal = new KoreanCalendar();
		tbcal = new ThaiBuddhistCalendar();
		acal = new Calendar[] {
			gcal, jucal, hical, hecal, jacal,
			tacal, kcal, tbcal};
	}
示例#3
0
	protected void SetUp() {
		gcal = new GregorianCalendar();
		jucal = new JulianCalendar();
		hical = new HijriCalendar();
		hecal = new HebrewCalendar();
		jacal = new JapaneseCalendar();
		tacal = new TaiwanCalendar();
		kcal = new KoreanCalendar();
		tbcal = new ThaiBuddhistCalendar();
		acal = new Calendar[] {
			gcal, jucal, hical, hecal, jacal,
			tacal, kcal, tbcal};
#if NET_2_0
		clcal = new ChineseLunisolarCalendar ();
		tlcal = new TaiwanLunisolarCalendar ();
		jlcal = new JapaneseLunisolarCalendar ();
		klcal = new KoreanLunisolarCalendar ();
#endif
	}
示例#4
0
		unsafe internal void ConstructCalendars ()
		{
			if (calendar_data == null) {
				optional_calendars = new Calendar [] {new GregorianCalendar (GregorianCalendarTypes.Localized)};
				return;
			}

			optional_calendars = new Calendar [NumOptionalCalendars];

			for (int i=0; i<NumOptionalCalendars; i++) {
				Calendar cal = null;
				int caldata = *(calendar_data + i);
				int caltype = (caldata >> CalendarTypeBits);
				switch (caltype) {
				case 0:
					GregorianCalendarTypes greg_type;
					greg_type = (GregorianCalendarTypes) (caldata & GregorianTypeMask);
					cal = new GregorianCalendar (greg_type);
					break;
				case 1:
					cal = new HijriCalendar ();
					break;
				case 2:
					cal = new ThaiBuddhistCalendar ();
					break;
				default:
					throw new Exception ("invalid calendar type:  " + caldata);
				}
				optional_calendars [i] = cal;
			}
		}
示例#5
0
	public CultureAndRegionInfoBuilder(CultureInfo templateCulture,
									   Object templateRegion,
									   String language, String region,
									   String suffix, CulturePrefix prefix)
#endif
			{
				if(templateCulture == null)
				{
					throw new ArgumentNullException("templateCulture");
				}
				if(templateRegion == null)
				{
					throw new ArgumentNullException("templateRegion");
				}

				// Copy the original property values out of the templates.
				availableCalendars = templateCulture.OptionalCalendars;
				consoleFallbackUICulture = templateCulture;
				cultureName = templateCulture.Name;
				dateTimeFormat = templateCulture.DateTimeFormat;
				isNeutralCulture = templateCulture.IsNeutralCulture;
			#if CONFIG_REFLECTION
				lcid = templateCulture.LCID;
			#else
				lcid = templateCulture.GetHashCode();
			#endif
				numberFormat = templateCulture.NumberFormat;
				parent = templateCulture.Parent;
				textInfo = templateCulture.TextInfo;
			#if CONFIG_FRAMEWORK_1_2
				keyboardLayoutID = templateCulture.KeyboardLayoutID;
				//lineOrientation = templateCulture.LineOrientation; // TODO
			#endif
			#if CONFIG_REFLECTION
				cultureEnglishName = templateCulture.EnglishName;
				cultureNativeName = templateCulture.NativeName;
				threeLetterISOLanguageName =
					templateCulture.ThreeLetterISOLanguageName;
				threeLetterWindowsLanguageName =
					templateCulture.ThreeLetterWindowsLanguageName;
				twoLetterISOLanguageName =
					templateCulture.TwoLetterISOLanguageName;
			#endif
			#if !ECMA_COMPAT
			#if CONFIG_FRAMEWORK_2_0
				geoId = templateRegion.GeoId;
			#else
				geoId = templateRegion.GetHashCode();
			#endif
			#if CONFIG_FRAMEWORK_2_0
				currencyEnglishName = templateRegion.CurrencyEnglishName;
				currencyNativeName = templateRegion.CurrencyNativeName;
			#endif
				currencySymbol = templateRegion.CurrencySymbol;
				isMetric = templateRegion.IsMetric;
				isoCurrencySymbol = templateRegion.ISOCurrencySymbol;
				regionEnglishName = templateRegion.EnglishName;
				regionName = templateRegion.Name;
				regionNativeName = templateRegion.DisplayName;
				threeLetterISORegionName =
					templateRegion.ThreeLetterISORegionName;
				threeLetterWindowsRegionName =
					templateRegion.ThreeLetterWindowsRegionName;
				twoLetterISORegionName =
					templateRegion.TwoLetterISORegionName;
			#endif

				// Override the names if necessary.
				String prefixValue;
				if(prefix == CulturePrefix.IANA)
				{
					prefixValue = "i-";
				}
				else if(prefix == CulturePrefix.PrivateUse)
				{
					prefixValue = "x-";
				}
				else
				{
					prefixValue = "";
				}
				if(language == null || language.Length == 0)
				{
					language = cultureName;
				}
				cultureName = prefixValue + language + suffix;
			#if CONFIG_REFLECTION
				cultureEnglishName = cultureName;
				cultureNativeName = cultureName;
			#endif
			#if !ECMA_COMPAT
				if(region == null || region.Length == 0)
				{
					region = regionName;
				}
				regionName = prefixValue + region + suffix;
				regionEnglishName = regionName;
				regionNativeName = regionName;
			#endif
			}