2013-07-05 06:47:10 -07:00
|
|
|
|
using System;
|
2013-10-03 08:24:32 -07:00
|
|
|
|
using System.Collections.Generic;
|
2016-10-25 12:02:04 -07:00
|
|
|
|
using MediaBrowser.Model.Serialization;
|
2013-07-05 06:47:10 -07:00
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Controller.Entities
|
|
|
|
|
{
|
|
|
|
|
public class LinkedChild
|
|
|
|
|
{
|
|
|
|
|
public string Path { get; set; }
|
|
|
|
|
public LinkedChildType Type { get; set; }
|
2013-10-03 08:24:32 -07:00
|
|
|
|
|
2014-08-05 21:18:13 -07:00
|
|
|
|
[IgnoreDataMember]
|
|
|
|
|
public string Id { get; set; }
|
|
|
|
|
|
2013-10-03 08:24:32 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Serves as a cache
|
|
|
|
|
/// </summary>
|
2014-02-26 19:44:16 -07:00
|
|
|
|
public Guid? ItemId { get; set; }
|
2014-08-02 19:16:37 -07:00
|
|
|
|
|
|
|
|
|
public static LinkedChild Create(BaseItem item)
|
|
|
|
|
{
|
|
|
|
|
return new LinkedChild
|
|
|
|
|
{
|
2014-08-04 20:41:56 -07:00
|
|
|
|
Path = item.Path,
|
|
|
|
|
Type = LinkedChildType.Manual
|
2014-08-02 19:16:37 -07:00
|
|
|
|
};
|
|
|
|
|
}
|
2014-08-05 21:18:13 -07:00
|
|
|
|
|
|
|
|
|
public LinkedChild()
|
|
|
|
|
{
|
|
|
|
|
Id = Guid.NewGuid().ToString("N");
|
|
|
|
|
}
|
2013-07-05 06:47:10 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum LinkedChildType
|
|
|
|
|
{
|
2014-03-07 11:48:55 -07:00
|
|
|
|
Manual = 0,
|
|
|
|
|
Shortcut = 1
|
2013-07-05 06:47:10 -07:00
|
|
|
|
}
|
|
|
|
|
|
2013-10-03 08:24:32 -07:00
|
|
|
|
public class LinkedChildComparer : IEqualityComparer<LinkedChild>
|
2013-07-05 06:47:10 -07:00
|
|
|
|
{
|
2013-10-03 08:24:32 -07:00
|
|
|
|
public bool Equals(LinkedChild x, LinkedChild y)
|
2013-07-05 06:47:10 -07:00
|
|
|
|
{
|
2013-10-03 08:24:32 -07:00
|
|
|
|
if (x.Type == y.Type)
|
2013-07-05 06:47:10 -07:00
|
|
|
|
{
|
2013-10-03 08:24:32 -07:00
|
|
|
|
return string.Equals(x.Path, y.Path, StringComparison.OrdinalIgnoreCase);
|
2013-07-05 06:47:10 -07:00
|
|
|
|
}
|
2013-10-03 08:24:32 -07:00
|
|
|
|
return false;
|
|
|
|
|
}
|
2013-07-05 06:47:10 -07:00
|
|
|
|
|
2013-10-03 08:24:32 -07:00
|
|
|
|
public int GetHashCode(LinkedChild obj)
|
|
|
|
|
{
|
2014-03-07 11:48:55 -07:00
|
|
|
|
return (obj.Path + obj.Type).GetHashCode();
|
2013-07-05 06:47:10 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|