MediaFile.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel.DataAnnotations;
  4. using System.ComponentModel.DataAnnotations.Schema;
  5. namespace Jellyfin.Data.Entities
  6. {
  7. public partial class MediaFile
  8. {
  9. partial void Init();
  10. /// <summary>
  11. /// Default constructor. Protected due to required properties, but present because EF needs it.
  12. /// </summary>
  13. protected MediaFile()
  14. {
  15. MediaFileStreams = new HashSet<MediaFileStream>();
  16. Init();
  17. }
  18. /// <summary>
  19. /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving.
  20. /// </summary>
  21. public static MediaFile CreateMediaFileUnsafe()
  22. {
  23. return new MediaFile();
  24. }
  25. /// <summary>
  26. /// Public constructor with required data.
  27. /// </summary>
  28. /// <param name="path">Relative to the LibraryRoot.</param>
  29. /// <param name="kind"></param>
  30. /// <param name="_release0"></param>
  31. public MediaFile(string path, Enums.MediaFileKind kind, Release _release0)
  32. {
  33. if (string.IsNullOrEmpty(path)) throw new ArgumentNullException(nameof(path));
  34. this.Path = path;
  35. this.Kind = kind;
  36. if (_release0 == null) throw new ArgumentNullException(nameof(_release0));
  37. _release0.MediaFiles.Add(this);
  38. this.MediaFileStreams = new HashSet<MediaFileStream>();
  39. Init();
  40. }
  41. /// <summary>
  42. /// Static create function (for use in LINQ queries, etc.)
  43. /// </summary>
  44. /// <param name="path">Relative to the LibraryRoot.</param>
  45. /// <param name="kind"></param>
  46. /// <param name="_release0"></param>
  47. public static MediaFile Create(string path, Enums.MediaFileKind kind, Release _release0)
  48. {
  49. return new MediaFile(path, kind, _release0);
  50. }
  51. /*************************************************************************
  52. * Properties
  53. *************************************************************************/
  54. /// <summary>
  55. /// Backing field for Id.
  56. /// </summary>
  57. internal int _Id;
  58. /// <summary>
  59. /// When provided in a partial class, allows value of Id to be changed before setting.
  60. /// </summary>
  61. partial void SetId(int oldValue, ref int newValue);
  62. /// <summary>
  63. /// When provided in a partial class, allows value of Id to be changed before returning.
  64. /// </summary>
  65. partial void GetId(ref int result);
  66. /// <summary>
  67. /// Identity, Indexed, Required.
  68. /// </summary>
  69. [Key]
  70. [Required]
  71. [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
  72. public int Id
  73. {
  74. get
  75. {
  76. int value = _Id;
  77. GetId(ref value);
  78. return _Id = value;
  79. }
  80. protected set
  81. {
  82. int oldValue = _Id;
  83. SetId(oldValue, ref value);
  84. if (oldValue != value)
  85. {
  86. _Id = value;
  87. }
  88. }
  89. }
  90. /// <summary>
  91. /// Backing field for Path.
  92. /// </summary>
  93. protected string _Path;
  94. /// <summary>
  95. /// When provided in a partial class, allows value of Path to be changed before setting.
  96. /// </summary>
  97. partial void SetPath(string oldValue, ref string newValue);
  98. /// <summary>
  99. /// When provided in a partial class, allows value of Path to be changed before returning.
  100. /// </summary>
  101. partial void GetPath(ref string result);
  102. /// <summary>
  103. /// Required, Max length = 65535
  104. /// Relative to the LibraryRoot.
  105. /// </summary>
  106. [Required]
  107. [MaxLength(65535)]
  108. [StringLength(65535)]
  109. public string Path
  110. {
  111. get
  112. {
  113. string value = _Path;
  114. GetPath(ref value);
  115. return _Path = value;
  116. }
  117. set
  118. {
  119. string oldValue = _Path;
  120. SetPath(oldValue, ref value);
  121. if (oldValue != value)
  122. {
  123. _Path = value;
  124. }
  125. }
  126. }
  127. /// <summary>
  128. /// Backing field for Kind.
  129. /// </summary>
  130. protected Enums.MediaFileKind _Kind;
  131. /// <summary>
  132. /// When provided in a partial class, allows value of Kind to be changed before setting.
  133. /// </summary>
  134. partial void SetKind(Enums.MediaFileKind oldValue, ref Enums.MediaFileKind newValue);
  135. /// <summary>
  136. /// When provided in a partial class, allows value of Kind to be changed before returning.
  137. /// </summary>
  138. partial void GetKind(ref Enums.MediaFileKind result);
  139. /// <summary>
  140. /// Required.
  141. /// </summary>
  142. [Required]
  143. public Enums.MediaFileKind Kind
  144. {
  145. get
  146. {
  147. Enums.MediaFileKind value = _Kind;
  148. GetKind(ref value);
  149. return _Kind = value;
  150. }
  151. set
  152. {
  153. Enums.MediaFileKind oldValue = _Kind;
  154. SetKind(oldValue, ref value);
  155. if (oldValue != value)
  156. {
  157. _Kind = value;
  158. }
  159. }
  160. }
  161. /// <summary>
  162. /// Required, ConcurrenyToken.
  163. /// </summary>
  164. [ConcurrencyCheck]
  165. [Required]
  166. public uint RowVersion { get; set; }
  167. public void OnSavingChanges()
  168. {
  169. RowVersion++;
  170. }
  171. /*************************************************************************
  172. * Navigation properties
  173. *************************************************************************/
  174. [ForeignKey("MediaFileStream_MediaFileStreams_Id")]
  175. public virtual ICollection<MediaFileStream> MediaFileStreams { get; protected set; }
  176. }
  177. }