xsd.exe /classes cwmp-1-1.xsd を使用して C# コードを生成します。
次のコードは、ツールによって生成されます。
public partial class Array
{
[System.Xml.Serialization.XmlAnyElementAttribute()]
public System.Xml.XmlElement[] Any;
[System.Xml.Serialization.XmlAttributeAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified)]
public string arrayType;
[System.Xml.Serialization.XmlAttributeAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified)]
public string offset;
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool offsetSpecified;
[System.Xml.Serialization.XmlAttributeAttribute(DataType = "ID")]
public string id;
[System.Xml.Serialization.XmlAttributeAttribute(DataType = "anyURI")]
public string href;
[System.Xml.Serialization.XmlAnyAttributeAttribute()]
public System.Xml.XmlAttribute[] AnyAttr;
}
public partial class EventList : Array
{
}
public partial class EventStruct
{
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string EventCode;
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string CommandKey;
}
public partial class Inform
{
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
public DeviceIdStruct DeviceId;
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
public EventList Event;
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
public uint MaxEnvelopes;
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
public System.DateTime CurrentTime;
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
public uint RetryCount;
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
public ParameterValueList ParameterList;
}
そして私のコード
Inform inform = new Inform();
inform.Event = new EventList();
EventStruct es = new EventStruct();
es.EventCode = "0 BOOTSTRAP";
es.CommandKey = "";
私の問題は、追加es
する方法ですinform.Event
クラスの Inform をシリアライザ/デシリアライズする方法。