我有这段代码由于某种原因没有写名称或命名空间或属性
public class MultiSpeakHeader : MessageHeader
{
protected override void OnWriteHeaderContents(XmlDictionaryWriter writer, MessageVersion messageVersion)
{
writer.WriteAttributeString("AppName", "A");
writer.WriteAttributeString("AppVersion", "1");
writer.WriteAttributeString("CSUnits", "feet");
}
public override string Name
{
get { return "MultiSpeakMsgHeader"; }
}
public override string Namespace
{
get { return "http://www.multispeak.org/Version_3.0"; }
}
}
this 类实例的结果如下:
<MultiSpeakHeader xmlns="http://schemas.datacontract.org/2004/07/my.app" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"/>
我需要这个:
<MultiSpeakMsgHeader xmlns="http://www.multispeak.org/Version_3.0" AppName="A" AppVersion="1" CSUnits="feet" />
代码使用:
AddressHeader[] header = { AddressHeader.CreateAddressHeader(new MultiSpeakHeader()) };