I have a data model consisting of large complex classes. Here you can see the general structure of my classes in following (one of the smallest classes of my model) example:
[DataContract(IsReference = true)]
public partial class Name : PresentationBase
{
[DataMember]
private SmartProperty<string> _first;
public SmartProperty<string> First
{
get { return this._first ?? (this._first = new SmartProperty<string>()); }
set
{
bool isModified = false;
if (this._first == null)
{
if (value != null)
{
isModified = true;
}
}
else if (value == null)
{
isModified = true;
}
else if (this._first.UnderlyingValue == null)
{
if (value.UnderlyingValue != null)
{
isModified = true;
}
}
else if (value.UnderlyingValue == null)
{
isModified = true;
}
else if (!value.UnderlyingValue.Equals(this._first.UnderlyingValue))
{
isModified = true;
}
this._first = value;
if (isModified)
{
this._first.IsModified = isModified;
this.OnPropertyChanged("First");
}
}
}
[DataMember]
private SmartProperty<string> _last;
public SmartProperty<string> Last
{
get { return this._last ?? (this._last = new SmartProperty<string>()); }
set
{
bool isModified = false;
if (this._last == null)
{
if (value != null)
{
isModified = true;
}
}
else if (value == null)
{
isModified = true;
}
else if (this._last.UnderlyingValue == null)
{
if (value.UnderlyingValue != null)
{
isModified = true;
}
}
else if (value.UnderlyingValue == null)
{
isModified = true;
}
else if (!value.UnderlyingValue.Equals(this._last.UnderlyingValue))
{
isModified = true;
}
this._last = value;
if (isModified)
{
this._last.IsModified = isModified;
this.OnPropertyChanged("Last");
}
}
}
[DataMember]
private SmartProperty<string> _maiden;
public SmartProperty<string> Maiden
{
get { return this._maiden ?? (this._maiden = new SmartProperty<string>()); }
set
{
bool isModified = false;
if (this._maiden == null)
{
if (value != null)
{
isModified = true;
}
}
else if (value == null)
{
isModified = true;
}
else if (this._maiden.UnderlyingValue == null)
{
if (value.UnderlyingValue != null)
{
isModified = true;
}
}
else if (value.UnderlyingValue == null)
{
isModified = true;
}
else if (!value.UnderlyingValue.Equals(this._maiden.UnderlyingValue))
{
isModified = true;
}
this._maiden = value;
if (isModified)
{
this._maiden.IsModified = isModified;
this.OnPropertyChanged("Maiden");
}
}
}
}
I'm using Json.net for serialization / deserialization operations. Because of the complexity of my model I'm wondering if is it possible to personalize the Json.net library to work more efficiently with my entities. It's not possible to revise my model because it's really a big project and any change will cause a big impact.
I tried a few Json serialization libraries other than Json.net including ServiceStack.Text, fastJson etc. But they were not useful for me. For example ServiceStack.Text doesn't serialize private fields, fastJson has problems on serializing complex entities as you can see on discussion page of the library...
Briefly, I downloaded the source code of Json.net to customize the library for my own entities but I got lost in the library. :) Do you have any suggestions for me to accomplish a performance improvement for this kind of entities? I'm serializing only private fields in my entities, so I think this could be a point but I don't know how to start.
Thanks,