Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 |
|
---|
6 | namespace 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.