File tree Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -175,7 +175,26 @@ private void Map(object x, XElement root)
175
175
var toConvert = value . ToString ( ) ;
176
176
if ( ! string . IsNullOrEmpty ( toConvert ) )
177
177
{
178
- prop . SetValue ( x , XmlConvert . ToDateTimeOffset ( toConvert ) , null ) ;
178
+ DateTimeOffset deserialisedValue ;
179
+ try
180
+ {
181
+ deserialisedValue = XmlConvert . ToDateTimeOffset ( toConvert ) ;
182
+ prop . SetValue ( x , deserialisedValue , null ) ;
183
+ }
184
+ catch ( Exception )
185
+ {
186
+ object result ;
187
+ if ( TryGetFromString ( toConvert , out result , type ) )
188
+ {
189
+ prop . SetValue ( x , result , null ) ;
190
+ }
191
+ else
192
+ {
193
+ //fallback to parse
194
+ deserialisedValue = DateTimeOffset . Parse ( toConvert ) ;
195
+ prop . SetValue ( x , deserialisedValue , null ) ;
196
+ }
197
+ }
179
198
}
180
199
}
181
200
else if ( type == typeof ( Decimal ) )
@@ -223,7 +242,7 @@ private void Map(object x, XElement root)
223
242
object result ;
224
243
if ( TryGetFromString ( value . ToString ( ) , out result , type ) )
225
244
{
226
- prop . SetValue ( x , value , null ) ;
245
+ prop . SetValue ( x , result , null ) ;
227
246
}
228
247
else
229
248
{
You can’t perform that action at this time.
0 commit comments