using System; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Runtime.CompilerServices; using Jellyfin.Data.Enums; namespace Jellyfin.Data.Entities { public partial class Permission : ISavingChanges { partial void Init(); /// /// Default constructor. Protected due to required properties, but present because EF needs it. /// protected Permission() { Init(); } /// /// Public constructor with required data /// /// /// /// public Permission(PermissionKind kind, bool value) { Kind = kind; Value = value; Init(); } /// /// Static create function (for use in LINQ queries, etc.) /// /// /// /// public static Permission Create(PermissionKind kind, bool value) { return new Permission(kind, value); } /************************************************************************* * Properties *************************************************************************/ /// /// Identity, Indexed, Required /// [Key] [Required] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; protected set; } /// /// Backing field for Kind /// protected PermissionKind _Kind; /// /// When provided in a partial class, allows value of Kind to be changed before setting. /// partial void SetKind(PermissionKind oldValue, ref PermissionKind newValue); /// /// When provided in a partial class, allows value of Kind to be changed before returning. /// partial void GetKind(ref PermissionKind result); /// /// Required /// [Required] public PermissionKind Kind { get { PermissionKind value = _Kind; GetKind(ref value); return _Kind = value; } set { PermissionKind oldValue = _Kind; SetKind(oldValue, ref value); if (oldValue != value) { _Kind = value; OnPropertyChanged(); } } } /// /// Required /// [Required] public bool Value { get; set; } /// /// Required, ConcurrencyToken. /// [ConcurrencyCheck] [Required] public uint RowVersion { get; set; } public void OnSavingChanges() { RowVersion++; } /************************************************************************* * Navigation properties *************************************************************************/ public virtual event PropertyChangedEventHandler PropertyChanged; protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } } }