I have the following serialized XML:
DataDescriptor
<d5p1:TimePastToInitializeData >
<d5p1:Hours>2</d5p1:Hours>
<d5p1:Minutes>10</d5p1:Minutes>
<d5p1:Seconds>5</d5p1:Seconds>
</d5p1:TimePastToInitializeData>
<d5p1:PollRate >
<d5p1:Hours>2</d5p1:Hours>
<d5p1:Minutes>10</d5p1:Minutes>
<d5p1:Seconds>5</d5p1:Seconds>
</d5p1:PollRate>
</Value>
</KeyValueOfstringanyType>
With this order, the PollRate property is not constructed and the resulting deserialized object has a null value for this field.
If, however, I change the order as follows:
DataDescriptor
<d5p1:PollRate >
<d5p1:Hours>2</d5p1:Hours>
<d5p1:Minutes>10</d5p1:Minutes>
<d5p1:Seconds>5</d5p1:Seconds>
</d5p1:PollRate>
<d5p1:TimePastToInitializeData >
<d5p1:Hours>2</d5p1:Hours>
<d5p1:Minutes>10</d5p1:Minutes>
<d5p1:Seconds>5</d5p1:Seconds> </d5p1:TimePastToInitializeData>
</Value>
</KeyValueOfstringanyType>
both properties PollRate and TimePastToInitializeData are constructed and initialized properly.
public class DataDescriptor
{
RefreshRate pastTime;
[DataMember]
public RefreshRate TimePastToInitializeData
{
get; set;
}
RefreshRate pollRate;
[DataMember]
public RefreshRate PollRate
{
get; set;
}
[OnDeserializing]
void Initialize(StreamingContext c)
{
// should I do this??
}
}
And RefreshRate:
[DataContract( Namespace = "http//www.emssatcom.com/occ600")]
[Serializable]
public class RefreshRate : Observable
{
public RefreshRate()
{ }
int hours;
[DataMember]
public int Hours
{
get; set;
}
int mins;
[DataMember]
public int Minutes
{
get; set;
}
int secs;
[DataMember]
public int Seconds
{
get; set;
}
int ms;
[DataMember]
public int MilliSeconds
{
get; set;
}
}