MediaFile.cs 6.2 KB

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