[OfflineList] Implement subreaders for configuration items

This commit is contained in:
Matt Nadareski
2018-01-15 14:17:09 -08:00
parent aba67a5f28
commit 212f59ac8f

View File

@@ -174,87 +174,27 @@ namespace SabreTools.Library.DatFiles
// string screenshotsHeight = content; // Int32?
break;
case "infos":
// // TODO: Technically, this needs to be in its own subreader
// string title_visible = reader.GetAttribute("visible"); // (true|false)
// string title_inNamingOption = reader.GetAttribute("inNamingOption"); // (true|false)
// string title_default = reader.GetAttribute("default"); // (true|false)
// string location_visible = reader.GetAttribute("visible"); // (true|false)
// string location_inNamingOption = reader.GetAttribute("inNamingOption"); // (true|false)
// string location_default = reader.GetAttribute("default"); // (true|false)
// string publisher_visible = reader.GetAttribute("visible"); // (true|false)
// string publisher_inNamingOption = reader.GetAttribute("inNamingOption"); // (true|false)
// string publisher_default = reader.GetAttribute("default"); // (true|false)
// string sourceRom_visible = reader.GetAttribute("visible"); // (true|false)
// string sourceRom_inNamingOption = reader.GetAttribute("inNamingOption"); // (true|false)
// string sourceRom_default = reader.GetAttribute("default"); // (true|false)
// string saveType_visible = reader.GetAttribute("visible"); // (true|false)
// string saveType_inNamingOption = reader.GetAttribute("inNamingOption"); // (true|false)
// string saveType_default = reader.GetAttribute("default"); // (true|false)
// string romSize_visible = reader.GetAttribute("visible"); // (true|false)
// string romSize_inNamingOption = reader.GetAttribute("inNamingOption"); // (true|false)
// string romSize_default = reader.GetAttribute("default"); // (true|false)
// string releaseNumber_visible = reader.GetAttribute("visible"); // (true|false)
// string releaseNumber_inNamingOption = reader.GetAttribute("inNamingOption"); // (true|false)
// string releaseNumber_default = reader.GetAttribute("default"); // (true|false)
// string languageNumber_visible = reader.GetAttribute("visible"); // (true|false)
// string languageNumber_inNamingOption = reader.GetAttribute("inNamingOption"); // (true|false)
// string languageNumber_default = reader.GetAttribute("default"); // (true|false)
// string comment_visible = reader.GetAttribute("visible"); // (true|false)
// string comment_inNamingOption = reader.GetAttribute("inNamingOption"); // (true|false)
// string comment_default = reader.GetAttribute("default"); // (true|false)
// string romCRC_visible = reader.GetAttribute("visible"); // (true|false)
// string romCRC_inNamingOption = reader.GetAttribute("inNamingOption"); // (true|false)
// string romCRC_default = reader.GetAttribute("default"); // (true|false)
// string im1CRC_visible = reader.GetAttribute("visible"); // (true|false)
// string im1CRC_inNamingOption = reader.GetAttribute("inNamingOption"); // (true|false)
// string im1CRC_default = reader.GetAttribute("default"); // (true|false)
// string im2CRC_visible = reader.GetAttribute("visible"); // (true|false)
// string im2CRC_inNamingOption = reader.GetAttribute("inNamingOption"); // (true|false)
// string im2CRC_default = reader.GetAttribute("default"); // (true|false)
// string languages_visible = reader.GetAttribute("visible"); // (true|false)
// string languages_inNamingOption = reader.GetAttribute("inNamingOption"); // (true|false)
// string languages_default = reader.GetAttribute("default"); // (true|false)
ReadInfos(reader.ReadSubtree());
// Skip the infos node now that we've processed it
reader.Skip();
break;
case "canopen":
// // TODO: Technically, this needs to be in its own subreader
// List<string> extensions = new List<string> extensions;
// // For each extension element...
// extensions.Add(reader.ReadElementContentAsString());
ReadCanOpen(reader.ReadSubtree());
// Skip the canopen node now that we've processed it
reader.Skip();
break;
case "newdat":
// // TODO: Technically, this needs to be in its own subreader
// // For the datVersionURL element...
// content = reader.ReadElementContentAsString();
// Url = (String.IsNullOrWhiteSpace(Name) ? content : Url);
// // For the datURL element...
// string fileName = reader.GetAttribute("fileName");
// content = reader.ReadElementContentAsString();
// string url = content;
// // For the imURL element...
// content = reader.ReadElementContentAsString();
// string url = content;
ReadNewDat(reader.ReadSubtree());
// Skip the newdat node now that we've processed it
reader.Skip();
break;
case "search":
// // TODO: Technically, this needs to be in its own subreader
// // For each to element...
// string value = reader.GetAttribute("value");
// string default = reader.GetAttribute("default"); (true|false)
// string auto = reader.GetAttribute("auto"); (true|false)
// // Additionally, each to element can contain find elements...
// string operation = reader.GetAttribute("operation");
// string value = reader.GetAttribute("value"); // Int32?
// content = reader.ReadElementContentAsString();
// string findValue = content;
ReadSearch(reader.ReadSubtree());
// Skip the search node now that we've processed it
reader.Skip();
break;
case "romtitle":
@@ -269,6 +209,297 @@ namespace SabreTools.Library.DatFiles
}
}
/// <summary>
/// Read infos information
/// </summary>
/// <param name="reader">XmlReader to use to parse the header</param>
private void ReadInfos(XmlReader reader)
{
// If there's no subtree to the configuration, skip it
if (reader == null)
{
return;
}
// Otherwise, add what is possible
reader.MoveToContent();
// Otherwise, read what we can from the header
while (!reader.EOF)
{
// We only want elements
if (reader.NodeType != XmlNodeType.Element)
{
reader.Read();
continue;
}
// Get all infos items
switch (reader.Name.ToLowerInvariant())
{
case "title":
// string title_visible = reader.GetAttribute("visible"); // (true|false)
// string title_inNamingOption = reader.GetAttribute("inNamingOption"); // (true|false)
// string title_default = reader.GetAttribute("default"); // (true|false)
reader.Read();
break;
case "location":
// string location_visible = reader.GetAttribute("visible"); // (true|false)
// string location_inNamingOption = reader.GetAttribute("inNamingOption"); // (true|false)
// string location_default = reader.GetAttribute("default"); // (true|false)
reader.Read();
break;
case "publisher":
// string publisher_visible = reader.GetAttribute("visible"); // (true|false)
// string publisher_inNamingOption = reader.GetAttribute("inNamingOption"); // (true|false)
// string publisher_default = reader.GetAttribute("default"); // (true|false)
reader.Read();
break;
case "sourcerom":
// string sourceRom_visible = reader.GetAttribute("visible"); // (true|false)
// string sourceRom_inNamingOption = reader.GetAttribute("inNamingOption"); // (true|false)
// string sourceRom_default = reader.GetAttribute("default"); // (true|false)
reader.Read();
break;
case "savetype":
// string saveType_visible = reader.GetAttribute("visible"); // (true|false)
// string saveType_inNamingOption = reader.GetAttribute("inNamingOption"); // (true|false)
// string saveType_default = reader.GetAttribute("default"); // (true|false)
reader.Read();
break;
case "romsize":
// string romSize_visible = reader.GetAttribute("visible"); // (true|false)
// string romSize_inNamingOption = reader.GetAttribute("inNamingOption"); // (true|false)
// string romSize_default = reader.GetAttribute("default"); // (true|false)
reader.Read();
break;
case "releasenumber":
// string releaseNumber_visible = reader.GetAttribute("visible"); // (true|false)
// string releaseNumber_inNamingOption = reader.GetAttribute("inNamingOption"); // (true|false)
// string releaseNumber_default = reader.GetAttribute("default"); // (true|false)
reader.Read();
break;
case "languagenumber":
// string languageNumber_visible = reader.GetAttribute("visible"); // (true|false)
// string languageNumber_inNamingOption = reader.GetAttribute("inNamingOption"); // (true|false)
// string languageNumber_default = reader.GetAttribute("default"); // (true|false)
reader.Read();
break;
case "comment":
// string comment_visible = reader.GetAttribute("visible"); // (true|false)
// string comment_inNamingOption = reader.GetAttribute("inNamingOption"); // (true|false)
// string comment_default = reader.GetAttribute("default"); // (true|false)
reader.Read();
break;
case "romcrc":
// string romCRC_visible = reader.GetAttribute("visible"); // (true|false)
// string romCRC_inNamingOption = reader.GetAttribute("inNamingOption"); // (true|false)
// string romCRC_default = reader.GetAttribute("default"); // (true|false)
reader.Read();
break;
case "im1crc":
// string im1CRC_visible = reader.GetAttribute("visible"); // (true|false)
// string im1CRC_inNamingOption = reader.GetAttribute("inNamingOption"); // (true|false)
// string im1CRC_default = reader.GetAttribute("default"); // (true|false)
reader.Read();
break;
case "im2crc":
// string im2CRC_visible = reader.GetAttribute("visible"); // (true|false)
// string im2CRC_inNamingOption = reader.GetAttribute("inNamingOption"); // (true|false)
// string im2CRC_default = reader.GetAttribute("default"); // (true|false)
reader.Read();
break;
case "languages":
// string languages_visible = reader.GetAttribute("visible"); // (true|false)
// string languages_inNamingOption = reader.GetAttribute("inNamingOption"); // (true|false)
// string languages_default = reader.GetAttribute("default"); // (true|false)
reader.Read();
break;
default:
reader.Read();
break;
}
}
}
/// <summary>
/// Read canopen information
/// </summary>
/// <param name="reader">XmlReader to use to parse the header</param>
private void ReadCanOpen(XmlReader reader)
{
// Prepare all internal variables
List<string> extensions = new List<string>();
// If there's no subtree to the configuration, skip it
if (reader == null)
{
return;
}
// Otherwise, add what is possible
reader.MoveToContent();
// Otherwise, read what we can from the header
while (!reader.EOF)
{
// We only want elements
if (reader.NodeType != XmlNodeType.Element)
{
reader.Read();
continue;
}
// Get all canopen items
switch (reader.Name.ToLowerInvariant())
{
case "extension":
extensions.Add(reader.ReadElementContentAsString());
break;
default:
reader.Read();
break;
}
}
}
/// <summary>
/// Read newdat information
/// </summary>
/// <param name="reader">XmlReader to use to parse the header</param>
private void ReadNewDat(XmlReader reader)
{
// If there's no subtree to the configuration, skip it
if (reader == null)
{
return;
}
// Otherwise, add what is possible
reader.MoveToContent();
// Otherwise, read what we can from the header
while (!reader.EOF)
{
// We only want elements
if (reader.NodeType != XmlNodeType.Element)
{
reader.Read();
continue;
}
// Get all newdat items
string content = "";
switch (reader.Name.ToLowerInvariant())
{
case "datversionurl":
content = reader.ReadElementContentAsString();
Url = (String.IsNullOrWhiteSpace(Name) ? content : Url);
break;
case "daturl":
// string fileName = reader.GetAttribute("fileName");
content = reader.ReadElementContentAsString();
// string url = content;
break;
case "imurl":
content = reader.ReadElementContentAsString();
// string url = content;
break;
default:
reader.Read();
break;
}
}
}
/// <summary>
/// Read search information
/// </summary>
/// <param name="reader">XmlReader to use to parse the header</param>
private void ReadSearch(XmlReader reader)
{
// If there's no subtree to the configuration, skip it
if (reader == null)
{
return;
}
// Otherwise, add what is possible
reader.MoveToContent();
// Otherwise, read what we can from the header
while (!reader.EOF)
{
// We only want elements
if (reader.NodeType != XmlNodeType.Element)
{
reader.Read();
continue;
}
// Get all search items
string content = "";
switch (reader.Name.ToLowerInvariant())
{
case "to":
// string value = reader.GetAttribute("value");
// string default = reader.GetAttribute("default"); (true|false)
// string auto = reader.GetAttribute("auto"); (true|false)
ReadTo(reader.ReadSubtree());
// Skip the to node now that we've processed it
reader.Skip();
break;
default:
reader.Read();
break;
}
}
}
/// <summary>
/// Read to information
/// </summary>
/// <param name="reader">XmlReader to use to parse the header</param>
private void ReadTo(XmlReader reader)
{
// If there's no subtree to the configuration, skip it
if (reader == null)
{
return;
}
// Otherwise, add what is possible
reader.MoveToContent();
// Otherwise, read what we can from the header
while (!reader.EOF)
{
// We only want elements
if (reader.NodeType != XmlNodeType.Element)
{
reader.Read();
continue;
}
// Get all search items
string content = "";
switch (reader.Name.ToLowerInvariant())
{
case "find":
// string operation = reader.GetAttribute("operation");
// string value = reader.GetAttribute("value"); // Int32?
content = reader.ReadElementContentAsString();
// string findValue = content;
break;
default:
reader.Read();
break;
}
}
}
/// <summary>
/// Read games information
/// </summary>