2024-04-16 18:29:40 +00:00
|
|
|
using System.Text.Json.Serialization;
|
|
|
|
using LootDumpProcessor.Utils;
|
2023-08-12 19:08:38 +01:00
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
|
|
namespace LootDumpProcessor.Storage.Collections;
|
|
|
|
|
|
|
|
public class SubdivisionedKeyableDictionary<K, V> : Dictionary<K, V>, IKeyable
|
|
|
|
{
|
|
|
|
[JsonProperty("__id__")]
|
|
|
|
[JsonPropertyName("__id__")]
|
2024-04-16 18:29:40 +00:00
|
|
|
public string __ID { get; set; } = KeyGenerator.GetNextKey();
|
2023-08-12 19:08:38 +01:00
|
|
|
|
|
|
|
[JsonProperty("extras")]
|
|
|
|
[JsonPropertyName("extras")]
|
|
|
|
public string? Extras
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
if (ExtraSubdivisions == null)
|
|
|
|
return null;
|
|
|
|
return string.Join(",", ExtraSubdivisions);
|
|
|
|
}
|
|
|
|
set { ExtraSubdivisions = value.Split(","); }
|
|
|
|
}
|
|
|
|
|
|
|
|
[Newtonsoft.Json.JsonIgnore]
|
|
|
|
[System.Text.Json.Serialization.JsonIgnore]
|
|
|
|
private string[]? ExtraSubdivisions { get; set; }
|
|
|
|
|
|
|
|
public IKey GetKey()
|
|
|
|
{
|
|
|
|
if (ExtraSubdivisions != null)
|
|
|
|
{
|
|
|
|
var subdivisions = new List<string>
|
|
|
|
{
|
|
|
|
"dictionaries"
|
|
|
|
};
|
|
|
|
subdivisions.AddRange(ExtraSubdivisions);
|
|
|
|
subdivisions.Add(__ID);
|
|
|
|
return new SubdivisionedUniqueKey(subdivisions.ToArray());
|
|
|
|
}
|
2024-04-16 18:29:40 +00:00
|
|
|
|
|
|
|
return new SubdivisionedUniqueKey(["dictionaries", __ID]);
|
2023-08-12 19:08:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void AddExtraSubdivisions(string[] extras)
|
|
|
|
{
|
|
|
|
ExtraSubdivisions = extras;
|
|
|
|
}
|
|
|
|
}
|