IItemByName.cs 891 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. using MediaBrowser.Model.Dto;
  2. using System;
  3. using System.Collections.Generic;
  4. namespace MediaBrowser.Controller.Entities
  5. {
  6. /// <summary>
  7. /// Marker interface
  8. /// </summary>
  9. public interface IItemByName
  10. {
  11. Dictionary<Guid, ItemByNameCounts> UserItemCounts { get; set; }
  12. }
  13. public interface IHasDualAccess : IItemByName
  14. {
  15. bool IsAccessedByName { get; }
  16. }
  17. public static class IItemByNameExtensions
  18. {
  19. public static ItemByNameCounts GetItemByNameCounts(this IItemByName item, User user)
  20. {
  21. if (user == null)
  22. {
  23. throw new ArgumentNullException("user");
  24. }
  25. ItemByNameCounts counts;
  26. if (item.UserItemCounts.TryGetValue(user.Id, out counts))
  27. {
  28. return counts;
  29. }
  30. return null;
  31. }
  32. }
  33. }