2
0

IHasKeywords.cs 768 B

12345678910111213141516171819202122232425262728293031
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace MediaBrowser.Controller.Entities
  5. {
  6. public interface IHasKeywords
  7. {
  8. /// <summary>
  9. /// Gets or sets the keywords.
  10. /// </summary>
  11. /// <value>The keywords.</value>
  12. List<string> Keywords { get; set; }
  13. }
  14. public static class KeywordExtensions
  15. {
  16. public static void AddKeyword(this IHasKeywords item, string name)
  17. {
  18. if (string.IsNullOrWhiteSpace(name))
  19. {
  20. throw new ArgumentNullException("name");
  21. }
  22. if (!item.Keywords.Contains(name, StringComparer.OrdinalIgnoreCase))
  23. {
  24. item.Keywords.Add(name);
  25. }
  26. }
  27. }
  28. }