From f84d5e8ec72c2df65015c96abdf206e2ea1e23a1 Mon Sep 17 00:00:00 2001 From: Michael Green <84688932+michael-j-green@users.noreply.github.com> Date: Tue, 21 Feb 2023 22:17:06 +1100 Subject: [PATCH] refactor: remove title description field --- gaseous-identifier/Classes/TosecParser.cs | 2 +- gaseous-identifier/Program.cs | 129 ++++++++++++---------- 2 files changed, 73 insertions(+), 58 deletions(-) diff --git a/gaseous-identifier/Classes/TosecParser.cs b/gaseous-identifier/Classes/TosecParser.cs index a55b985..abd47ac 100644 --- a/gaseous-identifier/Classes/TosecParser.cs +++ b/gaseous-identifier/Classes/TosecParser.cs @@ -343,7 +343,7 @@ namespace gaseous_identifier.classes switch (xmlGameDetail.Name.ToLower()) { case "description": - gameObject.Description = xmlGameDetail.InnerText; + //gameObject.Description = xmlGameDetail.InnerText; break; case "rom": diff --git a/gaseous-identifier/Program.cs b/gaseous-identifier/Program.cs index 382be23..0f5b344 100644 --- a/gaseous-identifier/Program.cs +++ b/gaseous-identifier/Program.cs @@ -101,66 +101,81 @@ if (availablePlatforms.Count > 0) } } -Console.WriteLine("Examining files"); -string[] romPathContents = Directory.GetFiles(scanPath); -foreach (string romFile in romPathContents) +//Console.WriteLine("Examining files"); +//string[] romPathContents = Directory.GetFiles(scanPath); +//foreach (string romFile in romPathContents) +//{ +// Console.WriteLine("Checking " + romFile); + +// var stream = File.OpenRead(romFile); + +// var md5 = MD5.Create(); +// byte[] md5HashByte = md5.ComputeHash(stream); +// string md5Hash = BitConverter.ToString(md5HashByte).Replace("-", "").ToLowerInvariant(); + +// var sha1 = SHA1.Create(); +// byte[] sha1HashByte = sha1.ComputeHash(stream); +// string sha1Hash = BitConverter.ToString(sha1HashByte).Replace("-", "").ToLowerInvariant(); + +// bool gameFound = false; +// foreach (gaseous_identifier.objects.RomSignatureObject tosecList in romSignatures) +// { +// foreach (gaseous_identifier.objects.RomSignatureObject.Game gameObject in tosecList.Games) +// { +// foreach (gaseous_identifier.objects.RomSignatureObject.Game.Rom romObject in gameObject.Roms) +// { +// if (romObject.Md5 != null) +// { +// if (md5Hash == romObject.Md5.ToLowerInvariant()) +// { +// // match +// gameFound = true; +// } +// } +// if (romObject.Sha1 != null) +// { +// if (md5Hash == romObject.Sha1.ToLowerInvariant()) +// { +// // match +// gameFound = true; +// } +// } +// if (gameFound == true) +// { +// Console.WriteLine(romObject.Name); + +// gaseous_identifier.objects.RomSignatureObject.Game gameSignature = gameObject; +// gameSignature.Roms.Clear(); +// gameSignature.Roms.Add(romObject); + +// var jsonSerializerSettings = new JsonSerializerSettings(); +// jsonSerializerSettings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter()); +// jsonSerializerSettings.NullValueHandling = NullValueHandling.Ignore; +// Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(gameSignature, Newtonsoft.Json.Formatting.Indented, jsonSerializerSettings)); +// break; +// } +// } +// if (gameFound == true) { break; } +// } +// if (gameFound == true) { break; } +// } +// if (gameFound == false) +// { +// Console.WriteLine("File not found in TOSEC library"); +// } +//} + +string SearchTitle = "California Games"; +foreach (gaseous_identifier.objects.RomSignatureObject romSignatureObject in romSignatures) { - Console.WriteLine("Checking " + romFile); - - var stream = File.OpenRead(romFile); - - var md5 = MD5.Create(); - byte[] md5HashByte = md5.ComputeHash(stream); - string md5Hash = BitConverter.ToString(md5HashByte).Replace("-", "").ToLowerInvariant(); - - var sha1 = SHA1.Create(); - byte[] sha1HashByte = sha1.ComputeHash(stream); - string sha1Hash = BitConverter.ToString(sha1HashByte).Replace("-", "").ToLowerInvariant(); - - bool gameFound = false; - foreach (gaseous_identifier.objects.RomSignatureObject tosecList in romSignatures) + foreach (gaseous_identifier.objects.RomSignatureObject.Game gameObject in romSignatureObject.Games) { - foreach (gaseous_identifier.objects.RomSignatureObject.Game gameObject in tosecList.Games) + if (gameObject.Name == SearchTitle) { - foreach (gaseous_identifier.objects.RomSignatureObject.Game.Rom romObject in gameObject.Roms) - { - if (romObject.Md5 != null) - { - if (md5Hash == romObject.Md5.ToLowerInvariant()) - { - // match - gameFound = true; - } - } - if (romObject.Sha1 != null) - { - if (md5Hash == romObject.Sha1.ToLowerInvariant()) - { - // match - gameFound = true; - } - } - if (gameFound == true) - { - Console.WriteLine(romObject.Name); - - gaseous_identifier.objects.RomSignatureObject.Game gameSignature = gameObject; - gameSignature.Roms.Clear(); - gameSignature.Roms.Add(romObject); - - var jsonSerializerSettings = new JsonSerializerSettings(); - jsonSerializerSettings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter()); - jsonSerializerSettings.NullValueHandling = NullValueHandling.Ignore; - Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(gameSignature, Newtonsoft.Json.Formatting.Indented, jsonSerializerSettings)); - break; - } - } - if (gameFound == true) { break; } + var jsonSerializerSettings = new JsonSerializerSettings(); + jsonSerializerSettings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter()); + jsonSerializerSettings.NullValueHandling = NullValueHandling.Ignore; + Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(gameObject, Newtonsoft.Json.Formatting.Indented, jsonSerializerSettings)); } - if (gameFound == true) { break; } - } - if (gameFound == false) - { - Console.WriteLine("File not found in TOSEC library"); } } \ No newline at end of file