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