IItemByName.cs 789 B

12345678910111213141516171819202122232425262728293031323334
  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 static class IItemByNameExtensions
  14. {
  15. public static ItemByNameCounts GetItemByNameCounts(this IItemByName item, User user)
  16. {
  17. if (user == null)
  18. {
  19. throw new ArgumentNullException("user");
  20. }
  21. ItemByNameCounts counts;
  22. if (item.UserItemCounts.TryGetValue(user.Id, out counts))
  23. {
  24. return counts;
  25. }
  26. return null;
  27. }
  28. }
  29. }