using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Data.Interfaces;
namespace Jellyfin.Data.Entities.Libraries
{
///
/// An entity representing a unique identifier for a metadata provider.
///
public class MetadataProviderId : IHasConcurrencyToken
{
///
/// Initializes a new instance of the class.
///
/// The provider id.
/// The metadata entity.
public MetadataProviderId(string providerId, ItemMetadata itemMetadata)
{
if (string.IsNullOrEmpty(providerId))
{
throw new ArgumentNullException(nameof(providerId));
}
ProviderId = providerId;
if (itemMetadata == null)
{
throw new ArgumentNullException(nameof(itemMetadata));
}
itemMetadata.Sources.Add(this);
}
///
/// Initializes a new instance of the class.
///
///
/// Default constructor. Protected due to required properties, but present because EF needs it.
///
protected MetadataProviderId()
{
}
///
/// Gets or sets the id.
///
///
/// Identity, Indexed, Required.
///
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; protected set; }
///
/// Gets or sets the provider id.
///
///
/// Required, Max length = 255.
///
[Required]
[MaxLength(255)]
[StringLength(255)]
public string ProviderId { get; set; }
///
[ConcurrencyCheck]
public uint RowVersion { get; set; }
///
/// Gets or sets the metadata provider.
///
///
/// Required.
///
public virtual MetadataProvider MetadataProvider { get; set; }
///
public void OnSavingChanges()
{
RowVersion++;
}
}
}