Files
Pf2eDataScrapper/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/Compendium/CompendiumFolder.cs
T

60 lines
1.6 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
namespace Pf2eDataScrapper.Importers.Implementations.Pf2eFoundry.Compendium
{
internal class CompendiumFolder
{
public readonly string Id;
public readonly string Name;
public readonly string? Path;
public readonly bool IsContained;
public CompendiumFolder? Parent;
public readonly CompendiumDocumentType Type;
public CompendiumFolder(JObject json)
{
if (json.ContainsKey("_id"))
{
// Вложенная папка через _folders.json
Id = json["_id"]!.ToString();
Name = json["name"]!.ToString();
Path = null;
IsContained = true;
}
else
{
// Корневой пак в system.json
Id = json["name"]!.ToString();
Name = json["label"]!.ToString();
Path = json["path"]!.ToString();
IsContained = false;
}
Type = (CompendiumDocumentType)Enum.Parse(typeof(CompendiumDocumentType), json["type"]!.ToString());
}
public CompendiumFolder(string id, string name)
{
Id = id;
Name = name;
Path = null;
IsContained = false;
}
public override string ToString()
{
return $"CompendiumFolder([Id={Id}][Type={Type}][Name={Name}][Path={Path}][Parent={Parent?.Name ?? "null"}])";
}
}
}