Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/DynamicDataDisplay/Common/DataRectSerializer.cs @ 13757

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

#2283 added GUI and charts; fixed MCTS

File size: 1.0 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Windows.Markup;
6using System.Globalization;
7
8namespace Microsoft.Research.DynamicDataDisplay.Common
9{
10  public sealed class DataRectSerializer : ValueSerializer
11  {
12    public override bool CanConvertFromString(string value, IValueSerializerContext context)
13    {
14      return true;
15    }
16
17    public override bool CanConvertToString(object value, IValueSerializerContext context)
18    {
19      return value is DataRect;
20    }
21
22    public override object ConvertFromString(string value, IValueSerializerContext context)
23    {
24      if (value != null)
25      {
26        return DataRect.Parse(value);
27      }
28      return base.ConvertFromString(value, context);
29    }
30
31    public override string ConvertToString(object value, IValueSerializerContext context)
32    {
33      if (value is DataRect)
34      {
35        DataRect rect = (DataRect)value;
36        return rect.ConvertToString(null, CultureInfo.GetCultureInfo("en-us"));
37      }
38      return base.ConvertToString(value, context);
39    }
40  }
41}
Note: See TracBrowser for help on using the repository browser.