Move some constants to the deserializer

This commit is contained in:
Matt Nadareski
2024-04-03 21:44:02 -04:00
parent f2c6fa2b8e
commit 8ced91d0fa
2 changed files with 13 additions and 17 deletions

View File

@@ -12,6 +12,14 @@ namespace SabreTools.Serialization.Deserializers
IFileDeserializer<MetadataFile>,
IStreamDeserializer<MetadataFile>
{
#region Constants
public const int HeaderWithoutExtendedHashesCount = 14;
public const int HeaderWithExtendedHashesCount = 17;
#endregion
#region IFileDeserializer
/// <inheritdoc cref="IFileDeserializer.Deserialize(string?)"/>
@@ -79,7 +87,7 @@ namespace SabreTools.Serialization.Deserializers
// Parse the line into a row
Row? row = null;
if (reader.Line.Count < Serialization.SeparatedValue.HeaderWithExtendedHashesCount)
if (reader.Line.Count < HeaderWithExtendedHashesCount)
{
row = new Row
{
@@ -100,8 +108,8 @@ namespace SabreTools.Serialization.Deserializers
};
// If we have additional fields
if (reader.Line.Count > Serialization.SeparatedValue.HeaderWithoutExtendedHashesCount)
row.ADDITIONAL_ELEMENTS = reader.Line.Skip(Serialization.SeparatedValue.HeaderWithoutExtendedHashesCount).ToArray();
if (reader.Line.Count > HeaderWithoutExtendedHashesCount)
row.ADDITIONAL_ELEMENTS = reader.Line.Skip(HeaderWithoutExtendedHashesCount).ToArray();
}
else
{
@@ -127,8 +135,8 @@ namespace SabreTools.Serialization.Deserializers
};
// If we have additional fields
if (reader.Line.Count > Serialization.SeparatedValue.HeaderWithExtendedHashesCount)
row.ADDITIONAL_ELEMENTS = reader.Line.Skip(Serialization.SeparatedValue.HeaderWithExtendedHashesCount).ToArray();
if (reader.Line.Count > HeaderWithExtendedHashesCount)
row.ADDITIONAL_ELEMENTS = reader.Line.Skip(HeaderWithExtendedHashesCount).ToArray();
}
rows.Add(row);
}

View File

@@ -1,12 +0,0 @@
namespace SabreTools.Serialization
{
/// <summary>
/// Represents separated-value variants
/// </summary>
public static class SeparatedValue
{
public const int HeaderWithoutExtendedHashesCount = 14;
public const int HeaderWithExtendedHashesCount = 17;
}
}