aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/Entities/LinkedChild.cs
blob: 84af0500ddf4b9d7ab6a47cd099619c4edf092c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;

namespace MediaBrowser.Controller.Entities
{
    public class LinkedChild
    {
        public string Path { get; set; }
        public LinkedChildType Type { get; set; }

        public string ItemName { get; set; }
        public string ItemType { get; set; }
        public int? ItemYear { get; set; }

        /// <summary>
        /// Serves as a cache
        /// </summary>
        [IgnoreDataMember]
        public Guid? ItemId { get; set; }
    }

    public enum LinkedChildType
    {
        Manual = 1,
        Shortcut = 2
    }

    public class LinkedChildComparer : IEqualityComparer<LinkedChild>
    {
        public bool Equals(LinkedChild x, LinkedChild y)
        {
            if (x.Type == y.Type)
            {
                return string.Equals(x.Path, y.Path, StringComparison.OrdinalIgnoreCase);
            }
            return false;
        }

        public int GetHashCode(LinkedChild obj)
        {
            return (obj.Path + obj.Type.ToString()).GetHashCode();
        }
    }
}