我正在尝试将以下类序列化为 XML:
[XmlRoot("FCS_SET_SCH")]
public class DDCSendReceiveScheduleXml
{
private const string TABLE_NAME = "DDCScheduler";
[XmlElement("schedule",Order=1)]
public List<ScheduleXml> ScheduleList { get; set; }
[XmlElement("timetable",Order=2)]
public List<TimeTableXml> TimeTableXmlList { get; set; }
public DDCSendReceiveScheduleXml()
{
}
}
如果我要分别序列化一个对象,则 Order 标志有效,但它似乎无法控制列表中的排序。
这是 XmlSerializer 目前序列化两个列表的方式:
<FCS_SET_SCH xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<schedule>...</schedule>
<schedule>...</schedule>
<timetable>...</timetable>
<timetable>...</timetable>
</FCS_SET_SCH>
有什么方法可以控制序列化,以便上述顺序按此顺序排列?
<FCS_SET_SCH xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<schedule>...</schedule>
<timetable>...</timetable>
<schedule>...</schedule>
<timetable>...</timetable>
</FCS_SET_SCH>