Remove constructor side effects and remove unneeded parameterless constructors

This commit is contained in:
Patrick Barron 2021-03-06 16:17:19 -05:00
parent b5e3c02865
commit 287dab4655
46 changed files with 46 additions and 627 deletions

View File

@ -1,7 +1,6 @@
using System; using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;
using System.Xml.Serialization; using System.Xml.Serialization;
using Jellyfin.Data.Enums; using Jellyfin.Data.Enums;
@ -27,14 +26,6 @@ namespace Jellyfin.Data.Entities
EndHour = endHour; EndHour = endHour;
} }
/// <summary>
/// Initializes a new instance of the <see cref="AccessSchedule"/> class.
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </summary>
protected AccessSchedule()
{
}
/// <summary> /// <summary>
/// Gets or sets the id of this instance. /// Gets or sets the id of this instance.
/// </summary> /// </summary>

View File

@ -18,8 +18,7 @@ namespace Jellyfin.Data.Entities
/// <param name="name">The name.</param> /// <param name="name">The name.</param>
/// <param name="type">The type.</param> /// <param name="type">The type.</param>
/// <param name="userId">The user id.</param> /// <param name="userId">The user id.</param>
/// <param name="logLevel">The log level.</param> public ActivityLog(string name, string type, Guid userId)
public ActivityLog(string name, string type, Guid userId, LogLevel logLevel = LogLevel.Information)
{ {
if (string.IsNullOrEmpty(name)) if (string.IsNullOrEmpty(name))
{ {
@ -35,15 +34,7 @@ namespace Jellyfin.Data.Entities
Type = type; Type = type;
UserId = userId; UserId = userId;
DateCreated = DateTime.UtcNow; DateCreated = DateTime.UtcNow;
LogSeverity = logLevel; LogSeverity = LogLevel.Information;
}
/// <summary>
/// Initializes a new instance of the <see cref="ActivityLog"/> class.
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </summary>
protected ActivityLog()
{
} }
/// <summary> /// <summary>

View File

@ -15,22 +15,15 @@ namespace Jellyfin.Data.Entities
/// <param name="userId">The user id.</param> /// <param name="userId">The user id.</param>
/// <param name="itemId">The item id.</param> /// <param name="itemId">The item id.</param>
/// <param name="client">The client.</param> /// <param name="client">The client.</param>
/// <param name="preferenceKey">The preference key.</param> /// <param name="key">The preference key.</param>
/// <param name="preferenceValue">The preference value.</param> /// <param name="value">The preference value.</param>
public CustomItemDisplayPreferences(Guid userId, Guid itemId, string client, string preferenceKey, string preferenceValue) public CustomItemDisplayPreferences(Guid userId, Guid itemId, string client, string key, string value)
{ {
UserId = userId; UserId = userId;
ItemId = itemId; ItemId = itemId;
Client = client; Client = client;
Key = preferenceKey; Key = key;
Value = preferenceValue; Value = value;
}
/// <summary>
/// Initializes a new instance of the <see cref="CustomItemDisplayPreferences"/> class.
/// </summary>
protected CustomItemDisplayPreferences()
{
} }
/// <summary> /// <summary>

View File

@ -36,13 +36,6 @@ namespace Jellyfin.Data.Entities
HomeSections = new HashSet<HomeSection>(); HomeSections = new HashSet<HomeSection>();
} }
/// <summary>
/// Initializes a new instance of the <see cref="DisplayPreferences"/> class.
/// </summary>
protected DisplayPreferences()
{
}
/// <summary> /// <summary>
/// Gets or sets the Id. /// Gets or sets the Id.
/// </summary> /// </summary>

View File

@ -32,16 +32,6 @@ namespace Jellyfin.Data.Entities
Preferences = new HashSet<Preference>(); Preferences = new HashSet<Preference>();
} }
/// <summary>
/// Initializes a new instance of the <see cref="Group"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected Group()
{
}
/// <summary> /// <summary>
/// Gets or sets the id of this group. /// Gets or sets the id of this group.
/// </summary> /// </summary>

View File

@ -19,16 +19,6 @@ namespace Jellyfin.Data.Entities
LastModified = DateTime.UtcNow; LastModified = DateTime.UtcNow;
} }
/// <summary>
/// Initializes a new instance of the <see cref="ImageInfo"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected ImageInfo()
{
}
/// <summary> /// <summary>
/// Gets or sets the id. /// Gets or sets the id.
/// </summary> /// </summary>

View File

@ -28,13 +28,6 @@ namespace Jellyfin.Data.Entities
RememberIndexing = false; RememberIndexing = false;
} }
/// <summary>
/// Initializes a new instance of the <see cref="ItemDisplayPreferences"/> class.
/// </summary>
protected ItemDisplayPreferences()
{
}
/// <summary> /// <summary>
/// Gets or sets the Id. /// Gets or sets the Id.
/// </summary> /// </summary>

View File

@ -18,8 +18,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </summary> /// </summary>
/// <param name="path">The path.</param> /// <param name="path">The path.</param>
/// <param name="kind">The kind of art.</param> /// <param name="kind">The kind of art.</param>
/// <param name="owner">The owner.</param> public Artwork(string path, ArtKind kind)
public Artwork(string path, ArtKind kind, IHasArtwork owner)
{ {
if (string.IsNullOrEmpty(path)) if (string.IsNullOrEmpty(path))
{ {
@ -28,18 +27,6 @@ namespace Jellyfin.Data.Entities.Libraries
Path = path; Path = path;
Kind = kind; Kind = kind;
owner?.Artwork.Add(this);
}
/// <summary>
/// Initializes a new instance of the <see cref="Artwork"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected Artwork()
{
} }
/// <summary> /// <summary>

View File

@ -13,7 +13,8 @@ namespace Jellyfin.Data.Entities.Libraries
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Book"/> class. /// Initializes a new instance of the <see cref="Book"/> class.
/// </summary> /// </summary>
public Book() /// <param name="library">The library.</param>
public Book(Library library) : base(library)
{ {
BookMetadata = new HashSet<BookMetadata>(); BookMetadata = new HashSet<BookMetadata>();
Releases = new HashSet<Release>(); Releases = new HashSet<Release>();

View File

@ -1,6 +1,5 @@
#pragma warning disable CA2227 #pragma warning disable CA2227
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Data.Interfaces; using Jellyfin.Data.Interfaces;
@ -17,29 +16,11 @@ namespace Jellyfin.Data.Entities.Libraries
/// </summary> /// </summary>
/// <param name="title">The title or name of the object.</param> /// <param name="title">The title or name of the object.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param> /// <param name="language">ISO-639-3 3-character language codes.</param>
/// <param name="book">The book.</param> public BookMetadata(string title, string language) : base(title, language)
public BookMetadata(string title, string language, Book book) : base(title, language)
{ {
if (book == null)
{
throw new ArgumentNullException(nameof(book));
}
book.BookMetadata.Add(this);
Publishers = new HashSet<Company>(); Publishers = new HashSet<Company>();
} }
/// <summary>
/// Initializes a new instance of the <see cref="BookMetadata"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected BookMetadata()
{
}
/// <summary> /// <summary>
/// Gets or sets the ISBN. /// Gets or sets the ISBN.
/// </summary> /// </summary>

View File

@ -17,8 +17,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </summary> /// </summary>
/// <param name="language">ISO-639-3 3-character language codes.</param> /// <param name="language">ISO-639-3 3-character language codes.</param>
/// <param name="startTime">The start time for this chapter.</param> /// <param name="startTime">The start time for this chapter.</param>
/// <param name="release">The release.</param> public Chapter(string language, long startTime)
public Chapter(string language, long startTime, Release release)
{ {
if (string.IsNullOrEmpty(language)) if (string.IsNullOrEmpty(language))
{ {
@ -27,23 +26,6 @@ namespace Jellyfin.Data.Entities.Libraries
Language = language; Language = language;
StartTime = startTime; StartTime = startTime;
if (release == null)
{
throw new ArgumentNullException(nameof(release));
}
release.Chapters.Add(this);
}
/// <summary>
/// Initializes a new instance of the <see cref="Chapter"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected Chapter()
{
} }
/// <summary> /// <summary>

View File

@ -1,4 +1,3 @@
using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Data.Interfaces; using Jellyfin.Data.Interfaces;
@ -10,44 +9,6 @@ namespace Jellyfin.Data.Entities.Libraries
/// </summary> /// </summary>
public class CollectionItem : IHasConcurrencyToken public class CollectionItem : IHasConcurrencyToken
{ {
/// <summary>
/// Initializes a new instance of the <see cref="CollectionItem"/> class.
/// </summary>
/// <param name="collection">The collection.</param>
/// <param name="previous">The previous item.</param>
/// <param name="next">The next item.</param>
public CollectionItem(Collection collection, CollectionItem previous, CollectionItem next)
{
if (collection == null)
{
throw new ArgumentNullException(nameof(collection));
}
collection.Items.Add(this);
if (next != null)
{
Next = next;
next.Previous = this;
}
if (previous != null)
{
Previous = previous;
previous.Next = this;
}
}
/// <summary>
/// Initializes a new instance of the <see cref="CollectionItem"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected CollectionItem()
{
}
/// <summary> /// <summary>
/// Gets or sets the id. /// Gets or sets the id.
/// </summary> /// </summary>

View File

@ -15,24 +15,11 @@ namespace Jellyfin.Data.Entities.Libraries
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Company"/> class. /// Initializes a new instance of the <see cref="Company"/> class.
/// </summary> /// </summary>
/// <param name="owner">The owner of this company.</param> public Company()
public Company(IHasCompanies owner)
{ {
owner?.Companies.Add(this);
CompanyMetadata = new HashSet<CompanyMetadata>(); CompanyMetadata = new HashSet<CompanyMetadata>();
} }
/// <summary>
/// Initializes a new instance of the <see cref="Company"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected Company()
{
}
/// <summary> /// <summary>
/// Gets or sets the id. /// Gets or sets the id.
/// </summary> /// </summary>

View File

@ -1,4 +1,3 @@
using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace Jellyfin.Data.Entities.Libraries namespace Jellyfin.Data.Entities.Libraries
@ -13,21 +12,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </summary> /// </summary>
/// <param name="title">The title or name of the object.</param> /// <param name="title">The title or name of the object.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param> /// <param name="language">ISO-639-3 3-character language codes.</param>
/// <param name="company">The company.</param> public CompanyMetadata(string title, string language) : base(title, language)
public CompanyMetadata(string title, string language, Company company) : base(title, language)
{
if (company == null)
{
throw new ArgumentNullException(nameof(company));
}
company.CompanyMetadata.Add(this);
}
/// <summary>
/// Initializes a new instance of the <see cref="CompanyMetadata"/> class.
/// </summary>
protected CompanyMetadata()
{ {
} }

View File

@ -13,7 +13,8 @@ namespace Jellyfin.Data.Entities.Libraries
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="CustomItem"/> class. /// Initializes a new instance of the <see cref="CustomItem"/> class.
/// </summary> /// </summary>
public CustomItem() /// <param name="library">The library.</param>
public CustomItem(Library library) : base(library)
{ {
CustomItemMetadata = new HashSet<CustomItemMetadata>(); CustomItemMetadata = new HashSet<CustomItemMetadata>();
Releases = new HashSet<Release>(); Releases = new HashSet<Release>();

View File

@ -12,24 +12,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </summary> /// </summary>
/// <param name="title">The title or name of the object.</param> /// <param name="title">The title or name of the object.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param> /// <param name="language">ISO-639-3 3-character language codes.</param>
/// <param name="item">The item.</param> public CustomItemMetadata(string title, string language) : base(title, language)
public CustomItemMetadata(string title, string language, CustomItem item) : base(title, language)
{
if (item == null)
{
throw new ArgumentNullException(nameof(item));
}
item.CustomItemMetadata.Add(this);
}
/// <summary>
/// Initializes a new instance of the <see cref="CustomItemMetadata"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected CustomItemMetadata()
{ {
} }
} }

View File

@ -1,6 +1,5 @@
#pragma warning disable CA2227 #pragma warning disable CA2227
using System;
using System.Collections.Generic; using System.Collections.Generic;
using Jellyfin.Data.Interfaces; using Jellyfin.Data.Interfaces;
@ -14,30 +13,13 @@ namespace Jellyfin.Data.Entities.Libraries
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Episode"/> class. /// Initializes a new instance of the <see cref="Episode"/> class.
/// </summary> /// </summary>
/// <param name="season">The season.</param> /// <param name="library">The library.</param>
public Episode(Season season) public Episode(Library library) : base(library)
{ {
if (season == null)
{
throw new ArgumentNullException(nameof(season));
}
season.Episodes.Add(this);
Releases = new HashSet<Release>(); Releases = new HashSet<Release>();
EpisodeMetadata = new HashSet<EpisodeMetadata>(); EpisodeMetadata = new HashSet<EpisodeMetadata>();
} }
/// <summary>
/// Initializes a new instance of the <see cref="Episode"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected Episode()
{
}
/// <summary> /// <summary>
/// Gets or sets the episode number. /// Gets or sets the episode number.
/// </summary> /// </summary>

View File

@ -1,4 +1,3 @@
using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace Jellyfin.Data.Entities.Libraries namespace Jellyfin.Data.Entities.Libraries
@ -13,24 +12,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </summary> /// </summary>
/// <param name="title">The title or name of the object.</param> /// <param name="title">The title or name of the object.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param> /// <param name="language">ISO-639-3 3-character language codes.</param>
/// <param name="episode">The episode.</param> public EpisodeMetadata(string title, string language) : base(title, language)
public EpisodeMetadata(string title, string language, Episode episode) : base(title, language)
{
if (episode == null)
{
throw new ArgumentNullException(nameof(episode));
}
episode.EpisodeMetadata.Add(this);
}
/// <summary>
/// Initializes a new instance of the <see cref="EpisodeMetadata"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected EpisodeMetadata()
{ {
} }

View File

@ -1,4 +1,3 @@
using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Data.Interfaces; using Jellyfin.Data.Interfaces;
@ -14,32 +13,9 @@ namespace Jellyfin.Data.Entities.Libraries
/// Initializes a new instance of the <see cref="Genre"/> class. /// Initializes a new instance of the <see cref="Genre"/> class.
/// </summary> /// </summary>
/// <param name="name">The name.</param> /// <param name="name">The name.</param>
/// <param name="itemMetadata">The metadata.</param> public Genre(string name)
public Genre(string name, ItemMetadata itemMetadata)
{ {
if (string.IsNullOrEmpty(name))
{
throw new ArgumentNullException(nameof(name));
}
Name = name; Name = name;
if (itemMetadata == null)
{
throw new ArgumentNullException(nameof(itemMetadata));
}
itemMetadata.Genres.Add(this);
}
/// <summary>
/// Initializes a new instance of the <see cref="Genre"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected Genre()
{
} }
/// <summary> /// <summary>

View File

@ -42,16 +42,6 @@ namespace Jellyfin.Data.Entities.Libraries
Sources = new HashSet<MetadataProviderId>(); Sources = new HashSet<MetadataProviderId>();
} }
/// <summary>
/// Initializes a new instance of the <see cref="ItemMetadata"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to being abstract.
/// </remarks>
protected ItemMetadata()
{
}
/// <summary> /// <summary>
/// Gets or sets the id. /// Gets or sets the id.
/// </summary> /// </summary>

View File

@ -24,16 +24,6 @@ namespace Jellyfin.Data.Entities.Libraries
Name = name; Name = name;
} }
/// <summary>
/// Initializes a new instance of the <see cref="Library"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected Library()
{
}
/// <summary> /// <summary>
/// Gets or sets the id. /// Gets or sets the id.
/// </summary> /// </summary>

View File

@ -20,13 +20,6 @@ namespace Jellyfin.Data.Entities.Libraries
Library = library; Library = library;
} }
/// <summary>
/// Initializes a new instance of the <see cref="LibraryItem"/> class.
/// </summary>
protected LibraryItem()
{
}
/// <summary> /// <summary>
/// Gets or sets the id. /// Gets or sets the id.
/// </summary> /// </summary>

View File

@ -19,8 +19,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </summary> /// </summary>
/// <param name="path">The path relative to the LibraryRoot.</param> /// <param name="path">The path relative to the LibraryRoot.</param>
/// <param name="kind">The file kind.</param> /// <param name="kind">The file kind.</param>
/// <param name="release">The release.</param> public MediaFile(string path, MediaFileKind kind)
public MediaFile(string path, MediaFileKind kind, Release release)
{ {
if (string.IsNullOrEmpty(path)) if (string.IsNullOrEmpty(path))
{ {
@ -30,26 +29,9 @@ namespace Jellyfin.Data.Entities.Libraries
Path = path; Path = path;
Kind = kind; Kind = kind;
if (release == null)
{
throw new ArgumentNullException(nameof(release));
}
release.MediaFiles.Add(this);
MediaFileStreams = new HashSet<MediaFileStream>(); MediaFileStreams = new HashSet<MediaFileStream>();
} }
/// <summary>
/// Initializes a new instance of the <see cref="MediaFile"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected MediaFile()
{
}
/// <summary> /// <summary>
/// Gets or sets the id. /// Gets or sets the id.
/// </summary> /// </summary>

View File

@ -1,4 +1,3 @@
using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Data.Interfaces; using Jellyfin.Data.Interfaces;
@ -14,27 +13,9 @@ namespace Jellyfin.Data.Entities.Libraries
/// Initializes a new instance of the <see cref="MediaFileStream"/> class. /// Initializes a new instance of the <see cref="MediaFileStream"/> class.
/// </summary> /// </summary>
/// <param name="streamNumber">The number of this stream.</param> /// <param name="streamNumber">The number of this stream.</param>
/// <param name="mediaFile">The media file.</param> public MediaFileStream(int streamNumber)
public MediaFileStream(int streamNumber, MediaFile mediaFile)
{ {
StreamNumber = streamNumber; StreamNumber = streamNumber;
if (mediaFile == null)
{
throw new ArgumentNullException(nameof(mediaFile));
}
mediaFile.MediaFileStreams.Add(this);
}
/// <summary>
/// Initializes a new instance of the <see cref="MediaFileStream"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected MediaFileStream()
{
} }
/// <summary> /// <summary>

View File

@ -24,16 +24,6 @@ namespace Jellyfin.Data.Entities.Libraries
Name = name; Name = name;
} }
/// <summary>
/// Initializes a new instance of the <see cref="MetadataProvider"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected MetadataProvider()
{
}
/// <summary> /// <summary>
/// Gets or sets the id. /// Gets or sets the id.
/// </summary> /// </summary>

View File

@ -14,8 +14,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// Initializes a new instance of the <see cref="MetadataProviderId"/> class. /// Initializes a new instance of the <see cref="MetadataProviderId"/> class.
/// </summary> /// </summary>
/// <param name="providerId">The provider id.</param> /// <param name="providerId">The provider id.</param>
/// <param name="itemMetadata">The metadata entity.</param> public MetadataProviderId(string providerId)
public MetadataProviderId(string providerId, ItemMetadata itemMetadata)
{ {
if (string.IsNullOrEmpty(providerId)) if (string.IsNullOrEmpty(providerId))
{ {
@ -23,23 +22,6 @@ namespace Jellyfin.Data.Entities.Libraries
} }
ProviderId = providerId; ProviderId = providerId;
if (itemMetadata == null)
{
throw new ArgumentNullException(nameof(itemMetadata));
}
itemMetadata.Sources.Add(this);
}
/// <summary>
/// Initializes a new instance of the <see cref="MetadataProviderId"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected MetadataProviderId()
{
} }
/// <summary> /// <summary>

View File

@ -13,7 +13,8 @@ namespace Jellyfin.Data.Entities.Libraries
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Movie"/> class. /// Initializes a new instance of the <see cref="Movie"/> class.
/// </summary> /// </summary>
public Movie() /// <param name="library">The library.</param>
public Movie(Library library) : base(library)
{ {
Releases = new HashSet<Release>(); Releases = new HashSet<Release>();
MovieMetadata = new HashSet<MovieMetadata>(); MovieMetadata = new HashSet<MovieMetadata>();

View File

@ -17,22 +17,9 @@ namespace Jellyfin.Data.Entities.Libraries
/// </summary> /// </summary>
/// <param name="title">The title or name of the movie.</param> /// <param name="title">The title or name of the movie.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param> /// <param name="language">ISO-639-3 3-character language codes.</param>
/// <param name="movie">The movie.</param> public MovieMetadata(string title, string language) : base(title, language)
public MovieMetadata(string title, string language, Movie movie) : base(title, language)
{ {
Studios = new HashSet<Company>(); Studios = new HashSet<Company>();
movie.MovieMetadata.Add(this);
}
/// <summary>
/// Initializes a new instance of the <see cref="MovieMetadata"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected MovieMetadata()
{
} }
/// <summary> /// <summary>

View File

@ -12,7 +12,8 @@ namespace Jellyfin.Data.Entities.Libraries
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="MusicAlbum"/> class. /// Initializes a new instance of the <see cref="MusicAlbum"/> class.
/// </summary> /// </summary>
public MusicAlbum() /// <param name="library">The library.</param>
public MusicAlbum(Library library) : base(library)
{ {
MusicAlbumMetadata = new HashSet<MusicAlbumMetadata>(); MusicAlbumMetadata = new HashSet<MusicAlbumMetadata>();
Tracks = new HashSet<Track>(); Tracks = new HashSet<Track>();

View File

@ -15,22 +15,9 @@ namespace Jellyfin.Data.Entities.Libraries
/// </summary> /// </summary>
/// <param name="title">The title or name of the album.</param> /// <param name="title">The title or name of the album.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param> /// <param name="language">ISO-639-3 3-character language codes.</param>
/// <param name="album">The music album.</param> public MusicAlbumMetadata(string title, string language) : base(title, language)
public MusicAlbumMetadata(string title, string language, MusicAlbum album) : base(title, language)
{ {
Labels = new HashSet<Company>(); Labels = new HashSet<Company>();
album.MusicAlbumMetadata.Add(this);
}
/// <summary>
/// Initializes a new instance of the <see cref="MusicAlbumMetadata"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected MusicAlbumMetadata()
{
} }
/// <summary> /// <summary>

View File

@ -31,16 +31,6 @@ namespace Jellyfin.Data.Entities.Libraries
Sources = new HashSet<MetadataProviderId>(); Sources = new HashSet<MetadataProviderId>();
} }
/// <summary>
/// Initializes a new instance of the <see cref="Person"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected Person()
{
}
/// <summary> /// <summary>
/// Gets or sets the id. /// Gets or sets the id.
/// </summary> /// </summary>

View File

@ -1,6 +1,5 @@
#pragma warning disable CA2227 #pragma warning disable CA2227
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
@ -18,31 +17,12 @@ namespace Jellyfin.Data.Entities.Libraries
/// Initializes a new instance of the <see cref="PersonRole"/> class. /// Initializes a new instance of the <see cref="PersonRole"/> class.
/// </summary> /// </summary>
/// <param name="type">The role type.</param> /// <param name="type">The role type.</param>
/// <param name="itemMetadata">The metadata.</param> public PersonRole(PersonRoleType type)
public PersonRole(PersonRoleType type, ItemMetadata itemMetadata)
{ {
Type = type; Type = type;
if (itemMetadata == null)
{
throw new ArgumentNullException(nameof(itemMetadata));
}
itemMetadata.PersonRoles.Add(this);
Sources = new HashSet<MetadataProviderId>(); Sources = new HashSet<MetadataProviderId>();
} }
/// <summary>
/// Initializes a new instance of the <see cref="PersonRole"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected PersonRole()
{
}
/// <summary> /// <summary>
/// Gets or sets the id. /// Gets or sets the id.
/// </summary> /// </summary>

View File

@ -13,7 +13,8 @@ namespace Jellyfin.Data.Entities.Libraries
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Photo"/> class. /// Initializes a new instance of the <see cref="Photo"/> class.
/// </summary> /// </summary>
public Photo() /// <param name="library">The library.</param>
public Photo(Library library) : base(library)
{ {
PhotoMetadata = new HashSet<PhotoMetadata>(); PhotoMetadata = new HashSet<PhotoMetadata>();
Releases = new HashSet<Release>(); Releases = new HashSet<Release>();

View File

@ -1,5 +1,3 @@
using System;
namespace Jellyfin.Data.Entities.Libraries namespace Jellyfin.Data.Entities.Libraries
{ {
/// <summary> /// <summary>
@ -12,24 +10,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </summary> /// </summary>
/// <param name="title">The title or name of the photo.</param> /// <param name="title">The title or name of the photo.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param> /// <param name="language">ISO-639-3 3-character language codes.</param>
/// <param name="photo">The photo.</param> public PhotoMetadata(string title, string language) : base(title, language)
public PhotoMetadata(string title, string language, Photo photo) : base(title, language)
{
if (photo == null)
{
throw new ArgumentNullException(nameof(photo));
}
photo.PhotoMetadata.Add(this);
}
/// <summary>
/// Initializes a new instance of the <see cref="PhotoMetadata"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected PhotoMetadata()
{ {
} }
} }

View File

@ -1,4 +1,3 @@
using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Data.Interfaces; using Jellyfin.Data.Interfaces;
@ -14,27 +13,9 @@ namespace Jellyfin.Data.Entities.Libraries
/// Initializes a new instance of the <see cref="Rating"/> class. /// Initializes a new instance of the <see cref="Rating"/> class.
/// </summary> /// </summary>
/// <param name="value">The value.</param> /// <param name="value">The value.</param>
/// <param name="itemMetadata">The metadata.</param> public Rating(double value)
public Rating(double value, ItemMetadata itemMetadata)
{ {
Value = value; Value = value;
if (itemMetadata == null)
{
throw new ArgumentNullException(nameof(itemMetadata));
}
itemMetadata.Ratings.Add(this);
}
/// <summary>
/// Initializes a new instance of the <see cref="Rating"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected Rating()
{
} }
/// <summary> /// <summary>

View File

@ -1,4 +1,3 @@
using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Data.Interfaces; using Jellyfin.Data.Interfaces;
@ -15,28 +14,10 @@ namespace Jellyfin.Data.Entities.Libraries
/// </summary> /// </summary>
/// <param name="minimumValue">The minimum value.</param> /// <param name="minimumValue">The minimum value.</param>
/// <param name="maximumValue">The maximum value.</param> /// <param name="maximumValue">The maximum value.</param>
/// <param name="rating">The rating.</param> public RatingSource(double minimumValue, double maximumValue)
public RatingSource(double minimumValue, double maximumValue, Rating rating)
{ {
MinimumValue = minimumValue; MinimumValue = minimumValue;
MaximumValue = maximumValue; MaximumValue = maximumValue;
if (rating == null)
{
throw new ArgumentNullException(nameof(rating));
}
rating.RatingType = this;
}
/// <summary>
/// Initializes a new instance of the <see cref="RatingSource"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected RatingSource()
{
} }
/// <summary> /// <summary>

View File

@ -17,8 +17,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// Initializes a new instance of the <see cref="Release"/> class. /// Initializes a new instance of the <see cref="Release"/> class.
/// </summary> /// </summary>
/// <param name="name">The name of this release.</param> /// <param name="name">The name of this release.</param>
/// <param name="owner">The owner of this release.</param> public Release(string name)
public Release(string name, IHasReleases owner)
{ {
if (string.IsNullOrEmpty(name)) if (string.IsNullOrEmpty(name))
{ {
@ -27,22 +26,10 @@ namespace Jellyfin.Data.Entities.Libraries
Name = name; Name = name;
owner?.Releases.Add(this);
MediaFiles = new HashSet<MediaFile>(); MediaFiles = new HashSet<MediaFile>();
Chapters = new HashSet<Chapter>(); Chapters = new HashSet<Chapter>();
} }
/// <summary>
/// Initializes a new instance of the <see cref="Release"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected Release()
{
}
/// <summary> /// <summary>
/// Gets or sets the id. /// Gets or sets the id.
/// </summary> /// </summary>

View File

@ -1,6 +1,5 @@
#pragma warning disable CA2227 #pragma warning disable CA2227
using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace Jellyfin.Data.Entities.Libraries namespace Jellyfin.Data.Entities.Libraries
@ -13,30 +12,13 @@ namespace Jellyfin.Data.Entities.Libraries
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Season"/> class. /// Initializes a new instance of the <see cref="Season"/> class.
/// </summary> /// </summary>
/// <param name="series">The series.</param> /// <param name="library">The library.</param>
public Season(Series series) public Season(Library library) : base(library)
{ {
if (series == null)
{
throw new ArgumentNullException(nameof(series));
}
series.Seasons.Add(this);
Episodes = new HashSet<Episode>(); Episodes = new HashSet<Episode>();
SeasonMetadata = new HashSet<SeasonMetadata>(); SeasonMetadata = new HashSet<SeasonMetadata>();
} }
/// <summary>
/// Initializes a new instance of the <see cref="Season"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected Season()
{
}
/// <summary> /// <summary>
/// Gets or sets the season number. /// Gets or sets the season number.
/// </summary> /// </summary>

View File

@ -1,4 +1,3 @@
using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace Jellyfin.Data.Entities.Libraries namespace Jellyfin.Data.Entities.Libraries
@ -13,24 +12,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </summary> /// </summary>
/// <param name="title">The title or name of the object.</param> /// <param name="title">The title or name of the object.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param> /// <param name="language">ISO-639-3 3-character language codes.</param>
/// <param name="season">The season.</param> public SeasonMetadata(string title, string language) : base(title, language)
public SeasonMetadata(string title, string language, Season season) : base(title, language)
{
if (season == null)
{
throw new ArgumentNullException(nameof(season));
}
season.SeasonMetadata.Add(this);
}
/// <summary>
/// Initializes a new instance of the <see cref="SeasonMetadata"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected SeasonMetadata()
{ {
} }

View File

@ -13,7 +13,8 @@ namespace Jellyfin.Data.Entities.Libraries
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Series"/> class. /// Initializes a new instance of the <see cref="Series"/> class.
/// </summary> /// </summary>
public Series() /// <param name="library">The library.</param>
public Series(Library library) : base(library)
{ {
DateAdded = DateTime.UtcNow; DateAdded = DateTime.UtcNow;
Seasons = new HashSet<Season>(); Seasons = new HashSet<Season>();

View File

@ -1,6 +1,5 @@
#pragma warning disable CA2227 #pragma warning disable CA2227
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
@ -18,29 +17,11 @@ namespace Jellyfin.Data.Entities.Libraries
/// </summary> /// </summary>
/// <param name="title">The title or name of the object.</param> /// <param name="title">The title or name of the object.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param> /// <param name="language">ISO-639-3 3-character language codes.</param>
/// <param name="series">The series.</param> public SeriesMetadata(string title, string language) : base(title, language)
public SeriesMetadata(string title, string language, Series series) : base(title, language)
{ {
if (series == null)
{
throw new ArgumentNullException(nameof(series));
}
series.SeriesMetadata.Add(this);
Networks = new HashSet<Company>(); Networks = new HashSet<Company>();
} }
/// <summary>
/// Initializes a new instance of the <see cref="SeriesMetadata"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected SeriesMetadata()
{
}
/// <summary> /// <summary>
/// Gets or sets the outline. /// Gets or sets the outline.
/// </summary> /// </summary>

View File

@ -1,6 +1,5 @@
#pragma warning disable CA2227 #pragma warning disable CA2227
using System;
using System.Collections.Generic; using System.Collections.Generic;
using Jellyfin.Data.Interfaces; using Jellyfin.Data.Interfaces;
@ -14,30 +13,13 @@ namespace Jellyfin.Data.Entities.Libraries
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Track"/> class. /// Initializes a new instance of the <see cref="Track"/> class.
/// </summary> /// </summary>
/// <param name="album">The album.</param> /// <param name="library">The library.</param>
public Track(MusicAlbum album) public Track(Library library) : base(library)
{ {
if (album == null)
{
throw new ArgumentNullException(nameof(album));
}
album.Tracks.Add(this);
Releases = new HashSet<Release>(); Releases = new HashSet<Release>();
TrackMetadata = new HashSet<TrackMetadata>(); TrackMetadata = new HashSet<TrackMetadata>();
} }
/// <summary>
/// Initializes a new instance of the <see cref="Track"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected Track()
{
}
/// <summary> /// <summary>
/// Gets or sets the track number. /// Gets or sets the track number.
/// </summary> /// </summary>

View File

@ -1,5 +1,3 @@
using System;
namespace Jellyfin.Data.Entities.Libraries namespace Jellyfin.Data.Entities.Libraries
{ {
/// <summary> /// <summary>
@ -12,24 +10,7 @@ namespace Jellyfin.Data.Entities.Libraries
/// </summary> /// </summary>
/// <param name="title">The title or name of the object.</param> /// <param name="title">The title or name of the object.</param>
/// <param name="language">ISO-639-3 3-character language codes.</param> /// <param name="language">ISO-639-3 3-character language codes.</param>
/// <param name="track">The track.</param> public TrackMetadata(string title, string language) : base(title, language)
public TrackMetadata(string title, string language, Track track) : base(title, language)
{
if (track == null)
{
throw new ArgumentNullException(nameof(track));
}
track.TrackMetadata.Add(this);
}
/// <summary>
/// Initializes a new instance of the <see cref="TrackMetadata"/> class.
/// </summary>
/// <remarks>
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </remarks>
protected TrackMetadata()
{ {
} }
} }

View File

@ -22,14 +22,6 @@ namespace Jellyfin.Data.Entities
Value = value; Value = value;
} }
/// <summary>
/// Initializes a new instance of the <see cref="Permission"/> class.
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </summary>
protected Permission()
{
}
/// <summary> /// <summary>
/// Gets or sets the id of this permission. /// Gets or sets the id of this permission.
/// </summary> /// </summary>

View File

@ -23,14 +23,6 @@ namespace Jellyfin.Data.Entities
Value = value ?? throw new ArgumentNullException(nameof(value)); Value = value ?? throw new ArgumentNullException(nameof(value));
} }
/// <summary>
/// Initializes a new instance of the <see cref="Preference"/> class.
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </summary>
protected Preference()
{
}
/// <summary> /// <summary>
/// Gets or sets the id of this preference. /// Gets or sets the id of this preference.
/// </summary> /// </summary>

View File

@ -77,14 +77,6 @@ namespace Jellyfin.Data.Entities
AddDefaultPreferences(); AddDefaultPreferences();
} }
/// <summary>
/// Initializes a new instance of the <see cref="User"/> class.
/// Default constructor. Protected due to required properties, but present because EF needs it.
/// </summary>
protected User()
{
}
/// <summary> /// <summary>
/// Gets or sets the Id of the user. /// Gets or sets the Id of the user.
/// </summary> /// </summary>