Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/DynamicDataDisplay/Charts/Axes/DateTime/Strategies/DelegateStrategy.cs @ 12503

Last change on this file since 12503 was 12503, checked in by aballeit, 9 years ago

#2283 added GUI and charts; fixed MCTS

File size: 766 bytes
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5
6namespace Microsoft.Research.DynamicDataDisplay.Charts.Axes.DateTime.Strategies
7{
8  public class DelegateDateTimeStrategy : DefaultDateTimeTicksStrategy
9  {
10    private readonly Func<TimeSpan, DifferenceIn?> function;
11    public DelegateDateTimeStrategy(Func<TimeSpan, DifferenceIn?> function)
12    {
13      if (function == null)
14        throw new ArgumentNullException("function");
15
16      this.function = function;
17    }
18
19    public override DifferenceIn GetDifference(TimeSpan span)
20    {
21      DifferenceIn? customResult = function(span);
22
23      DifferenceIn result = customResult.HasValue ?
24        customResult.Value :
25        base.GetDifference(span);
26
27      return result;
28    }
29  }
30}
Note: See TracBrowser for help on using the repository browser.