BookMetadata.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #pragma warning disable CA2227
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel.DataAnnotations.Schema;
  5. using Jellyfin.Data.Interfaces;
  6. namespace Jellyfin.Data.Entities.Libraries
  7. {
  8. /// <summary>
  9. /// An entity containing metadata for a book.
  10. /// </summary>
  11. public class BookMetadata : ItemMetadata, IHasCompanies
  12. {
  13. /// <summary>
  14. /// Initializes a new instance of the <see cref="BookMetadata"/> class.
  15. /// </summary>
  16. /// <param name="title">The title or name of the object.</param>
  17. /// <param name="language">ISO-639-3 3-character language codes.</param>
  18. /// <param name="book">The book.</param>
  19. public BookMetadata(string title, string language, Book book) : base(title, language)
  20. {
  21. if (book == null)
  22. {
  23. throw new ArgumentNullException(nameof(book));
  24. }
  25. book.BookMetadata.Add(this);
  26. Publishers = new HashSet<Company>();
  27. }
  28. /// <summary>
  29. /// Initializes a new instance of the <see cref="BookMetadata"/> class.
  30. /// </summary>
  31. /// <remarks>
  32. /// Default constructor. Protected due to required properties, but present because EF needs it.
  33. /// </remarks>
  34. protected BookMetadata()
  35. {
  36. }
  37. /// <summary>
  38. /// Gets or sets the ISBN.
  39. /// </summary>
  40. public long? Isbn { get; set; }
  41. /// <summary>
  42. /// Gets or sets a collection of the publishers for this book.
  43. /// </summary>
  44. public virtual ICollection<Company> Publishers { get; protected set; }
  45. /// <inheritdoc />
  46. [NotMapped]
  47. public ICollection<Company> Companies => Publishers;
  48. }
  49. }