说我有:
[DataContract(Name=,Namespace=)]
[KnownType(typeof(B))]
class A
{
[DataMember]
public B B{get;set;}
}
[DataContract(Name=,Namespace=)]
class B
{
public string Something{get;set;}
}
...
// ms = memory stream
// writerSession = XmlBinaryWriterSession
using (var writer = XmlDictionaryWriter.CreateBinaryWriter(ms, null, writerSession))
{
var serializer = new DataContractSerializer(typeof(SerializedFeedItem));
serializer.WriteObject(writer, serItem);
writer.Flush();
...
}
现在我看到只有A类的xml字典字符串被添加到编写器会话中。我想知道如何让串行器也写出类型B的字符串。 问题与使用XmlDictionary相关技术压缩序列化内容有关。
提前致谢。