/// <summary> /// Write out DatItem using the supplied StreamWriter /// </summary> /// <param name="svw">SeparatedValueWriter to output to</param> /// <param name="datItem">DatItem object to be output</param> private void WriteDatItem(SeparatedValueWriter svw, DatItem datItem) { // Separated values should only output Rom and Disk if (datItem.ItemType != ItemType.Disk && datItem.ItemType != ItemType.Rom) { return; } // Build the state // TODO: Can we have some way of saying what fields to write out? Support for read extends to all fields now string[] fields = new string[14]; // 18; fields[0] = Header.FileName; fields[1] = Header.Name; fields[2] = Header.Description; fields[3] = datItem.Machine.Name; fields[4] = datItem.Machine.Description; switch (datItem.ItemType) { case ItemType.Disk: var disk = datItem as Disk; fields[5] = "disk"; fields[6] = string.Empty; fields[7] = disk.Name; fields[8] = string.Empty; fields[9] = string.Empty; fields[10] = disk.MD5?.ToLowerInvariant(); //fields[11] = string.Empty; fields[11] = disk.SHA1?.ToLowerInvariant(); fields[12] = string.Empty; //fields[13] = string.Empty; //fields[14] = string.Empty; //fields[15] = string.Empty; fields[13] = disk.ItemStatus.ToString(); break; case ItemType.Media: var media = datItem as Media; fields[5] = "media"; fields[6] = string.Empty; fields[7] = media.Name; fields[8] = string.Empty; fields[9] = string.Empty; fields[10] = media.MD5?.ToLowerInvariant(); //fields[11] = string.Empty; fields[11] = media.SHA1?.ToLowerInvariant(); fields[12] = media.SHA256?.ToLowerInvariant(); //fields[13] = string.Empty; //fields[14] = string.Empty; //fields[15] = media.SpamSum?.ToLowerInvariant(); fields[13] = string.Empty; break; case ItemType.Rom: var rom = datItem as Rom; fields[5] = "rom"; fields[6] = rom.Name; fields[7] = string.Empty; fields[8] = rom.Size?.ToString(); fields[9] = rom.CRC?.ToLowerInvariant(); fields[10] = rom.MD5?.ToLowerInvariant(); //fields[11] = rom.RIPEMD160?.ToLowerInvariant(); fields[11] = rom.SHA1?.ToLowerInvariant(); fields[12] = rom.SHA256?.ToLowerInvariant(); //fields[13] = rom.SHA384?.ToLowerInvariant(); //fields[14] = rom.SHA512?.ToLowerInvariant(); //fields[15] = rom.SpamSum?.ToLowerInvariant(); fields[13] = rom.ItemStatus.ToString(); break; } svw.WriteString(CreatePrefixPostfix(datItem, true)); svw.WriteValues(fields, false); svw.WriteString(CreatePrefixPostfix(datItem, false)); svw.WriteLine(); svw.Flush(); }
/// <summary> /// Write out the footer-separator to the stream, if any exists /// </summary> /// <param name="svw">SeparatedValueWriter to write to</param> private void WriteFooterSeparator(SeparatedValueWriter svw) { svw.WriteString("\n"); svw.Flush(); }