问题描述
我有通过 XmlSerializer
序列化为 XML 的类:
[System.SerializableAttribute()]
public partial class Coupon
{
private string couponCodeField;
private int quantityField;
public string CouponCode
{
get
{
return this.couponCodeField;
}
set
{
this.couponCodeField = value;
}
}
public int Quantity
{
get
{
return this.quantityField;
}
set
{
this.quantityField = value;
}
}
}
序列化后的输出为:
<Coupon>
<CouponCode>9900000555780</CouponCode>
<Quantity>965</Quantity>
</Coupon>
就我而言,我需要将生成的 XML 中的所有属性类型作为 XML 属性发送。 所以我需要输出看起来像这样:
<Coupon>
<CouponCode type="xs:string">9900000555780</CouponCode>
<Quantity type="xs:integer">965</Quantity>
</Coupon>
有人知道如何在不将每个属性从简单类型更改为类的情况下做到这一点吗?
也许是一些 XmlSerializer
属性?或者一些对所有属性通用的自定义属性?
喜欢
[CustomAttr.typespecify]
public int Quantity
{
get
{
return this.quantityField;
}
set
{
this.quantityField = value;
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)