我有一个对象,我正在使用xml-serializer进行序列化。是否可以实质上插入任意子根节点,并指定属于此根节点的某些属性?
一些属性 public int ID {get;组; }
public object ActivityType { get; set; }
public int ObjectId { get; set; }
public string RelatedObjects { get; set; }
public string Parameters { get; set; }
public string Tag { get; set; }
public List<Condition> Conditions { get; set; }
public bool OnlySaveIfValid { get; set; }
现在,当我用xml序列化序列化时,我得到:
<?xml version="1.0" encoding="utf-16"?>
<FNActivity>
<ID>0</ID>
<ObjectId>0</ObjectId>
<Conditions>
<Condition>
<Critical>false</Critical>
<ValidIf>false</ValidIf>
<IsValid>false</IsValid>
</Condition>
<Condition>
<Critical>false</Critical>
<ValidIf>false</ValidIf>
<IsValid>false</IsValid>
</Condition>
</Conditions>
<OnlySaveIfValid>false</OnlySaveIfValid>
</FNActivity>
我想得到的Xml是这样的:
<?xml version="1.0" encoding="utf-16"?>
<FNActivity>
<ID>0</ID>
<ObjectId>0</ObjectId>
**<VALIDATION>
<Conditions>
<Condition>
<Critical>false</Critical>
<ValidIf>false</ValidIf>
<IsValid>false</IsValid>
</Condition>
<Condition>
<Critical>false</Critical>
<ValidIf>false</ValidIf>
<IsValid>false</IsValid>
</Condition>
</Conditions>
<OnlySaveIfValid>false</OnlySaveIfValid>
**</VALIDATION>
</FNActivity>