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


C# TimeRange.GetRelation方法代码示例

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


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

示例1: TimeRangeSample

        public void TimeRangeSample()
        {
            // --- time range 1 ---
            TimeRange timeRange1 = new TimeRange(
                new DateTime( 2011, 2, 22, 14, 0, 0 ),
                new DateTime( 2011, 2, 22, 18, 0, 0 ) );
            Console.WriteLine( "TimeRange1: " + timeRange1 );
            // > TimeRange1: 22.02.2011 14:00:00 - 18:00:00 | 04:00:00

            // --- time range 2 ---
            TimeRange timeRange2 = new TimeRange(
                new DateTime( 2011, 2, 22, 15, 0, 0 ),
                new TimeSpan( 2, 0, 0 ) );
            Console.WriteLine( "TimeRange2: " + timeRange2 );
            // > TimeRange2: 22.02.2011 15:00:00 - 17:00:00 | 02:00:00

            // --- time range 3 ---
            TimeRange timeRange3 = new TimeRange(
                new DateTime( 2011, 2, 22, 16, 0, 0 ),
                new DateTime( 2011, 2, 22, 21, 0, 0 ) );
            Console.WriteLine( "TimeRange3: " + timeRange3 );
            // > TimeRange3: 22.02.2011 16:00:00 - 21:00:00 | 05:00:00

            // --- relation ---
            Console.WriteLine( "TimeRange1.GetRelation( TimeRange2 ): " + timeRange1.GetRelation( timeRange2 ) );
            // > TimeRange1.GetRelation( TimeRange2 ): Enclosing
            Console.WriteLine( "TimeRange1.GetRelation( TimeRange3 ): " + timeRange1.GetRelation( timeRange3 ) );
            // > TimeRange1.GetRelation( TimeRange3 ): EndInside
            Console.WriteLine( "TimeRange3.GetRelation( TimeRange2 ): " + timeRange3.GetRelation( timeRange2 ) );
            // > TimeRange3.GetRelation( TimeRange2 ): StartInside

            // --- intersection ---
            Console.WriteLine( "TimeRange1.GetIntersection( TimeRange2 ): " + timeRange1.GetIntersection( timeRange2 ) );
            // > TimeRange1.GetIntersection( TimeRange2 ): 22.02.2011 15:00:00 - 17:00:00 | 02:00:00
            Console.WriteLine( "TimeRange1.GetIntersection( TimeRange3 ): " + timeRange1.GetIntersection( timeRange3 ) );
            // > TimeRange1.GetIntersection( TimeRange3 ): 22.02.2011 16:00:00 - 18:00:00 | 02:00:00
            Console.WriteLine( "TimeRange3.GetIntersection( TimeRange2 ): " + timeRange3.GetIntersection( timeRange2 ) );
            // > TimeRange3.GetIntersection( TimeRange2 ): 22.02.2011 16:00:00 - 17:00:00 | 01:00:00
        }
开发者ID:jwg4,项目名称:date-difference,代码行数:39,代码来源:ArticleSamples.cs

示例2: DefaultTest

 public void DefaultTest()
 {
     TimeRange timeRange = new TimeRange();
     Assert.AreNotEqual( timeRange, TimeRange.Anytime );
     Assert.AreEqual( timeRange.GetRelation( TimeRange.Anytime ), PeriodRelation.ExactMatch );
     Assert.IsTrue( timeRange.IsAnytime );
     Assert.IsFalse( timeRange.IsMoment );
     Assert.IsFalse( timeRange.IsReadOnly );
 }
开发者ID:HoLoveSalt,项目名称:showhotel,代码行数:9,代码来源:TimeRangeTest.cs


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