Example #1
0
        private static Hashtable getCsvHashTable(HootCsv pHootCsvFile)
        {
            Hashtable csvHashTable = new Hashtable();

            foreach (HootCsvEntry he in pHootCsvFile.CsvEntries)
            {
                if (!csvHashTable.ContainsKey(he.FileName))
                {
                    csvHashTable.Add(he.FileName, he);
                }
            }

            return(csvHashTable);
        }
Example #2
0
        public static void AddCsvInformationToDataFile(string pCsvPath,
                                                       string pSourceDataFilePath, string pDestinationDataFilePath)
        {
            // Initialize CSV
            HootCsv hootCsvFile = new HootCsv();

            hootCsvFile.LoadFromFile(pCsvPath);

            // Initialize Source DAT
            datafile      dataFile   = new datafile();
            XmlSerializer serializer = new XmlSerializer(typeof(datafile));
            TextReader    textReader = new StreamReader(pSourceDataFilePath);

            dataFile = (datafile)serializer.Deserialize(textReader);
            textReader.Close();
            textReader.Dispose();

            // Get Csv HashTable
            Hashtable csvHashtable = getCsvHashTable(hootCsvFile);

            // Add Data to DAT File
            foreach (VGMToolbox.format.auditing.game g in dataFile.game)
            {
                if (csvHashtable.ContainsKey(g.name))
                {
                    HootCsvEntry csvEntry = (HootCsvEntry)csvHashtable[g.name];
                    g.description  = csvEntry.EnglishName;
                    g.board        = csvEntry.System + " [" + csvEntry.Chip + "]";
                    g.manufacturer = csvEntry.Company;
                    g.year         = csvEntry.ReleaseYear;

                    g.comment    = new string[1];
                    g.comment[0] = csvEntry.Composer;
                }
            }

            // Output DAT File
            TextWriter textWriter = new StreamWriter(pDestinationDataFilePath);

            serializer.Serialize(textWriter, dataFile);
            textWriter.Close();
            textWriter.Dispose();
        }