aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/Entities/LinkedChild.cs
blob: fd5fef3dc5e36046e5e4ee9393a6f79bd0e078d9 (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
46
47
48
#nullable disable

#pragma warning disable CS1591

using System;
using System.Globalization;
using System.Text.Json.Serialization;

namespace MediaBrowser.Controller.Entities
{
    public class LinkedChild
    {
        public LinkedChild()
        {
            Id = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture);
        }

        public string Path { get; set; }

        public LinkedChildType Type { get; set; }

        public string LibraryItemId { get; set; }

        [JsonIgnore]
        public string Id { get; set; }

        /// <summary>
        /// Gets or sets the linked item id.
        /// </summary>
        public Guid? ItemId { get; set; }

        public static LinkedChild Create(BaseItem item)
        {
            var child = new LinkedChild
            {
                Path = item.Path,
                Type = LinkedChildType.Manual
            };

            if (string.IsNullOrEmpty(child.Path))
            {
                child.LibraryItemId = item.Id.ToString("N", CultureInfo.InvariantCulture);
            }

            return child;
        }
    }
}