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


C# Calendar.GetType方法代码示例

本文整理汇总了C#中System.Globalization.Calendar.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Calendar.GetType方法的具体用法?C# Calendar.GetType怎么用?C# Calendar.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Globalization.Calendar的用法示例。


在下文中一共展示了Calendar.GetType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CalendarSystemForCalendar

 /// <summary>
 /// Tries to work out a roughly-matching calendar system for the given BCL calendar.
 /// This is needed where we're testing whether days of the week match - even if we can
 /// get day/month/year values to match without getting the calendar right, the calendar
 /// affects the day of week.
 /// </summary>
 internal static CalendarSystem CalendarSystemForCalendar(Calendar bcl)
 {
     // Yes, this is horrible... but the specific calendars aren't available to test
     // against in the PCL
     switch (bcl.GetType().Name)
     {
         case "GregorianCalendar": return CalendarSystem.Iso;
         case "HijriCalendar": return CalendarSystem.IslamicBcl;
         case "HebrewCalendar": return CalendarSystem.HebrewCivil;
         case "PersianCalendar": return bcl.IsLeapYear(1) ? CalendarSystem.PersianSimple : CalendarSystem.PersianAstronomical;
         case "UmAlQuraCalendar": return CalendarSystem.UmAlQura;
         case "JulianCalendar":
             return CalendarSystem.Julian;
         default:
             // No idea - we can't test with this calendar...
             return null;
     }
 }
开发者ID:ivandrofly,项目名称:nodatime,代码行数:24,代码来源:BclCalendars.cs

示例2: TestDaysInYear

	public void TestDaysInYear (Calendar calendar, int year)
	{
		var daysInYear = calendar.GetDaysInYear (year);
		var daysInMonths = 0;
		var monthInYear = calendar.GetMonthsInYear (year);
		for (var m = 1; m <= monthInYear; m++)
			daysInMonths += calendar.GetDaysInMonth (year, m);

		Assert.AreEqual (daysInYear, daysInMonths, string.Format("Calendar:{0} Year:{1}",calendar.GetType(), year));
	}
开发者ID:nlhepler,项目名称:mono,代码行数:10,代码来源:CalendarTest.cs

示例3: CalendarToString

 private static string CalendarToString(Calendar calendar)
 {
     var algorithmType = calendar.AlgorithmType.ToString().Replace("Calendar", "");
     if (calendar.GetType() == typeof(GregorianCalendar))
     {
         var gregorianCalendar = (GregorianCalendar)calendar;
         return string.Format("Gregorian-{0} ({1})", gregorianCalendar.CalendarType, algorithmType);
     }
     return string.Format("{0} ({1})", calendar.ToString().Replace("System.Globalization.", "").Replace("Calendar", ""), algorithmType);
 }
开发者ID:AndreyAkinshin,项目名称:CultureInfoExplorer,代码行数:10,代码来源:ExploreHelper.cs

示例4: GetDayOfWeek

        /// <summary>
        /// Returns the day of week based on calendar.
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="calendar"></param>
        /// <returns></returns>
        public static int GetDayOfWeek(DateTime dt, Calendar calendar)
        {
            var calendarType = calendar.GetType();
            if (calendarType == typeof (PersianCalendar) ||
                calendarType == typeof (System.Globalization.PersianCalendar))
            {
                return PersianDateTimeFormatInfo.GetDayIndex(dt.DayOfWeek);
            }

            return (int) dt.DayOfWeek;
        }
开发者ID:HEskandari,项目名称:FarsiLibrary,代码行数:17,代码来源:CultureHelper.cs

示例5: CloningTest

 public static void CloningTest(Calendar calendar, int yearHasLeapMonth, CalendarAlgorithmType algorithmType)
 {
     Calendar cloned = (Calendar) calendar.Clone();
     Assert.Equal(calendar.GetType(), cloned.GetType());
 }
开发者ID:geoffkizer,项目名称:corefx,代码行数:5,代码来源:Calendars.netstandard1.7.cs

