本文整理汇总了C#中Itenso.TimePeriod.TimeRange.HasInside方法的典型用法代码示例。如果您正苦于以下问题:C# TimeRange.HasInside方法的具体用法?C# TimeRange.HasInside怎么用?C# TimeRange.HasInside使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Itenso.TimePeriod.TimeRange
的用法示例。
在下文中一共展示了TimeRange.HasInside方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsValidReservation
// ----------------------------------------------------------------------
public bool IsValidReservation( DateTime start, DateTime end )
{
if ( !TimeCompare.IsSameDay( start, end ) )
{
return false; // multiple day reservation
}
TimeRange workingHours = new TimeRange( TimeTrim.Hour( start, 8 ), TimeTrim.Hour( start, 18 ) );
return workingHours.HasInside( new TimeRange( start, end ) );
}
示例2: HasInsideDateTimeTest
public void HasInsideDateTimeTest()
{
TimeRange timeRange = new TimeRange( start, end );
Assert.AreEqual( timeRange.End, end );
// start
Assert.IsFalse( timeRange.HasInside( start.AddMilliseconds( -1 ) ) );
Assert.IsTrue( timeRange.HasInside( start ) );
Assert.IsTrue( timeRange.HasInside( start.AddMilliseconds( 1 ) ) );
// end
Assert.IsTrue( timeRange.HasInside( end.AddMilliseconds( -1 ) ) );
Assert.IsTrue( timeRange.HasInside( end ) );
Assert.IsFalse( timeRange.HasInside( end.AddMilliseconds( 1 ) ) );
}
示例3: HasInsidePeriodTest
public void HasInsidePeriodTest()
{
TimeRange timeRange = new TimeRange( start, end );
Assert.AreEqual( timeRange.End, end );
// before
TimeRange before1 = new TimeRange( start.AddHours( -2 ), start.AddHours( -1 ) );
Assert.IsFalse( timeRange.HasInside( before1 ) );
TimeRange before2 = new TimeRange( start.AddMilliseconds( -1 ), end );
Assert.IsFalse( timeRange.HasInside( before2 ) );
TimeRange before3 = new TimeRange( start.AddMilliseconds( -1 ), start );
Assert.IsFalse( timeRange.HasInside( before3 ) );
// after
TimeRange after1 = new TimeRange( end.AddHours( 1 ), end.AddHours( 2 ) );
Assert.IsFalse( timeRange.HasInside( after1 ) );
TimeRange after2 = new TimeRange( start, end.AddMilliseconds( 1 ) );
Assert.IsFalse( timeRange.HasInside( after2 ) );
TimeRange after3 = new TimeRange( end, end.AddMilliseconds( 1 ) );
Assert.IsFalse( timeRange.HasInside( after3 ) );
// inside
Assert.IsTrue( timeRange.HasInside( timeRange ) );
TimeRange inside1 = new TimeRange( start.AddMilliseconds( 1 ), end );
Assert.IsTrue( timeRange.HasInside( inside1 ) );
TimeRange inside2 = new TimeRange( start.AddMilliseconds( 1 ), end.AddMilliseconds( -1 ) );
Assert.IsTrue( timeRange.HasInside( inside2 ) );
TimeRange inside3 = new TimeRange( start, end.AddMilliseconds( -1 ) );
Assert.IsTrue( timeRange.HasInside( inside3 ) );
}
示例4: CheckDateBetweenDatesSample
public void CheckDateBetweenDatesSample()
{
DateTime[] moments = new[]
{
new DateTime( 2011, 11, 02 ),
new DateTime( 2011, 12, 25 ),
new DateTime( 2011, 12, 09 ),
new DateTime( 2011, 12, 13 )
};
TimeRange timeRange = new TimeRange( new DateTime( 2011, 11, 01 ), new DateTime( 2011, 12, 15 ) );
Console.WriteLine( "time range: {0}", timeRange );
foreach ( DateTime moment in moments )
{
Console.WriteLine( "{0:d} is inside: {1}", moment, timeRange.HasInside( moment ) ? "1" : "0" );
}
}