mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-09-22 14:55:11 +00:00
Move some constants to the deserializer
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
namespace SabreTools.Serialization
|
||||
{
|
||||
/// <summary>
|
||||
/// Separated value serializer/deserializer for AttractMode romlists
|
||||
/// </summary>
|
||||
public static class AttractMode
|
||||
{
|
||||
public const string HeaderWithoutRomname = "#Name;Title;Emulator;CloneOf;Year;Manufacturer;Category;Players;Rotation;Control;Status;DisplayCount;DisplayType;AltRomname;AltTitle;Extra;Buttons";
|
||||
public const int HeaderWithoutRomnameCount = 17;
|
||||
|
||||
public const string HeaderWithRomname = "#Romname;Title;Emulator;Cloneof;Year;Manufacturer;Category;Players;Rotation;Control;Status;DisplayCount;DisplayType;AltRomname;AltTitle;Extra;Buttons;Favourite;Tags;PlayedCount;PlayedTime;FileIsAvailable";
|
||||
public const int HeaderWithRomnameCount = 22;
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,14 @@ namespace SabreTools.Serialization.Deserializers
|
||||
IFileDeserializer<MetadataFile>,
|
||||
IStreamDeserializer<MetadataFile>
|
||||
{
|
||||
#region Constants
|
||||
|
||||
public const int HeaderWithoutRomnameCount = 17;
|
||||
|
||||
public const int HeaderWithRomnameCount = 22;
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileDeserializer
|
||||
|
||||
/// <inheritdoc cref="IFileDeserializer.Deserialize(string?)"/>
|
||||
@@ -70,7 +78,7 @@ namespace SabreTools.Serialization.Deserializers
|
||||
|
||||
// Parse the line into a row
|
||||
Row row;
|
||||
if (reader.Line.Count < Serialization.AttractMode.HeaderWithRomnameCount)
|
||||
if (reader.Line.Count < HeaderWithRomnameCount)
|
||||
{
|
||||
row = new Row
|
||||
{
|
||||
@@ -94,8 +102,8 @@ namespace SabreTools.Serialization.Deserializers
|
||||
};
|
||||
|
||||
// If we have additional fields
|
||||
if (reader.Line.Count > Serialization.AttractMode.HeaderWithoutRomnameCount)
|
||||
row.ADDITIONAL_ELEMENTS = reader.Line.Skip(Serialization.AttractMode.HeaderWithoutRomnameCount).ToArray();
|
||||
if (reader.Line.Count > HeaderWithoutRomnameCount)
|
||||
row.ADDITIONAL_ELEMENTS = reader.Line.Skip(HeaderWithoutRomnameCount).ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -121,8 +129,8 @@ namespace SabreTools.Serialization.Deserializers
|
||||
};
|
||||
|
||||
// If we have additional fields
|
||||
if (reader.Line.Count > Serialization.AttractMode.HeaderWithRomnameCount)
|
||||
row.ADDITIONAL_ELEMENTS = reader.Line.Skip(Serialization.AttractMode.HeaderWithRomnameCount).ToArray();
|
||||
if (reader.Line.Count > HeaderWithRomnameCount)
|
||||
row.ADDITIONAL_ELEMENTS = reader.Line.Skip(HeaderWithRomnameCount).ToArray();
|
||||
}
|
||||
|
||||
rows.Add(row);
|
||||
|
||||
@@ -11,6 +11,14 @@ namespace SabreTools.Serialization.Serializers
|
||||
IFileSerializer<MetadataFile>,
|
||||
IStreamSerializer<MetadataFile>
|
||||
{
|
||||
#region Constants
|
||||
|
||||
public const string HeaderWithoutRomname = "#Name;Title;Emulator;CloneOf;Year;Manufacturer;Category;Players;Rotation;Control;Status;DisplayCount;DisplayType;AltRomname;AltTitle;Extra;Buttons";
|
||||
|
||||
public const string HeaderWithRomname = "#Romname;Title;Emulator;Cloneof;Year;Manufacturer;Category;Players;Rotation;Control;Status;DisplayCount;DisplayType;AltRomname;AltTitle;Extra;Buttons;Favourite;Tags;PlayedCount;PlayedTime;FileIsAvailable";
|
||||
|
||||
#endregion
|
||||
|
||||
#region IFileSerializer
|
||||
|
||||
/// <inheritdoc cref="IFileSerializer.Serialize(T?, string?)"/>
|
||||
@@ -64,7 +72,7 @@ namespace SabreTools.Serialization.Serializers
|
||||
|
||||
// TODO: Include flag to write out long or short header
|
||||
// Write the short header
|
||||
writer.WriteString(Serialization.AttractMode.HeaderWithoutRomname); // TODO: Convert to array of values
|
||||
writer.WriteString(HeaderWithoutRomname); // TODO: Convert to array of values
|
||||
writer.WriteLine();
|
||||
|
||||
// Write out the rows, if they exist
|
||||
|
||||
Reference in New Issue
Block a user