jellyfin-server/MediaBrowser.Controller/Entities/LinkedChild.cs

66 lines
1.5 KiB
C#
Raw Normal View History

2013-07-05 13:47:10 +00:00
using System;
2013-10-03 15:24:32 +00:00
using System.Collections.Generic;
2017-05-04 18:14:45 +00:00
using MediaBrowser.Model.IO;
2016-10-25 19:02:04 +00:00
using MediaBrowser.Model.Serialization;
2013-07-05 13:47:10 +00:00
namespace MediaBrowser.Controller.Entities
{
public class LinkedChild
{
public string Path { get; set; }
public LinkedChildType Type { get; set; }
2013-10-03 15:24:32 +00:00
2014-08-06 04:18:13 +00:00
[IgnoreDataMember]
public string Id { get; set; }
2013-10-03 15:24:32 +00:00
/// <summary>
/// Serves as a cache
/// </summary>
public Guid? ItemId { get; set; }
public static LinkedChild Create(BaseItem item)
{
return new LinkedChild
{
2014-08-05 03:41:56 +00:00
Path = item.Path,
Type = LinkedChildType.Manual
};
}
2014-08-06 04:18:13 +00:00
public LinkedChild()
{
Id = Guid.NewGuid().ToString("N");
}
2013-07-05 13:47:10 +00:00
}
public enum LinkedChildType
{
Manual = 0,
Shortcut = 1
2013-07-05 13:47:10 +00:00
}
2013-10-03 15:24:32 +00:00
public class LinkedChildComparer : IEqualityComparer<LinkedChild>
2013-07-05 13:47:10 +00:00
{
2017-05-04 18:14:45 +00:00
private readonly IFileSystem _fileSystem;
public LinkedChildComparer(IFileSystem fileSystem)
{
_fileSystem = fileSystem;
}
2013-10-03 15:24:32 +00:00
public bool Equals(LinkedChild x, LinkedChild y)
2013-07-05 13:47:10 +00:00
{
2013-10-03 15:24:32 +00:00
if (x.Type == y.Type)
2013-07-05 13:47:10 +00:00
{
2017-05-04 18:14:45 +00:00
return _fileSystem.AreEqual(x.Path, y.Path);
2013-07-05 13:47:10 +00:00
}
2013-10-03 15:24:32 +00:00
return false;
}
2013-07-05 13:47:10 +00:00
2013-10-03 15:24:32 +00:00
public int GetHashCode(LinkedChild obj)
{
return (obj.Path + obj.Type).GetHashCode();
2013-07-05 13:47:10 +00:00
}
}
}