[英]XmlElementName - Change during runtime
I am implementing a class object that is serializable. 我正在实现一个可序列化的类对象。
something like this: 像这样的东西:
StringWriter sw = new StringWriter();
XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
ns.Add("", "");
System.Xml.Serialization.XmlSerializer x =
new System.Xml.Serialization.XmlSerializer(this.GetType());
x.Serialize(sw, this,ns);
return sw.ToString();
I want the child class/objects to have different names depending on a flag. 我希望子类/对象根据标志具有不同的名称。 is there a ways to change the ElementName of the class prop.
有没有一种方法可以更改类prop的ElementName。 during run time without write a custom WriteXml?
在运行时无需编写自定义WriteXml?
Yes, but you won't like it. 是的,但是您不喜欢它。 IXmlSerializable
IXml可序列化
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.