本文整理汇总了C#中TimeRange类的典型用法代码示例。如果您正苦于以下问题:C# TimeRange类的具体用法?C# TimeRange怎么用?C# TimeRange使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TimeRange类属于命名空间,在下文中一共展示了TimeRange类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: PeriodLimitsAddTest
public void PeriodLimitsAddTest() {
var test = new DateTime(2011, 4, 12);
var timeRange1 = new TimeRange(new DateTime(2011, 4, 20), new DateTime(2011, 4, 25)); // 4월 20일~4월25일
var timeRange2 = new TimeRange(new DateTime(2011, 4, 30), null); // 4월 30일 이후
var calendarDateAdd = new CalendarDateAdd();
// 예외 기간을 설정합니다. 4월20일 ~ 4월25일, 4월30일 이후
//
calendarDateAdd.ExcludePeriods.Add(timeRange1);
calendarDateAdd.ExcludePeriods.Add(timeRange2);
calendarDateAdd.Add(test, DurationUtil.Day).Should().Be(test.Add(DurationUtil.Day));
//! 4월 12일에 8일을 더하면 4월 20일이지만, 20~25일까지 제외되므로, 4월 25일이 된다.
//
calendarDateAdd.Add(test, DurationUtil.Days(8)).Should().Be(timeRange1.End);
//! 4월 20일에 20일을 더하면, 4월 20~25일 제외 후를 계산하면 4월 30일 이후가 된다. 하지만 4월 30일 이후는 제외가 되므로, 결과값은 null이 된다.
//
calendarDateAdd.Add(test, DurationUtil.Days(20)).HasValue.Should().Be.False();
calendarDateAdd.Subtract(test, DurationUtil.Days(3)).Should().Be(test.Subtract(DurationUtil.Days(3)));
}
开发者ID:debop,项目名称:NFramework,代码行数:25,代码来源:CalendarDateAddFixture.cs
示例2: MomentTest
public void MomentTest() {
var period = new TimeRange(new DateTime(2011, 3, 1), new DateTime(2011, 3, 1));
var periodCombiner = new TimePeriodCombiner<TimeRange>();
var periods = periodCombiner.CombinePeriods(new TimePeriodCollection { period });
periods.Count.Should().Be(1);
Assert.IsTrue(periods[0].IsSamePeriod(period));
}
开发者ID:debop,项目名称:NFramework,代码行数:7,代码来源:TimePeriodCombinerFixture.cs
示例3: PeriodLimitsSubtractTest
public void PeriodLimitsSubtractTest() {
var test = new DateTime(2011, 4, 30);
var timeRange1 = new TimeRange(new DateTime(2011, 4, 20), new DateTime(2011, 4, 25));
var timeRange2 = new TimeRange(DateTime.MinValue, new DateTime(2011, 4, 6));
var calendarDateAdd = new CalendarDateAdd();
// 예외 기간을 설정합니다. 4월 10일 이전, 4월20일 ~ 4월25일
//
calendarDateAdd.ExcludePeriods.Add(timeRange1);
calendarDateAdd.ExcludePeriods.Add(timeRange2);
calendarDateAdd.Subtract(test, DurationUtil.Days(1)).Should().Be(test.Subtract(DurationUtil.Days(1)));
//! 4월 30일로부터 5일전이면 4월25일이지만, 예외기간이 4월20일~4월25일이므로, 4월20일을 반환합니다.
//
calendarDateAdd.Subtract(test, DurationUtil.Days(5)).Should().Be(timeRange1.Start);
//! 4월 30일로부터 20일전이면, 4월10일 이지만 예외기간이 4월20일~4월25일이 있어 4월 5일이 되지만 4월 6일 이전은 예외기간이라 null을 반환합니다.
//
calendarDateAdd.Subtract(test, DurationUtil.Days(20)).HasValue.Should().Be.False();
calendarDateAdd.Add(test, DurationUtil.Days(3)).Should().Be(test.Add(DurationUtil.Days(3)));
}
开发者ID:debop,项目名称:NFramework,代码行数:25,代码来源:CalendarDateAddFixture.cs
示例4: HasStartTest
public void HasStartTest() {
//현재부터 ~ 쭉
var timeRange = new TimeRange(ClockProxy.Clock.Now, null);
timeRange.HasStart.Should().Be.True();
timeRange.HasEnd.Should().Be.False();
}
开发者ID:debop,项目名称:NFramework,代码行数:7,代码来源:TimeRangeFixture.cs
示例5: AsStringTest
public void AsStringTest() {
var period = new TimeRange(testTime, nowTime);
var periodString = TimeTool.AsString(period);
Console.WriteLine("periodString=" + periodString);
periodString.Should().Not.Be.Empty();
}
开发者ID:debop,项目名称:NFramework,代码行数:7,代码来源:TimeToolFixture.cs
示例6: LocationWorkHour
/// <summary>
/// Initializes a new instance of the <see cref="LocationWorkHour"/> class.
/// </summary>
/// <param name="dayOfWeek">The day of week.</param>
/// <param name="workHourTimeRange">The work hour time range.</param>
public LocationWorkHour(DayOfWeek dayOfWeek, TimeRange workHourTimeRange)
{
Check.IsNotNull(dayOfWeek, () => DayOfWeek);
_dayOfWeek = dayOfWeek;
_workHourTimeRange = workHourTimeRange;
}
开发者ID:divyang4481,项目名称:REM,代码行数:12,代码来源:LocationWorkHour.cs
示例7: TimeRangeCalendarTimeRangeTest
public void TimeRangeCalendarTimeRangeTest() {
var now = ClockProxy.Clock.Now;
for(var i = 0; i < 500; i += 10) {
//var fiveSeconds = new TimeRange(new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, 15, 0),
// new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, 20, 0));
var current = now.AddDays(i);
var currentFiveSeconds = new TimeRange(current.TrimToSecond(15), current.TrimToSecond(20));
new YearRange(current).HasInside(currentFiveSeconds).Should().Be.True();
new HalfyearRange(current).HasInside(currentFiveSeconds).Should().Be.True();
new QuarterRange(current).HasInside(currentFiveSeconds).Should().Be.True();
new MonthRange(current).HasInside(currentFiveSeconds).Should().Be.True();
new WeekRange(current).HasInside(currentFiveSeconds).Should().Be.True();
new DayRange(current).HasInside(currentFiveSeconds).Should().Be.True();
new HourRange(current).HasInside(currentFiveSeconds).Should().Be.True();
new MinuteRange(current).HasInside(currentFiveSeconds).Should().Be.True();
}
TimeRange anytime = new TimeRange();
new YearRange().HasInside(anytime).Should().Be.False();
new HalfyearRange().HasInside(anytime).Should().Be.False();
new QuarterRange().HasInside(anytime).Should().Be.False();
new MonthRange().HasInside(anytime).Should().Be.False();
new WeekRange().HasInside(anytime).Should().Be.False();
new DayRange().HasInside(anytime).Should().Be.False();
new HourRange().HasInside(anytime).Should().Be.False();
new MinuteRange().HasInside(anytime).Should().Be.False();
}
开发者ID:debop,项目名称:NFramework,代码行数:32,代码来源:BusinessCaseFixture.cs
示例8: SampleCombiner
public SampleCombiner(DataSample sample)
{
if (sample == null)
{
throw new ArgumentNullException("sample");
}
// validate that this sampletype is acceptable
switch (sample.SampleType)
{
case DataSampleType.Average:
case DataSampleType.Histogram:
case DataSampleType.HitCount:
case DataSampleType.Maximum:
case DataSampleType.Minimum:
break;
default:
throw new ArgumentException("Cannot combine samples for percentiles or other types");
}
this.internalSample = new DataSample
{
SampleType = sample.SampleType,
Dimensions = sample.Dimensions,
Name = sample.Name
};
this.AddData(sample);
this.timeRange = new TimeRange(sample.StartTime, sample.EndTime);
this.hasUpdatedTimeRange = true;
}
开发者ID:darting,项目名称:MetricSystem,代码行数:32,代码来源:SampleCombiner.cs
示例9: TariffRestriction
/// <summary>
/// Create a new tariff restrictions class.
/// </summary>
/// <param name="Time">Start/end time of day, for example "13:30 - 19:45", valid from this time of the day.</param>
/// <param name="Date">Start/end date, for example: 2015-12-24, valid from this day until that day (excluding that day).</param>
/// <param name="kWh">Minimum/Maximum used energy in kWh, for example 20, valid from this amount of energy is used.</param>
/// <param name="Power">Minimum/Maximum power in kW, for example 0, valid from this charging speed.</param>
/// <param name="Duration">Minimum/Maximum duration in seconds, valid for a duration from x seconds.</param>
/// <param name="DayOfWeek">Minimum/Maximum duration in seconds, valid for a duration from x seconds.</param>
public TariffRestriction(TimeRange? Time = null,
StartEndDateTime? Date = null,
DecimalMinMax? kWh = null,
DecimalMinMax? Power = null,
TimeSpanMinMax? Duration = null,
IEnumerable<DayOfWeek> DayOfWeek = null)
{
#region Initial checks
if (!Time. HasValue &&
!Date. HasValue &&
!kWh. HasValue &&
Power. HasValue &&
Duration.HasValue &&
DayOfWeek == null)
throw new ArgumentNullException("All given parameter equals null is invalid!");
#endregion
this.Time = Time;
this.Date = Date;
this.kWh = kWh;
this.Power = Power;
this.Duration = Duration;
this.DayOfWeek = DayOfWeek != null ? DayOfWeek.Distinct() : new DayOfWeek[0];
}
开发者ID:OpenChargingCloud,项目名称:WWCP_OCPI,代码行数:35,代码来源:TariffRestrictions.cs
示例10: TimedColourRangeSet
public TimedColourRangeSet(TimeRange timeRange, DualColour start, DualColour mid, DualColour end)
{
this.timeRange = timeRange;
this.start = start;
this.mid = mid;
this.end = end;
}
开发者ID:jokigenki,项目名称:SuperDomestique,代码行数:7,代码来源:TimedColourRangeSet.cs
示例11: TwoPeriodsOverlap1Test
public void TwoPeriodsOverlap1Test() {
var period1 = new TimeRange(new DateTime(2011, 3, 1), new DateTime(2011, 3, 15));
var period2 = new TimeRange(new DateTime(2011, 3, 10), new DateTime(2011, 3, 20));
var periodCombiner = new TimePeriodCombiner<TimeRange>();
var periods = periodCombiner.CombinePeriods(period1, period2);
periods.Count.Should().Be(1);
Assert.IsTrue(periods[0].IsSamePeriod(new TimeRange(new DateTime(2011, 3, 1), new DateTime(2011, 3, 20))));
}
开发者ID:debop,项目名称:NFramework,代码行数:8,代码来源:TimePeriodCombinerFixture.cs
示例12: GenericStockChartViewModel
public GenericStockChartViewModel( Settings settings )
{
mySettings = settings;
myCurves = new List<Curve>();
Signals = SignalCurve.Empty;
myViewPort = TimeRange.All;
}
开发者ID:bg0jr,项目名称:Maui,代码行数:9,代码来源:GenericStockChartViewModel.cs
示例13: WhenResetCellularDataBlackoutThenGetCellularDataBlackoutShouldReturnNull
public void WhenResetCellularDataBlackoutThenGetCellularDataBlackoutShouldReturnNull()
{
TimeRange range = new TimeRange(new Time(11, 00), new Time(12, 01));
this.Preferences.ResetCellularDataBlackout();
TimeRange timeRange = Preferences.CellularDataBlackout;
Assert.Null(timeRange);
}
开发者ID:ejarlewski,项目名称:reyna.net,代码行数:9,代码来源:GivenAPreferences.cs
示例14: ReadingRangeAggregate
public ReadingRangeAggregate(
TimeRange timeStamp,
ReadingValuesRange ranges
)
: base(ranges)
{
TimeStamp = new TimeRange(timeStamp);
_min = _max = null;
}
开发者ID:fparaggio,项目名称:atmo,代码行数:9,代码来源:ReadingRangeAggregate.cs
示例15: GetActiveEventsAroundPOI
public static GetEventsResult GetActiveEventsAroundPOI(LocationPoint PointOfInterest, TimeRange When)
{
BasicHttpBinding basicHttpBinding = new BasicHttpBinding();
EndpointAddress endpointAddress = new EndpointAddress("http://localhost:56071/CaloomMainService.svc");
ICaloomMainService service =
new ChannelFactory< ICaloomMainService >(basicHttpBinding, endpointAddress).CreateChannel();
var serviceResponse = service.GetActiveEventsAroundPOI(PointOfInterest, When);
return serviceResponse;
}
开发者ID:kallex,项目名称:Caloom,代码行数:9,代码来源:ServiceClient_CSharp_v1_0.designer.cs
示例16: NoPeriodsTest
public void NoPeriodsTest() {
var limits = new TimeRange(new DateTime(2011, 3, 1), new DateTime(2011, 3, 5));
var gapCalculator = new TimeGapCalculator<TimeRange>();
var gaps = gapCalculator.GetGaps(new TimePeriodCollection(), limits);
gaps.Count.Should().Be(1);
gaps[0].IsSamePeriod(limits).Should().Be.True();
}
开发者ID:debop,项目名称:NFramework,代码行数:9,代码来源:TimeGapCalculatorFixture.cs
示例17: ApplyCycle
protected override IColorEffect ApplyCycle(TimeRange range, LEDNode ledNode)
{
double pos = Tween.GetValue(range.Current);
if (Ordering.GetLEDPosition(ledNode) <= pos)
return _endColorEffect;
return _startColorEffect;
}
开发者ID:JacquiManzi,项目名称:KineticSpectrum,代码行数:9,代码来源:Sweep.cs
示例18: PeriodEqualsLimitsTest
public void PeriodEqualsLimitsTest() {
var limits = new TimeRange(new DateTime(2011, 3, 1), new DateTime(2011, 3, 5));
var gapCalculator = new TimeGapCalculator<TimeRange>();
var excludePeriods = new TimePeriodCollection { limits };
var gaps = gapCalculator.GetGaps(excludePeriods, limits);
gaps.Count.Should().Be(0);
}
开发者ID:debop,项目名称:NFramework,代码行数:10,代码来源:TimeGapCalculatorFixture.cs
示例19: TimeRangeStepper
public TimeRangeStepper(ChartModel chart)
{
TimeRange = chart.TimeRange;
StartDate = chart.StartDate;
EndDate = IncrementByGranularity(StartDate, TimeRange);
Granularity = chart.Granularity;
CurrentStartDate = StartDate;
CurrentEndDate = incrementByGranularity(StartDate);
StepCount = 0;
}
开发者ID:jneufeld,项目名称:cs319,代码行数:10,代码来源:TimeRangeStepper.cs
示例20: WhenSettingCellularDataBlackoutThenGetCellularDataBlackoutShouldReturnExpected
public void WhenSettingCellularDataBlackoutThenGetCellularDataBlackoutShouldReturnExpected()
{
TimeRange range = new TimeRange(new Time(11, 00), new Time(12, 01));
this.Preferences.SetCellularDataBlackout(range);
TimeRange timeRange = Preferences.CellularDataBlackout;
Assert.Equal(range.From.MinuteOfDay, timeRange.From.MinuteOfDay);
Assert.Equal(range.To.MinuteOfDay, timeRange.To.MinuteOfDay);
}
开发者ID:ejarlewski,项目名称:reyna.net,代码行数:10,代码来源:GivenAPreferences.cs
注:本文中的TimeRange类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论