-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCustomDataSerializer.cs
33 lines (28 loc) · 1.2 KB
/
CustomDataSerializer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using CustomParameterEditorAngularExample;
using DevExpress.XtraReports.Native;
namespace CustomParameterEditorAngularExample {
[TypeConverter(typeof(CustomParameterTypeConverter))]
public class CustomDataSerializer : IDataSerializer {
public const string Name = "myCustomDataSerializer";
public bool CanDeserialize(string value, string typeName, object extensionProvider) {
return typeName == typeof(CustomParameterType).FullName;
}
public bool CanSerialize(object data, object extensionProvider) {
return data is CustomParameterType;
}
public object Deserialize(string value, string typeName, object extensionProvider) {
if (typeName == typeof(CustomParameterType).FullName) {
return new CustomParameterType { Value = value };
}
return null;
}
public string Serialize(object data, object extensionProvider) {
var parameter = data as CustomParameterType;
return parameter != null ? parameter.Value : null;
}
}
}