UI: collapse LoadFromStream into static ctor

pass the index get delegate to the struct instead of the entire header
This commit is contained in:
Evan Husted 2025-01-09 19:44:24 -06:00
parent 292e27f0da
commit c5574b41a1

View File

@ -11,7 +11,7 @@ using System.Text;
namespace Ryujinx.Ava.Utilities.Compat
{
public struct ColumnIndices(SepReaderHeader header)
public struct ColumnIndices(Func<string, int> getIndex)
{
public const string TitleIdCol = "\"title_id\"";
public const string GameNameCol = "\"game_name\"";
@ -19,11 +19,11 @@ namespace Ryujinx.Ava.Utilities.Compat
public const string StatusCol = "\"status\"";
public const string LastUpdatedCol = "\"last_updated\"";
public readonly int TitleId = header.IndexOf(TitleIdCol);
public readonly int GameName = header.IndexOf(GameNameCol);
public readonly int Labels = header.IndexOf(LabelsCol);
public readonly int Status = header.IndexOf(StatusCol);
public readonly int LastUpdated = header.IndexOf(LastUpdatedCol);
public readonly int TitleId = getIndex(TitleIdCol);
public readonly int GameName = getIndex(GameNameCol);
public readonly int Labels = getIndex(LabelsCol);
public readonly int Status = getIndex(StatusCol);
public readonly int LastUpdated = getIndex(LastUpdatedCol);
}
public class CompatibilityCsv
@ -34,13 +34,8 @@ namespace Ryujinx.Ava.Utilities.Compat
.GetManifestResourceStream("RyujinxGameCompatibilityList")!;
csvStream.Position = 0;
LoadFromStream(csvStream);
}
public static void LoadFromStream(Stream stream)
{
using SepReader reader = Sep.Reader().From(stream);
ColumnIndices columnIndices = new(reader.Header);
using SepReader reader = Sep.Reader().From(csvStream);
ColumnIndices columnIndices = new(reader.Header.IndexOf);
Entries = reader
.Enumerate(row => new CompatibilityEntry(ref columnIndices, row))