Example #1
0
        /// <summary>
        /// Write out DatItem using the supplied StreamWriter
        /// </summary>
        /// <param name="cmpw">ClrMameProWriter to output to</param>
        /// <param name="datItem">DatItem object to be output</param>
        private void WriteDatItem(ClrMameProWriter cmpw, DatItem datItem)
        {
            // Pre-process the item name
            ProcessItemName(datItem, true);

            // Build the state
            switch (datItem.ItemType)
            {
            case ItemType.Rom:
                var rom = datItem as Rom;
                cmpw.WriteStartElement("file");
                cmpw.WriteRequiredAttributeString("name", rom.Name);
                cmpw.WriteOptionalAttributeString("size", rom.Size?.ToString());
                cmpw.WriteOptionalAttributeString("date", rom.Date);
                cmpw.WriteOptionalAttributeString("crc", rom.CRC?.ToLowerInvariant());
                cmpw.WriteEndElement();
                break;
            }

            cmpw.Flush();
        }
Example #2
0
        /// <summary>
        /// Write out DatItem using the supplied StreamWriter
        /// </summary>
        /// <param name="datFile">DatFile to write out from</param>
        /// <param name="cmpw">ClrMameProWriter to output to</param>
        /// <param name="datItem">DatItem object to be output</param>
        private void WriteDatItem(ClrMameProWriter cmpw, DatItem datItem)
        {
            // Pre-process the item name
            ProcessItemName(datItem, true);

            // Build the state
            switch (datItem.ItemType)
            {
            case ItemType.Archive:
                var archive = datItem as Archive;
                cmpw.WriteStartElement("archive");
                cmpw.WriteRequiredAttributeString("name", archive.Name);
                cmpw.WriteEndElement();
                break;

            case ItemType.BiosSet:
                var biosSet = datItem as BiosSet;
                cmpw.WriteStartElement("biosset");
                cmpw.WriteRequiredAttributeString("name", biosSet.Name);
                cmpw.WriteOptionalAttributeString("description", biosSet.Description);
                cmpw.WriteOptionalAttributeString("default", biosSet.Default?.ToString().ToLowerInvariant());
                cmpw.WriteEndElement();
                break;

            case ItemType.Disk:
                var disk = datItem as Disk;
                cmpw.WriteStartElement("disk");
                cmpw.WriteRequiredAttributeString("name", disk.Name);
                cmpw.WriteOptionalAttributeString("md5", disk.MD5?.ToLowerInvariant(), quoteOverride: false);
                cmpw.WriteOptionalAttributeString("sha1", disk.SHA1?.ToLowerInvariant(), quoteOverride: false);
                cmpw.WriteOptionalAttributeString("flags", disk.ItemStatus.FromItemStatus(false));
                cmpw.WriteEndElement();
                break;

            case ItemType.Media:
                var media = datItem as Media;
                cmpw.WriteStartElement("media");
                cmpw.WriteRequiredAttributeString("name", media.Name);
                cmpw.WriteOptionalAttributeString("md5", media.MD5?.ToLowerInvariant(), quoteOverride: false);
                cmpw.WriteOptionalAttributeString("sha1", media.SHA1?.ToLowerInvariant(), quoteOverride: false);
                cmpw.WriteOptionalAttributeString("sha256", media.SHA256?.ToLowerInvariant(), quoteOverride: false);
                cmpw.WriteOptionalAttributeString("spamsum", media.SpamSum?.ToLowerInvariant());
                cmpw.WriteEndElement();
                break;

            case ItemType.Release:
                var release = datItem as Release;
                cmpw.WriteStartElement("release");
                cmpw.WriteRequiredAttributeString("name", release.Name);
                cmpw.WriteOptionalAttributeString("region", release.Region);
                cmpw.WriteOptionalAttributeString("language", release.Language);
                cmpw.WriteOptionalAttributeString("date", release.Date);
                cmpw.WriteOptionalAttributeString("default", release.Default?.ToString().ToLowerInvariant());
                cmpw.WriteEndElement();
                break;

            case ItemType.Rom:
                var rom = datItem as Rom;
                cmpw.WriteStartElement("rom");
                cmpw.WriteRequiredAttributeString("name", rom.Name);
                cmpw.WriteOptionalAttributeString("size", rom.Size?.ToString(), quoteOverride: false);
                cmpw.WriteOptionalAttributeString("crc", rom.CRC?.ToLowerInvariant(), quoteOverride: false);
                cmpw.WriteOptionalAttributeString("md5", rom.MD5?.ToLowerInvariant(), quoteOverride: false);
                cmpw.WriteOptionalAttributeString("sha1", rom.SHA1?.ToLowerInvariant(), quoteOverride: false);
                cmpw.WriteOptionalAttributeString("sha256", rom.SHA256?.ToLowerInvariant(), quoteOverride: false);
                cmpw.WriteOptionalAttributeString("sha384", rom.SHA384?.ToLowerInvariant(), quoteOverride: false);
                cmpw.WriteOptionalAttributeString("sha512", rom.SHA512?.ToLowerInvariant(), quoteOverride: false);
                cmpw.WriteOptionalAttributeString("spamsum", rom.SpamSum?.ToLowerInvariant(), quoteOverride: false);
                cmpw.WriteOptionalAttributeString("date", rom.Date);
                cmpw.WriteOptionalAttributeString("flags", rom.ItemStatus.FromItemStatus(false));
                cmpw.WriteEndElement();
                break;

            case ItemType.Sample:
                var sample = datItem as Sample;
                cmpw.WriteStartElement("sample");
                cmpw.WriteRequiredAttributeString("name", sample.Name);
                cmpw.WriteEndElement();
                break;
            }

            cmpw.Flush();
        }