polenter / SharpSerializer

SharpSerializer can serialize types like: multidimensional array, nested array, array-of-arrays, polymorphic object (where value is inherited from the property type), generic type, generic listing (i.e. dictionary, collection) and many more, with a single line of code
https://www.sharpserializer.net
Other
114 stars 28 forks source link

SharpSerializer Is failing when object has non existing properties #12

Open dmitry-web opened 5 years ago

dmitry-web commented 5 years ago

SharpSerializer Is failing when object has non existing properties. Just need to check if Dictionary has key line code here

leotop commented 5 years ago

How fix it?

dmitry-web commented 5 years ago

How fix it?

Try to override SharpSerializer with your classes and check if key exists return _objectCache.Any(x => x.Key == referenceTarget.Reference.Id) ? _objectCache[referenceTarget.Reference.Id] : null;