我有这样的类结构:
public List<EndpointInfo> EndpointInfoList = new List<EndpointInfo> ();
[Serializable]
public class EndpointInfo
{
public List<PairedEndpoint> PairedEndpoints { get; set; }
public EndpointInfo ()
{
PairedEndpoints = new List<PairedEndpoint> ();
}
}
public class PairedEndpoint
{
public List<int> ConnectedChannels { get; set; }
public PairedEndpoint ()
{
ConnectedChannels = new List<int>();
}
}
我希望最终的XML看起来像这样
<?xml version="1.0"?>
<ArrayOfEndpointInfo xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<EndpointInfo>
<PairedEndpoints>
<PairedEndpoint>
<ConnectedChannels>
<ConnectedChannel>1</ConnectedChannel>
<ConnectedChannel>2</ConnectedChannel>
</ConnectedChannels>
</PairedEndpoint>
<PairedEndpoint>
<ConnectedChannels>
<ConnectedChannel>3</ConnectedChannel>
<ConnectedChannel>4</ConnectedChannel>
</ConnectedChannels>
</PairedEndpoint>
</PairedEndpoints>
</EndpointInfo>
</ArrayOfEndpointInfo>
然而,我并不清楚如何序列化PairedEndpoints以创建其中的通道列表。如果您能提供任何帮助,我将不胜感激。