- Timestamp:
- 09/16/14 16:49:37 (10 years ago)
- Location:
- stable
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 10896,11352
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Persistence
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Persistence merged: 10896
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/Number2StringSerializer.cs
r11170 r11373 78 78 /// </returns> 79 79 public bool CanSerialize(Type type) { 80 return numberSerializerMap.ContainsKey( type);80 return numberSerializerMap.ContainsKey(Nullable.GetUnderlyingType(type) ?? type); 81 81 } 82 82 … … 90 90 /// </returns> 91 91 public string JustifyRejection(Type type) { 92 return string.Format("not a number type (one of {0})",92 return string.Format("not a (nullable) number type (one of {0})", 93 93 string.Join(", ", numberSerializers.Select(n => n.SourceType.Name).ToArray())); 94 94 } … … 100 100 /// <returns></returns> 101 101 public string Format(object obj) { 102 return ((XmlString)numberSerializerMap[obj.GetType()].Format(obj)).Data; 102 if (obj == null) return "null"; 103 Type type = obj.GetType(); 104 return ((XmlString)numberSerializerMap[Nullable.GetUnderlyingType(type) ?? type].Format(obj)).Data; 103 105 } 104 106 … … 110 112 /// <returns></returns> 111 113 public object Parse(string stringValue, Type type) { 114 if (stringValue == "null") return null; 112 115 try { 113 return numberSerializerMap[ type].Parse(new XmlString(stringValue));116 return numberSerializerMap[Nullable.GetUnderlyingType(type) ?? type].Parse(new XmlString(stringValue)); 114 117 } 115 118 catch (FormatException e) {
Note: See TracChangeset
for help on using the changeset viewer.