Skip to content

Instantly share code, notes, and snippets.

@DanTheMan827
Created April 16, 2020 23:30
Show Gist options
  • Save DanTheMan827/ccc56b477465bec91ab13923d3f3f2cf to your computer and use it in GitHub Desktop.
Save DanTheMan827/ccc56b477465bec91ab13923d3f3f2cf to your computer and use it in GitHub Desktop.
using System.Collections.Generic;
using System.Xml.Serialization;
[XmlRoot(ElementName = "datafile")]
public class DatFile
{
[XmlRoot(ElementName = "header")]
public class DatHeader
{
[XmlElement(ElementName = "name")]
public string Name;
[XmlElement(ElementName = "description")]
public string Description;
[XmlElement(ElementName = "version")]
public string Version;
[XmlElement(ElementName = "author")]
public string Author;
[XmlElement(ElementName = "homepage")]
public string Homepage;
[XmlElement(ElementName = "url")]
public string Url;
}
[XmlRoot(ElementName = "game")]
public class DatGame
{
[XmlRoot(ElementName = "rom")]
public class DatRom
{
[XmlAttribute(AttributeName = "name")]
public string Name;
[XmlAttribute(AttributeName = "size")]
public long Size;
[XmlAttribute(AttributeName = "crc")]
public string Crc32;
[XmlAttribute(AttributeName = "md5")]
public string Md5;
[XmlAttribute(AttributeName = "sha1")]
public string Sha1;
public bool ShouldSerializeSize() => Size > 0;
}
[XmlAttribute(AttributeName = "name")]
public string Name;
[XmlElement(ElementName = "description")]
public string Description;
[XmlElement(ElementName = "rom")]
public List<DatRom> Roms = new List<DatRom>();
}
[XmlElement(ElementName = "header")]
public DatHeader Header = new DatHeader();
[XmlElement(ElementName = "game")]
public List<DatGame> Games = new List<DatGame>();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment