jellyfin/Jellyfin.Data/Entities/MediaFile.cs

211 lines
6.2 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Jellyfin.Data.Entities
{
2020-05-02 23:56:05 +02:00
public partial class MediaFile
{
partial void Init();
/// <summary>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </summary>
protected MediaFile()
{
MediaFileStreams = new HashSet<MediaFileStream>();
Init();
}
/// <summary>
/// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving.
/// </summary>
public static MediaFile CreateMediaFileUnsafe()
{
return new MediaFile();
}
/// <summary>
/// Public constructor with required data.
2020-05-02 23:56:05 +02:00
/// </summary>
2020-06-19 12:21:49 +02:00
/// <param name="path">Relative to the LibraryRoot.</param>
2020-05-02 23:56:05 +02:00
/// <param name="kind"></param>
/// <param name="_release0"></param>
public MediaFile(string path, Enums.MediaFileKind kind, Release _release0)
{
2020-06-20 10:35:29 +02:00
if (string.IsNullOrEmpty(path))
{
throw new ArgumentNullException(nameof(path));
}
2020-05-02 23:56:05 +02:00
this.Path = path;
this.Kind = kind;
2020-06-20 10:35:29 +02:00
if (_release0 == null)
{
throw new ArgumentNullException(nameof(_release0));
}
2020-05-02 23:56:05 +02:00
_release0.MediaFiles.Add(this);
this.MediaFileStreams = new HashSet<MediaFileStream>();
Init();
}
/// <summary>
/// Static create function (for use in LINQ queries, etc.)
/// </summary>
2020-06-19 12:21:49 +02:00
/// <param name="path">Relative to the LibraryRoot.</param>
2020-05-02 23:56:05 +02:00
/// <param name="kind"></param>
/// <param name="_release0"></param>
public static MediaFile Create(string path, Enums.MediaFileKind kind, Release _release0)
{
return new MediaFile(path, kind, _release0);
}
/*************************************************************************
* Properties
*************************************************************************/
/// <summary>
/// Backing field for Id.
2020-05-02 23:56:05 +02:00
/// </summary>
internal int _Id;
/// <summary>
/// When provided in a partial class, allows value of Id to be changed before setting.
/// </summary>
partial void SetId(int oldValue, ref int newValue);
/// <summary>
/// When provided in a partial class, allows value of Id to be changed before returning.
/// </summary>
partial void GetId(ref int result);
/// <summary>
/// Identity, Indexed, Required.
2020-05-02 23:56:05 +02:00
/// </summary>
[Key]
[Required]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id
{
get
{
int value = _Id;
GetId(ref value);
2020-06-19 11:57:37 +02:00
return _Id = value;
2020-05-02 23:56:05 +02:00
}
2020-06-15 23:43:52 +02:00
2020-05-02 23:56:05 +02:00
protected set
{
int oldValue = _Id;
SetId(oldValue, ref value);
if (oldValue != value)
{
_Id = value;
}
}
}
/// <summary>
/// Backing field for Path.
2020-05-02 23:56:05 +02:00
/// </summary>
protected string _Path;
/// <summary>
/// When provided in a partial class, allows value of Path to be changed before setting.
/// </summary>
partial void SetPath(string oldValue, ref string newValue);
/// <summary>
/// When provided in a partial class, allows value of Path to be changed before returning.
/// </summary>
partial void GetPath(ref string result);
/// <summary>
/// Required, Max length = 65535
/// Relative to the LibraryRoot.
2020-05-02 23:56:05 +02:00
/// </summary>
[Required]
[MaxLength(65535)]
[StringLength(65535)]
public string Path
{
get
{
string value = _Path;
GetPath(ref value);
2020-06-19 11:57:37 +02:00
return _Path = value;
2020-05-02 23:56:05 +02:00
}
2020-06-15 23:43:52 +02:00
2020-05-02 23:56:05 +02:00
set
{
2020-05-02 23:56:05 +02:00
string oldValue = _Path;
SetPath(oldValue, ref value);
if (oldValue != value)
{
_Path = value;
}
}
2020-05-02 23:56:05 +02:00
}
/// <summary>
/// Backing field for Kind.
2020-05-02 23:56:05 +02:00
/// </summary>
protected Enums.MediaFileKind _Kind;
/// <summary>
/// When provided in a partial class, allows value of Kind to be changed before setting.
/// </summary>
partial void SetKind(Enums.MediaFileKind oldValue, ref Enums.MediaFileKind newValue);
/// <summary>
/// When provided in a partial class, allows value of Kind to be changed before returning.
/// </summary>
partial void GetKind(ref Enums.MediaFileKind result);
/// <summary>
/// Required.
2020-05-02 23:56:05 +02:00
/// </summary>
[Required]
public Enums.MediaFileKind Kind
{
get
{
2020-05-02 23:56:05 +02:00
Enums.MediaFileKind value = _Kind;
GetKind(ref value);
2020-06-19 11:57:37 +02:00
return _Kind = value;
}
2020-06-15 23:43:52 +02:00
2020-05-02 23:56:05 +02:00
set
{
2020-05-02 23:56:05 +02:00
Enums.MediaFileKind oldValue = _Kind;
SetKind(oldValue, ref value);
if (oldValue != value)
{
_Kind = value;
}
}
2020-05-02 23:56:05 +02:00
}
/// <summary>
/// Required, ConcurrenyToken.
2020-05-02 23:56:05 +02:00
/// </summary>
[ConcurrencyCheck]
[Required]
public uint RowVersion { get; set; }
2020-05-02 23:56:05 +02:00
public void OnSavingChanges()
{
RowVersion++;
}
2020-05-02 23:56:05 +02:00
/*************************************************************************
* Navigation properties
*************************************************************************/
2020-05-02 23:56:05 +02:00
[ForeignKey("MediaFileStream_MediaFileStreams_Id")]
public virtual ICollection<MediaFileStream> MediaFileStreams { get; protected set; }
}
}