MetadataProvider.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using System;
  2. using System.ComponentModel.DataAnnotations;
  3. using System.ComponentModel.DataAnnotations.Schema;
  4. using Jellyfin.Data.Interfaces;
  5. namespace Jellyfin.Data.Entities.Libraries
  6. {
  7. /// <summary>
  8. /// An entity representing a metadata provider.
  9. /// </summary>
  10. public class MetadataProvider : IHasConcurrencyToken
  11. {
  12. /// <summary>
  13. /// Initializes a new instance of the <see cref="MetadataProvider"/> class.
  14. /// </summary>
  15. /// <param name="name">The name of the metadata provider.</param>
  16. public MetadataProvider(string name)
  17. {
  18. if (string.IsNullOrEmpty(name))
  19. {
  20. throw new ArgumentNullException(nameof(name));
  21. }
  22. Name = name;
  23. }
  24. /// <summary>
  25. /// Initializes a new instance of the <see cref="MetadataProvider"/> class.
  26. /// </summary>
  27. /// <remarks>
  28. /// Default constructor. Protected due to required properties, but present because EF needs it.
  29. /// </remarks>
  30. protected MetadataProvider()
  31. {
  32. }
  33. /// <summary>
  34. /// Gets or sets the id.
  35. /// </summary>
  36. /// <remarks>
  37. /// Identity, Indexed, Required.
  38. /// </remarks>
  39. [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
  40. public int Id { get; protected set; }
  41. /// <summary>
  42. /// Gets or sets the name.
  43. /// </summary>
  44. /// <remarks>
  45. /// Required, Max length = 1024.
  46. /// </remarks>
  47. [Required]
  48. [MaxLength(1024)]
  49. [StringLength(1024)]
  50. public string Name { get; set; }
  51. /// <inheritdoc />
  52. [ConcurrencyCheck]
  53. public uint RowVersion { get; set; }
  54. /// <inheritdoc />
  55. public void OnSavingChanges()
  56. {
  57. RowVersion++;
  58. }
  59. }
  60. }