We are currently trying to serialize a collection of objects in xml using XmlSerializer.Serialize
We tested the XmlSerializer with the following stubs
private static void TestMethod()
{
ChartContentConfig Config = new ChartContentConfig();
Config.DefinitionId = "6790e2ca-be93-48dd-94e7-f8ec0f6e5fd4";
Config.Sorts = null;
Config.DataFields = new DataField[1];
Config.DataFields[0] = new DataField()
{
Aggregator = AggregateFunction.Sum,
ApplyFilter = ApplyFilter.Before,
FieldName = "Hello",
FieldType = typeof(decimal).ToString(),
FilterToValue = "",
FilterFromValue = "",
FilterOperator = FilterOperator.None,
IsVisible = false,
DisplayName = "Hello",
DefaultStyle = "DefaultFormat"
};
Type configType = typeof(DataField);
DataField DataField = Config.DataFields[0];
DataField.MarkerFormat = "MarkerFormatTest";
DataField.SeriesColour = "SeriesColourTest";
DataField.TestProperty = AggregateFunction.Average;
DataField.Aggregator = AggregateFunction.Average;
string test = SerializeConfig(DataField, configType).InnerXml;
System.Diagnostics.Debug.WriteLine(test);
}
xml returns a penalty, however each attribute appears separately from the Aggregator and ApplyFilter enumerations. Now we are completely lost for what causes this, because everything seems beautiful. Here are the definitions for both below.
[XmlAttribute]
public AggregateFunction Aggregator { get; set; }
[XmlAttribute]
public ApplyFilter ApplyFilter { get; set; }
with tags
[Serializable]
[DebuggerStepThrough]
[DesignerCategory("code")]
[GeneratedCode("xsd", "4.0.30319.1")]
[XmlRoot(Namespace = "", IsNullable = false)]
at the top of this class.
The listings are as follows:
[Serializable]
[GeneratedCode("xsd", "4.0.30319.1")]
public enum AggregateFunction
{
None = 0,
Group = 1,
Sum = 2,
Max = 3,
Min = 4,
Average = 5,
Count = 6,
Project = 7,
Value = 8,
}
and
[Serializable]
[GeneratedCode("xsd", "4.0.30319.1")]
public enum ApplyFilter
{
OnDisplay = 0,
BeforeGroup = 1,
AfterGroup = 2,
}
Any help would be greatly appreciated.
Thanks,
Mt.