This project is read-only.
1
Vote

Null values in default class property values

description

With defaut SharpSerializer.Library:

class SampleProp
{
    public SampleProp()
    {
        Str1 = "Str1InitialValue";
        Str2 = "Str2InitialValue";
    }
    public string Str1 { get; set; }
    public string Str2 { get; set; }
}
var data = new SampleProp{ Str1 = null };
var serializer = new SharpSerializer();
serializer.Serialize(obj, stream);
data = (SampleProp)serializer.Deserialize(stream);
// data.Str1 is "Str1InitialValue" because null values is not assigned.
// Attach changes for:
var settings = new SharpSerializerXmlSettings();
// New configuration for ObjectFactory
settings.AdvancedSettings.SetNullProperties = true;
serializer = new SharpSerializer(settings);
// Sorry, second zip is ok

file attachments

comments