refactor: remove title description field

This commit is contained in:
Michael Green
2023-02-21 22:17:06 +11:00
parent fef758c32c
commit f84d5e8ec7
2 changed files with 73 additions and 58 deletions

View File

@@ -343,7 +343,7 @@ namespace gaseous_identifier.classes
switch (xmlGameDetail.Name.ToLower()) switch (xmlGameDetail.Name.ToLower())
{ {
case "description": case "description":
gameObject.Description = xmlGameDetail.InnerText; //gameObject.Description = xmlGameDetail.InnerText;
break; break;
case "rom": case "rom":

View File

@@ -101,66 +101,81 @@ if (availablePlatforms.Count > 0)
} }
} }
Console.WriteLine("Examining files"); //Console.WriteLine("Examining files");
string[] romPathContents = Directory.GetFiles(scanPath); //string[] romPathContents = Directory.GetFiles(scanPath);
foreach (string romFile in romPathContents) //foreach (string romFile in romPathContents)
{ //{
Console.WriteLine("Checking " + romFile); // Console.WriteLine("Checking " + romFile);
var stream = File.OpenRead(romFile); // var stream = File.OpenRead(romFile);
var md5 = MD5.Create(); // var md5 = MD5.Create();
byte[] md5HashByte = md5.ComputeHash(stream); // byte[] md5HashByte = md5.ComputeHash(stream);
string md5Hash = BitConverter.ToString(md5HashByte).Replace("-", "").ToLowerInvariant(); // string md5Hash = BitConverter.ToString(md5HashByte).Replace("-", "").ToLowerInvariant();
var sha1 = SHA1.Create(); // var sha1 = SHA1.Create();
byte[] sha1HashByte = sha1.ComputeHash(stream); // byte[] sha1HashByte = sha1.ComputeHash(stream);
string sha1Hash = BitConverter.ToString(sha1HashByte).Replace("-", "").ToLowerInvariant(); // string sha1Hash = BitConverter.ToString(sha1HashByte).Replace("-", "").ToLowerInvariant();
bool gameFound = false; // bool gameFound = false;
foreach (gaseous_identifier.objects.RomSignatureObject tosecList in romSignatures) // foreach (gaseous_identifier.objects.RomSignatureObject tosecList in romSignatures)
{ // {
foreach (gaseous_identifier.objects.RomSignatureObject.Game gameObject in tosecList.Games) // foreach (gaseous_identifier.objects.RomSignatureObject.Game gameObject in tosecList.Games)
{ // {
foreach (gaseous_identifier.objects.RomSignatureObject.Game.Rom romObject in gameObject.Roms) // foreach (gaseous_identifier.objects.RomSignatureObject.Game.Rom romObject in gameObject.Roms)
{ // {
if (romObject.Md5 != null) // if (romObject.Md5 != null)
{ // {
if (md5Hash == romObject.Md5.ToLowerInvariant()) // if (md5Hash == romObject.Md5.ToLowerInvariant())
{ // {
// match // // match
gameFound = true; // gameFound = true;
} // }
} // }
if (romObject.Sha1 != null) // if (romObject.Sha1 != null)
{ // {
if (md5Hash == romObject.Sha1.ToLowerInvariant()) // if (md5Hash == romObject.Sha1.ToLowerInvariant())
{ // {
// match // // match
gameFound = true; // gameFound = true;
} // }
} // }
if (gameFound == true) // if (gameFound == true)
{ // {
Console.WriteLine(romObject.Name); // Console.WriteLine(romObject.Name);
gaseous_identifier.objects.RomSignatureObject.Game gameSignature = gameObject; // gaseous_identifier.objects.RomSignatureObject.Game gameSignature = gameObject;
gameSignature.Roms.Clear(); // gameSignature.Roms.Clear();
gameSignature.Roms.Add(romObject); // 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)
{
foreach (gaseous_identifier.objects.RomSignatureObject.Game gameObject in romSignatureObject.Games)
{
if (gameObject.Name == SearchTitle)
{
var jsonSerializerSettings = new JsonSerializerSettings(); var jsonSerializerSettings = new JsonSerializerSettings();
jsonSerializerSettings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter()); jsonSerializerSettings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter());
jsonSerializerSettings.NullValueHandling = NullValueHandling.Ignore; jsonSerializerSettings.NullValueHandling = NullValueHandling.Ignore;
Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(gameSignature, Newtonsoft.Json.Formatting.Indented, jsonSerializerSettings)); Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(gameObject, 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");
}
} }