GetIntersection() public méthode

public GetIntersection ( ITimePeriod period ) : ITimeInterval
period ITimePeriod
Résultat ITimeInterval
        public void TouchingIntervalTest()
        {
            TimeInterval timeInterval1 = new TimeInterval( start, end );
            TimeInterval timeInterval2 = new TimeInterval( end, end.AddHours( 1 ) );

            Assert.AreNotEqual( timeInterval1.GetIntersection( timeInterval2 ), null );
            Assert.AreEqual( timeInterval1.IntersectsWith( timeInterval2 ), true );
            Assert.AreEqual( timeInterval1.GetRelation( timeInterval2 ), PeriodRelation.EndTouching );
            Assert.AreEqual( timeInterval2.GetRelation( timeInterval1 ), PeriodRelation.StartTouching );

            timeInterval1.EndEdge = IntervalEdge.Open;
            Assert.AreEqual( timeInterval1.GetIntersection( timeInterval2 ), null );
            Assert.AreEqual( timeInterval1.IntersectsWith( timeInterval2 ), false );
            Assert.AreEqual( timeInterval1.GetRelation( timeInterval2 ), PeriodRelation.Before );
            Assert.AreEqual( timeInterval2.GetRelation( timeInterval1 ), PeriodRelation.After );

            timeInterval1.EndEdge = IntervalEdge.Closed;
            Assert.AreNotEqual( timeInterval1.GetIntersection( timeInterval2 ), null );
            Assert.AreEqual( timeInterval1.IntersectsWith( timeInterval2 ), true );
            Assert.AreEqual( timeInterval1.GetRelation( timeInterval2 ), PeriodRelation.EndTouching );
            Assert.AreEqual( timeInterval2.GetRelation( timeInterval1 ), PeriodRelation.StartTouching );

            timeInterval2.StartEdge = IntervalEdge.Open;
            Assert.AreEqual( timeInterval1.GetIntersection( timeInterval2 ), null );
            Assert.AreEqual( timeInterval1.IntersectsWith( timeInterval2 ), false );
            Assert.AreEqual( timeInterval1.GetRelation( timeInterval2 ), PeriodRelation.Before );
            Assert.AreEqual( timeInterval2.GetRelation( timeInterval1 ), PeriodRelation.After );

            timeInterval2.StartEdge = IntervalEdge.Closed;
            Assert.AreNotEqual( timeInterval1.GetIntersection( timeInterval2 ), null );
            Assert.AreEqual( timeInterval1.IntersectsWith( timeInterval2 ), true );
            Assert.AreEqual( timeInterval1.GetRelation( timeInterval2 ), PeriodRelation.EndTouching );
            Assert.AreEqual( timeInterval2.GetRelation( timeInterval1 ), PeriodRelation.StartTouching );
        }
        public void TimeIntervalSample()
        {
            // --- time interval 1 ---
            TimeInterval timeInterval1 = new TimeInterval(
                new DateTime( 2011, 5, 8 ),
                new DateTime( 2011, 5, 9 ) );
            Console.WriteLine( "TimeInterval1: " + timeInterval1 );
            // > TimeInterval1: [08.05.2011 - 09.05.2011] | 1.00:00

            // --- time interval 2 ---
            TimeInterval timeInterval2 = new TimeInterval(
                timeInterval1.End,
                timeInterval1.End.AddDays( 1 ) );
            Console.WriteLine( "TimeInterval2: " + timeInterval2 );
            // > TimeInterval2: [09.05.2011 - 10.05.2011] | 1.00:00

            // --- relation ---
            Console.WriteLine( "Relation: " + timeInterval1.GetRelation( timeInterval2 ) );
            // > Relation: EndTouching
            Console.WriteLine( "Intersection: " + timeInterval1.GetIntersection( timeInterval2 ) );
            // > Intersection: [09.05.2011]

            timeInterval1.EndEdge = IntervalEdge.Open;
            Console.WriteLine( "TimeInterval1: " + timeInterval1 );
            // > TimeInterval1: [08.05.2011 - 09.05.2011) | 1.00:00

            timeInterval2.StartEdge = IntervalEdge.Open;
            Console.WriteLine( "TimeInterval2: " + timeInterval2 );
            // > TimeInterval2: (09.05.2011 - 10.05.2011] | 1.00:00

            // --- relation ---
            Console.WriteLine( "Relation: " + timeInterval1.GetRelation( timeInterval2 ) );
            // > Relation: Before
            Console.WriteLine( "Intersection: " + timeInterval1.GetIntersection( timeInterval2 ) );
            // > Intersection:
        }