I must work with an object DeviceDefinitions containing an array of elements DeviceDef with a specific "layout" :
<DeviceDefinitions>
<!-- First null definition -->
<DeviceDef>
<Code>0</Code>
<Id>0</Id>
<Year>0</Year>
<Month>0</Month>
<Day>0</Day>
<DeviceDef>
<!-- Second null definition -->
<DeviceDef>
<Code>0</Code>
<Id>0</Id>
<Year>0</Year>
<Month>0</Month>
<Day>0</Day>
<DeviceDef>
...
<!-- 100th null definition -->
<DeviceDef>
<Code>0</Code>
<Id>0</Id>
<Year>0</Year>
<Month>0</Month>
<Day>0</Day>
<DeviceDef>
</DeviceDefinitions>
As I am retrieving this collection of objects from a wcf(soap) service, this is more or less the way the DeviceDefinitions object is serialized with sometimes thousands of DeviceDef items. I need to call this wcf service 300 times by second and the collection in the xml is quite huge even if with default values.
In my example here it's contains a collection of DeviceDef objects , and when I deserialize this file I should have exactly 100 DeviceDef objects in my collection just as in the preceding xml example. The problem, that I facing is that all the DeviceDef elements in this collection are in fact just some placeholders : they contains only default values... So I am trying to find a way to have a more compact xml document when I serialize my DeviceDefinitions collection and retrieve back the exact same 100 default DeviceDef items in my collection when I deserialize the xml document. So in fact I wants something like that when the object is serialized and contain only DeviceDef items with default values :
<DeviceDefinitions Count="100" />
And here the C# class when deserialized :
public class DeviceDefinitions
{
private DeviceDef[] array = new DeviceDef[100];
}
it should contain 100 DeviceDef object initilized from it's default constructor. So basicaly, I am about to write a custom serailizer or switch to protobuff because the structure is realy huge now (whenever I call the wcf service, I receive 800 ko for one collection of DeviceDefinitions even when all the 100 DeviceDeff object in it are all the same. But is there any way to do it "natively"in .net or does I have to write a specific xml de/serialiser ?