ConfigurationExtensions.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System;
  2. using Microsoft.Extensions.Configuration;
  3. namespace MediaBrowser.Controller.Extensions
  4. {
  5. /// <summary>
  6. /// Configuration extensions for <c>MediaBrowser.Controller</c>.
  7. /// </summary>
  8. public static class ConfigurationExtensions
  9. {
  10. /// <summary>
  11. /// The key for a setting that indicates whether the application should host static web content.
  12. /// </summary>
  13. public const string NoWebContentKey = "nowebcontent";
  14. /// <summary>
  15. /// The key for the FFmpeg probe size option.
  16. /// </summary>
  17. public const string FfmpegProbeSizeKey = "FFmpeg:probesize";
  18. /// <summary>
  19. /// The key for the FFmpeg analyse duration option.
  20. /// </summary>
  21. public const string FfmpegAnalyzeDurationKey = "FFmpeg:analyzeduration";
  22. /// <summary>
  23. /// Retrieves a config value indicating whether the application should not host
  24. /// static web content from the <see cref="IConfiguration"/>.
  25. /// </summary>
  26. /// <param name="configuration">The configuration to retrieve the value from.</param>
  27. /// <returns>The parsed config value.</returns>
  28. /// <exception cref="FormatException">The config value is not a valid bool string. See <see cref="bool.Parse(string)"/>.</exception>
  29. public static bool IsNoWebContent(this IConfiguration configuration)
  30. => configuration.GetValue<bool>(NoWebContentKey);
  31. /// <summary>
  32. /// Retrieves the FFmpeg probe size from the <see cref="IConfiguration" />.
  33. /// </summary>
  34. /// <param name="configuration">This configuration.</param>
  35. /// <returns>The FFmpeg probe size option.</returns>
  36. public static string GetFFmpegProbeSize(this IConfiguration configuration)
  37. => configuration[FfmpegProbeSizeKey];
  38. /// <summary>
  39. /// Retrieves the FFmpeg analyse duration from the <see cref="IConfiguration" />.
  40. /// </summary>
  41. /// <param name="configuration">This configuration.</param>
  42. /// <returns>The FFmpeg analyse duration option.</returns>
  43. public static string GetFFmpegAnalyzeDuration(this IConfiguration configuration)
  44. => configuration[FfmpegAnalyzeDurationKey];
  45. }
  46. }