Hi All,
I am using a generic list to contain a list of "Zone" objects.
I also have a "ZoneConfiguration" object that is part of a header for all zones.
I have created a Zones generic list and added a publi serialisable property called ZOneConfiguration.
Now when I serialise Zones there is not a ZoneCOnfiguratin object included.
Is it possible to have public properties serialised as part of a generic list?
This is my Zones definitaion, the zone collection serializes fine it is just the ZoneConfigurations that does not.
Code:
public class Zones : List<Zone>
{
public event OnZoneAdded ZoneAdded;
public event OnZoneChanged ZoneChanged;
public event OnZoneConfigurationChanged ZoneConfigurationChanged;
private ZoneConfiguration zoneConfiguration = new ZoneConfiguration();
public ZoneConfiguration ZoneConfiguration
{
get{return zoneConfiguration;}
set
{
zoneConfiguration = value;
//Dont do anything if there isn't any change
if (Utilities.Serialiser.Compare(this, zoneConfiguration, typeof(ZoneConfiguration))) { return; }
//Change the ZoneConfiguraton
resetConfiguration();
if (ZoneConfigurationChanged != null) { ZoneConfigurationChanged(); }
}
}
public new void Add(Zone item)
{
//See if we need to add or change
for (int i = 0; i < Count; i++)
{
if (this[i].ZoneID == item.ZoneID)
{
//Dont do anything if there isn't any change
if (Utilities.Serialiser.Compare(this[i], item, typeof(Zone))) { return; }
//Delete old area from totals
ZoneConfiguration.TotalArea -= this[i].ZoneArea;
if (this[i].DesignZone) { ZoneConfiguration.DesignArea -= this[i].ZoneArea; }
//Change the item
this[i] = item;
//Add new area to totals
ZoneConfiguration.TotalArea += item.ZoneArea;
if (item.DesignZone) { ZoneConfiguration.DesignArea += item.ZoneArea; }
//Bubbble event
if (ZoneChanged != null) { ZoneChanged(item); }
return;
}
}
//Add the new item
base.Add(item);
ZoneConfiguration.TotalArea += item.ZoneArea;
if (item.DesignZone) { ZoneConfiguration.DesignArea += item.ZoneArea; }
if (ZoneAdded != null) { ZoneAdded(item); }
}
private void resetConfiguration()
{
zoneConfiguration.TotalArea = 0;
zoneConfiguration.DesignArea = 0;
foreach (Zone z in this)
{
zoneConfiguration.TotalArea += z.ZoneArea;
if (z.DesignZone) { zoneConfiguration.DesignArea += z.ZoneArea; }
}
}
}
======================================
"They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad."
--Shakespeare
======================================