示例6: Calendar_AutomationPeer

        public void Calendar_AutomationPeer()
        {
            Calendar calendar = new Calendar();
            Assert.IsNotNull(calendar);
            calendar.Height = 200;
            calendar.Width = 200;
            _isLoaded = false;
            DateTime date = new DateTime(2000, 2, 2);
            calendar.DisplayDate = date;
            calendar.SelectedDate = date;

            calendar.Loaded += new RoutedEventHandler(calendar_Loaded);
            CalendarAutomationPeer peer = ((CalendarAutomationPeer)CalendarAutomationPeer.CreatePeerForElement(calendar));
            Assert.IsNotNull(peer);

            TestPeer testPeer = new TestPeer(calendar);
            Assert.IsNotNull(testPeer);

            TestPanel.Children.Add(calendar);
            EnqueueConditional(IsLoaded);
            EnqueueCallback(delegate
            {
                Assert.AreEqual(peer.GetAutomationControlType(), AutomationControlType.Calendar, "Incorrect Control type for calendar");
                Assert.AreEqual(peer.GetClassName(), calendar.GetType().Name, "Incorrect ClassName value for Calendar");
                Assert.AreEqual(peer.GetName(), date.ToString(), "Incorrect Name value for CalendarPeer");
                Assert.IsTrue(peer.IsContentElement(), "Incorrect IsContentElement value");
                Assert.IsTrue(peer.IsControlElement(), "Incorrect IsControlElement value");

                #region CalendarAutomationPeer IGridProvider tests:

                IGridProvider calendarGridProvider = ((IGridProvider)peer.GetPattern(PatternInterface.Grid));
                Assert.IsNotNull(calendarGridProvider, "Incorrect calendarGridProvider value");
                Assert.AreEqual(calendar.MonthControl.MonthView.RowDefinitions.Count - 1, calendarGridProvider.RowCount, "Incorrect RowCount value");
                Assert.AreEqual(calendar.MonthControl.MonthView.ColumnDefinitions.Count, calendarGridProvider.ColumnCount, "Incorrect ColumnCount value");

                IRawElementProviderSimple cell = calendarGridProvider.GetItem(0, 3);
                Assert.IsNotNull(cell, "GetItem returned null for valid cell");
                AutomationPeer cellPeer = testPeer.GetPeerFromProvider(cell);
                Assert.AreEqual(typeof(CalendarDayButton).Name, cellPeer.GetClassName(), "GetItem did not return DayButton");

                calendar.DisplayMode = CalendarMode.Year;
                Assert.AreEqual(calendar.MonthControl.YearView.RowDefinitions.Count, calendarGridProvider.RowCount, "Incorrect RowCount value");
                Assert.AreEqual(calendar.MonthControl.YearView.ColumnDefinitions.Count, calendarGridProvider.ColumnCount, "Incorrect ColumnCount value");

                cell = calendarGridProvider.GetItem(2, 3);
                Assert.IsNotNull(cell, "GetItem returned null for valid cell");
                cellPeer = testPeer.GetPeerFromProvider(cell);
                Assert.AreEqual(typeof(CalendarButton).Name, cellPeer.GetClassName(), "GetItem did not return CalendarButton");

                calendar.DisplayMode = CalendarMode.Decade;
                Assert.AreEqual(calendar.MonthControl.YearView.RowDefinitions.Count, calendarGridProvider.RowCount, "Incorrect RowCount value");
                Assert.AreEqual(calendar.MonthControl.YearView.ColumnDefinitions.Count, calendarGridProvider.ColumnCount, "Incorrect ColumnCount value");

                cell = calendarGridProvider.GetItem(2, 3);
                Assert.IsNotNull(cell, "GetItem returned null for valid cell");
                cellPeer = testPeer.GetPeerFromProvider(cell);
                Assert.AreEqual(typeof(CalendarButton).Name, cellPeer.GetClassName(), "GetItem did not return CalendarButton");

                cell = calendarGridProvider.GetItem(10, 10);
                Assert.IsNull(cell, "GetItem returned object for invalid cell");

                #endregion

                #region CalendarAutomationPeer IMultipleViewProvider tests:
                calendar._hasFocus = true;
                IMultipleViewProvider calendarMultiViewProvider = ((IMultipleViewProvider)peer.GetPattern(PatternInterface.MultipleView));
                Assert.IsNotNull(calendarMultiViewProvider);
                Assert.IsTrue(calendarMultiViewProvider.CurrentView == (int)CalendarMode.Decade);
                Assert.IsTrue(CalendarMode.Decade.ToString() == calendarMultiViewProvider.GetViewName(calendarMultiViewProvider.CurrentView));
                calendarMultiViewProvider.SetCurrentView((int)CalendarMode.Year);
                Assert.IsTrue(calendar.DisplayMode == CalendarMode.Year);
                Assert.IsTrue(calendarMultiViewProvider.CurrentView == (int)CalendarMode.Year);
                Assert.IsTrue(CalendarMode.Year.ToString() == calendarMultiViewProvider.GetViewName(calendarMultiViewProvider.CurrentView));

                #endregion

                #region CalendarAutomationPeer ISelectionProvider tests:
                ISelectionProvider calendarSelectionProvider = ((ISelectionProvider)peer.GetPattern(PatternInterface.Selection));
                Assert.IsNotNull(calendarSelectionProvider);
                Assert.IsFalse(calendarSelectionProvider.IsSelectionRequired, "Incorrect IsSelectionRequired value");
                Assert.IsFalse(calendarSelectionProvider.CanSelectMultiple, "Incorrect CanSelectMultiple value");
                calendar.SelectionMode = CalendarSelectionMode.MultipleRange;
                Assert.IsNull(calendar.SelectedDate);
                Assert.IsTrue(calendarSelectionProvider.CanSelectMultiple, "Incorrect CanSelectMultiple value");
                calendar.SelectedDates.AddRange(new DateTime(2000, 2, 10), new DateTime(2000, 3, 30));

                IRawElementProviderSimple[] selection = calendarSelectionProvider.GetSelection();
                Assert.IsNotNull(selection, "GetSelection returned null for valid selection");
                Assert.AreEqual(selection.Length, 1, "GetSelection returned wrong number of selections");
                cellPeer = testPeer.GetPeerFromProvider(selection[0]);
                Assert.AreEqual(cellPeer.GetClassName(), typeof(CalendarButton).Name, "Incorrect name for CalendarButton");

                calendar.DisplayMode = CalendarMode.Month;
                selection = calendarSelectionProvider.GetSelection();
                Assert.IsNotNull(selection, "GetSelection returned null for valid selection");
                Assert.AreEqual(selection.Length, 31, "GetSelection returned wrong number of selections");
                cellPeer = testPeer.GetPeerFromProvider(selection[0]);
                Assert.AreEqual(cellPeer.GetClassName(), typeof(CalendarDayButton).Name, "Incorrect name for DayButton");
                #endregion

//.........这里部分代码省略.........
开发者ID:dfr0,项目名称:moon,代码行数:101,代码来源:CalendarTest.cs


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