Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/DynamicDataDisplay/DataSources/OneDimensional/DataSourceHelper.cs @ 13847

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

#2283 added GUI and charts; fixed MCTS

File size: 880 bytes
Line 
1using System;
2using System.Collections.Generic;
3using System.Windows;
4using Microsoft.Research.DynamicDataDisplay.Charts;
5
6namespace Microsoft.Research.DynamicDataDisplay.DataSources
7{
8  public static class DataSourceHelper
9  {
10    public static IEnumerable<Point> GetPoints(IPointDataSource dataSource)
11    {
12      return GetPoints(dataSource, null);
13    }
14
15    public static IEnumerable<Point> GetPoints(IPointDataSource dataSource, DependencyObject context)
16    {
17      if (dataSource == null)
18        throw new ArgumentNullException("dataSource");
19
20      if (context == null)
21        context = new DataSource2dContext();
22
23      using (IPointEnumerator enumerator = dataSource.GetEnumerator(context))
24      {
25        Point p = new Point();
26        while (enumerator.MoveNext())
27        {
28          enumerator.GetCurrent(ref p);
29          yield return p;
30          p = new Point();
31        }
32      }
33    }
34  }
35}
Note: See TracBrowser for help on using the repository browser.