using MsgPack; using Ryujinx.Ava.Utilities.AppLibrary; using System.Collections.Generic; using System.Linq; namespace Ryujinx.Ava.Utilities.PlayReport { public abstract class MatchedValue { public MatchedValue(T matched) { Matched = matched; } /// /// The currently running application's . /// public ApplicationMetadata Application { get; init; } /// /// The entire play report. /// public Horizon.Prepo.Types.PlayReport PlayReport { get; init; } /// /// The matched value from the Play Report. /// public T Matched { get; init; } } /// /// The input data to a , /// containing the currently running application's , /// and the matched from the Play Report. /// public class SingleValue : MatchedValue { public SingleValue(Value matched) : base(matched) { } public static implicit operator SingleValue(MessagePackObject mpo) => new(mpo); } /// /// The input data to a , /// containing the currently running application's , /// and the matched s from the Play Report. /// public class MultiValue : MatchedValue { public MultiValue(Value[] matched) : base(matched) { } public MultiValue(IEnumerable matched) : base(Value.ConvertPackedObjects(matched)) { } public static implicit operator MultiValue(List matched) => new(matched.Select(x => new Value(x)).ToArray()); } /// /// The input data to a , /// containing the currently running application's , /// and the matched s from the Play Report. /// public class SparseMultiValue : MatchedValue> { public SparseMultiValue(Dictionary matched) : base(matched) { } public SparseMultiValue(Dictionary matched) : base(Value.ConvertPackedObjectMap(matched)) { } public static implicit operator SparseMultiValue(Dictionary matched) => new(matched .ToDictionary( x => x.Key, x => new Value(x.Value) ) ); } }