18 using System.Collections.Generic;
20 namespace Deveel.Data.Serialization {
22 private readonly Dictionary<string, KeyValuePair<Type, object>>
values;
25 GraphType = graphType;
26 values =
new Dictionary<string, KeyValuePair<Type, object>>();
29 public Type GraphType {
get;
private set; }
31 internal IEnumerable<KeyValuePair<string, KeyValuePair<Type, object>>> Values {
32 get {
return values; }
35 public void SetValue(
string key, Type type,
object value) {
36 if (String.IsNullOrEmpty(key))
37 throw new ArgumentNullException(
"key");
39 throw new ArgumentNullException(
"type");
42 if (!IsSupported(type.GetElementType()))
43 throw new NotSupportedException(String.Format(
"The element type '{0}' of the array is not supported.",
44 type.GetElementType()));
45 }
else if (!type.IsArray && !IsSupported(type))
46 throw new NotSupportedException(String.Format(
"The type '{0}' is not supported.", type));
48 if (value != null && !type.IsInstanceOfType(value))
49 throw new ArgumentException(
50 String.Format(
"The specified object value is not assignable from the type '{0}' specified.", type));
52 values[key] =
new KeyValuePair<Type, object>(type, value);
56 return type.IsPrimitive ||
57 type == typeof (
string) ||
61 public void SetValue(
string key,
object value) {
65 var type = value.GetType();
66 SetValue(key, type, value);
70 SetValue(key, typeof(
bool), value);
74 SetValue(key, typeof(byte), value);
77 public void SetValue(
string key,
short value) {
78 SetValue(key, typeof(
short), value);
82 SetValue(key, typeof(
int), value);
86 SetValue(key, typeof(
long), value);
89 public void SetValue(
string key,
float value) {
90 SetValue(key, typeof(
float), value);
93 public void SetValue(
string key,
double value) {
94 SetValue(key, typeof(
double), value);
97 public void SetValue(
string key,
string value) {
98 SetValue(key, typeof(
string), value);
void SetValue(string key, long value)
void SetValue(string key, int value)
static bool IsSupported(Type type)
void SetValue(string key, Type type, object value)
void SetValue(string key, object value)
readonly Dictionary< string, KeyValuePair< Type, object > > values
void SetValue(string key, string value)
void SetValue(string key, byte value)
void SetValue(string key, float value)
SerializeData(Type graphType)
void SetValue(string key, short value)
void SetValue(string key, bool value)
void SetValue(string key, double value)