misc: chore: unify GameSpec creation
This commit is contained in:
parent
05e991db87
commit
764c9e9d4e
@ -31,8 +31,7 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
Guard.Ensure(ulong.TryParse(titleId, NumberStyles.HexNumber, null, out _),
|
Guard.Ensure(ulong.TryParse(titleId, NumberStyles.HexNumber, null, out _),
|
||||||
$"Cannot use a non-hexadecimal string as the Title ID for a {nameof(GameSpec)}.");
|
$"Cannot use a non-hexadecimal string as the Title ID for a {nameof(GameSpec)}.");
|
||||||
|
|
||||||
_specs.Add(transform(new GameSpec { TitleIds = [titleId] }));
|
return AddSpec(transform(GameSpec.Create(titleId)));
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -46,8 +45,7 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
Guard.Ensure(ulong.TryParse(titleId, NumberStyles.HexNumber, null, out _),
|
Guard.Ensure(ulong.TryParse(titleId, NumberStyles.HexNumber, null, out _),
|
||||||
$"Cannot use a non-hexadecimal string as the Title ID for a {nameof(GameSpec)}.");
|
$"Cannot use a non-hexadecimal string as the Title ID for a {nameof(GameSpec)}.");
|
||||||
|
|
||||||
_specs.Add(new GameSpec { TitleIds = [titleId] }.Apply(transform));
|
return AddSpec(GameSpec.Create(titleId).Apply(transform));
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -63,8 +61,7 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
Guard.Ensure(tids.All(x => ulong.TryParse(x, NumberStyles.HexNumber, null, out _)),
|
Guard.Ensure(tids.All(x => ulong.TryParse(x, NumberStyles.HexNumber, null, out _)),
|
||||||
$"Cannot use a non-hexadecimal string as the Title ID for a {nameof(GameSpec)}.");
|
$"Cannot use a non-hexadecimal string as the Title ID for a {nameof(GameSpec)}.");
|
||||||
|
|
||||||
_specs.Add(transform(new GameSpec { TitleIds = [..tids] }));
|
return AddSpec(transform(GameSpec.Create(tids)));
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -79,7 +76,17 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
Guard.Ensure(tids.All(x => ulong.TryParse(x, NumberStyles.HexNumber, null, out _)),
|
Guard.Ensure(tids.All(x => ulong.TryParse(x, NumberStyles.HexNumber, null, out _)),
|
||||||
$"Cannot use a non-hexadecimal string as the Title ID for a {nameof(GameSpec)}.");
|
$"Cannot use a non-hexadecimal string as the Title ID for a {nameof(GameSpec)}.");
|
||||||
|
|
||||||
_specs.Add(new GameSpec { TitleIds = [..tids] }.Apply(transform));
|
return AddSpec(GameSpec.Create(tids).Apply(transform));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Add an analysis spec matching a specific game by title ID, with the provided pre-configured spec.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="spec">The <see cref="GameSpec"/> to add.</param>
|
||||||
|
/// <returns>The current <see cref="Analyzer"/>, for chaining convenience.</returns>
|
||||||
|
public Analyzer AddSpec(GameSpec spec)
|
||||||
|
{
|
||||||
|
_specs.Add(spec);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,12 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class GameSpec
|
public class GameSpec
|
||||||
{
|
{
|
||||||
|
public static GameSpec Create(string requiredTitleId, params IEnumerable<string> otherTitleIds)
|
||||||
|
=> new() { TitleIds = otherTitleIds.Prepend(requiredTitleId).ToArray() };
|
||||||
|
|
||||||
|
public static GameSpec Create(IEnumerable<string> titleIds)
|
||||||
|
=> new() { TitleIds = titleIds.ToArray() };
|
||||||
|
|
||||||
private int _lastPriority;
|
private int _lastPriority;
|
||||||
|
|
||||||
public required string[] TitleIds { get; init; }
|
public required string[] TitleIds { get; init; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user