FileTypeExtensions.cs 1.2 KB

12345678910111213141516171819202122232425
  1. using System;
  2. using static Ryujinx.Ui.Common.Configuration.ConfigurationState.UiSection;
  3. namespace Ryujinx.Ui.Common
  4. {
  5. public static class FileTypesExtensions
  6. {
  7. /// <summary>
  8. /// Gets the current <see cref="ShownFileTypeSettings"/> value for the correlating FileType name.
  9. /// </summary>
  10. /// <param name="type">The name of the <see cref="ShownFileTypeSettings"/> parameter to get the value of.</param>
  11. /// <param name="config">The config instance to get the value from.</param>
  12. /// <returns>The current value of the setting. Value is <see langword="true"/> if the file type is the be shown on the games list, <see langword="false"/> otherwise.</returns>
  13. public static bool GetConfigValue(this FileTypes type, ShownFileTypeSettings config) => type switch
  14. {
  15. FileTypes.NSP => config.NSP.Value,
  16. FileTypes.PFS0 => config.PFS0.Value,
  17. FileTypes.XCI => config.XCI.Value,
  18. FileTypes.NCA => config.NCA.Value,
  19. FileTypes.NRO => config.NRO.Value,
  20. FileTypes.NSO => config.NSO.Value,
  21. _ => throw new ArgumentOutOfRangeException(nameof(type), type, null)
  22. };
  23. }
  24. }