は、私は次のクラスXMLシリアル化の問題
[Serializable]
[XmlRoot("fileset")]
public class FileSet
{
[XmlArray("")]
[XmlArrayItem(ElementName="file")]
public List<File> Files { get; set; }
[XmlAttribute("complete")]
public string Complete { get; set; }
[XmlAttribute("id")]
public string ID { get; set; }
[XmlAttribute("search_expression")]
public string Search_Expression { get; set; }
[XmlAttribute("format_expression")]
public string Format_Expression { get; set; }
public FileSet()
{ }
}
[Serializable]
[XmlRoot("file")]
public class File
{
[XmlElement("action")]
public List<Action> Actions { get; set; }
[XmlAttribute("type")]
public string Type { get; set; }
[XmlAttribute("format")]
public string Format { get; set; }
[XmlAttribute("filefound")]
public string FileFound { get; set; }
[XmlAttribute("filename")]
public string FileName { get; set; }
[XmlAttribute("size")]
public long Size { get; set; }
[XmlAttribute("creationTime")]
public DateTime CreationTime { get; set; }
public File() { }
}
[Serializable]
[XmlRoot("action")]
public class Action
{
[XmlAttribute("task")]
public string Task { get; set; }
[XmlAttribute("sequenceid")]
public int SequenceId { get; set; }
[XmlAttribute("source")]
public string Source { get; set; }
[XmlAttribute("destination")]
public string Destination { get; set; }
[XmlAttribute("desc")]
public string Description { get; set; }
public Action()
{ }
}
を持って、私が提供するXMLは次のタイプ
<fileset complete="y" id="NY1109162" search_expression="" format_expression="">
<file type="Datafile" format="NYyymmddn.zip" filefound="y" filename="NY1109162.zip" size="91703" creationTime="">
<actions>
<action task="move" sequenceid="1" source="" destination="" desc="move to archive"></action>
<action task="copy" sequenceid="2" source="" destination="" desc="copy to production"></action>
<action task="unzip" sequenceid="3" source="" destination="" desc="unzip files to working directory"></action>
</actions>
</file>
<file type="Repfile" format="NYyymmddn.rep" filefound="y" filename="NY1109162.rep" size="17" creationTime="">
<actions>
<action task="copy" sequenceid="1" source="" destination="" desc="copy to archive"></action>
<action task="copy" sequenceid="2" source="" destination="" desc="copy to production"></action>
</actions>
</file>
<file type="Imagefile" format="NYyymmddn_images.zip" filefound="y" filename="NY1109162_images.zip" size="116550" creationTime="">
<actions>
<action task="move" sequenceid="1" source="" destination="" desc="move to archive"></action>
<action task="copy" sequenceid="2" source="" destination="" desc="copy to production"></action>
<action task="unzip" sequenceid="3" source="" destination="" desc="unzip files to working directory"></action>
</actions>
</file>
</fileset>
である。しかし、私は戻って、XMLへの私のファイルセットオブジェクトをシリアル化するとき、それは追加されます私が欲しくない余分なタグに。 直列化出力は
<fileset complete="y" id="NY1109162" search_expression="" format_expression="">
<Files>
<file type="Datafile" format="NYyymmddn.zip" filefound="y" filename="NY1109162.zip" size="91703" creationTime="">
<actions>
<action task="move" sequenceid="1" source="" destination="" desc="move to archive"></action>
<action task="copy" sequenceid="2" source="" destination="" desc="copy to production"></action>
<action task="unzip" sequenceid="3" source="" destination="" desc="unzip files to working directory"></action>
</actions>
</file>
<file type="Repfile" format="NYyymmddn.rep" filefound="y" filename="NY1109162.rep" size="17" creationTime="">
<actions>
<action task="copy" sequenceid="1" source="" destination="" desc="copy to archive"></action>
<action task="copy" sequenceid="2" source="" destination="" desc="copy to production"></action>
</actions>
</file>
<file type="Imagefile" format="NYyymmddn_images.zip" filefound="y" filename="NY1109162_images.zip" size="116550" creationTime="">
<actions>
<action task="move" sequenceid="1" source="" destination="" desc="move to archive"></action>
<action task="copy" sequenceid="2" source="" destination="" desc="copy to production"></action>
<action task="unzip" sequenceid="3" source="" destination="" desc="unzip files to working directory"></action>
</actions>
</file>
</Files>
</fileset>
誰も助けてくださいすることができ、あります?
はい、絶対に正しく!私はそれについて考えていませんでした。今では、私は自分自身のXMLシリアライザを実装しています。 – Sagar