Merge pull request #2502 from JustAMan/baseitem-equals

Adds BaseItem.Equals method that compares items by their Id
This commit is contained in:
Bond-009 2020-03-11 16:00:36 +01:00 committed by GitHub
commit 008a76cf4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -33,7 +33,7 @@ namespace MediaBrowser.Controller.Entities
/// <summary> /// <summary>
/// Class BaseItem /// Class BaseItem
/// </summary> /// </summary>
public abstract class BaseItem : IHasProviderIds, IHasLookupInfo<ItemLookupInfo> public abstract class BaseItem : IHasProviderIds, IHasLookupInfo<ItemLookupInfo>, IEquatable<BaseItem>
{ {
/// <summary> /// <summary>
/// The supported image extensions /// The supported image extensions
@ -2914,5 +2914,17 @@ namespace MediaBrowser.Controller.Entities
public static readonly IReadOnlyCollection<ExtraType> DisplayExtraTypes = new[] { Model.Entities.ExtraType.BehindTheScenes, Model.Entities.ExtraType.Clip, Model.Entities.ExtraType.DeletedScene, Model.Entities.ExtraType.Interview, Model.Entities.ExtraType.Sample, Model.Entities.ExtraType.Scene }; public static readonly IReadOnlyCollection<ExtraType> DisplayExtraTypes = new[] { Model.Entities.ExtraType.BehindTheScenes, Model.Entities.ExtraType.Clip, Model.Entities.ExtraType.DeletedScene, Model.Entities.ExtraType.Interview, Model.Entities.ExtraType.Sample, Model.Entities.ExtraType.Scene };
public virtual bool SupportsExternalTransfer => false; public virtual bool SupportsExternalTransfer => false;
/// <inheritdoc />
public override bool Equals(object obj)
{
return obj is BaseItem baseItem && this.Equals(baseItem);
}
/// <inheritdoc />
public bool Equals(BaseItem item) => Object.Equals(Id, item?.Id);
/// <inheritdoc />
public override int GetHashCode() => HashCode.Combine(Id);
} }
} }