c# - XML Serialization Customized Partially -
in brief need custom class project partially
public class project : ixmlserializable { [xmlattribute] public string name; [xmlignore] public string[] contents; public xmlschema getschema() { return null; } public void readxml(xmlreader reader) { if (reader.hasattributes) { contents=new string[reader.attributecount]; (int = 0; < reader.attributecount; i++) { reader.movetoattribute(i); string attr = reader.name; regex reg = new regex(@"content_\d+"); if (reg.ismatch(attr)) { contents[i] = reader.value; } } } } public void writexml(xmlwriter writer) { (int = 0; < contents.count(); i++) { writer.writeattributestring("content_" + i, contents[i]); } } }
i want name serialized custom contents of array (i need make attribute in project node ). happen when implement project class name kept null idea how can this?
in readxml
method never assign name
property. add
name= "somevalue";
Comments
Post a Comment