FileStack.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace Emby.Naming.Video
  5. {
  6. /// <summary>
  7. /// Object holding list of files paths with additional information.
  8. /// </summary>
  9. public class FileStack
  10. {
  11. /// <summary>
  12. /// Initializes a new instance of the <see cref="FileStack"/> class.
  13. /// </summary>
  14. public FileStack()
  15. {
  16. Files = new List<string>();
  17. }
  18. /// <summary>
  19. /// Gets or sets name of file stack.
  20. /// </summary>
  21. public string Name { get; set; } = string.Empty;
  22. /// <summary>
  23. /// Gets or sets list of paths in stack.
  24. /// </summary>
  25. public List<string> Files { get; set; }
  26. /// <summary>
  27. /// Gets or sets a value indicating whether stack is directory stack.
  28. /// </summary>
  29. public bool IsDirectoryStack { get; set; }
  30. /// <summary>
  31. /// Helper function to determine if path is in the stack.
  32. /// </summary>
  33. /// <param name="file">Path of desired file.</param>
  34. /// <param name="isDirectory">Requested type of stack.</param>
  35. /// <returns>True if file is in the stack.</returns>
  36. public bool ContainsFile(string file, bool isDirectory)
  37. {
  38. if (IsDirectoryStack == isDirectory)
  39. {
  40. return Files.Contains(file, StringComparer.OrdinalIgnoreCase);
  41. }
  42. return false;
  43. }
  44. }
  45. }