Обработка через CSharper
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"version": 1,
|
||||
"isRoot": true,
|
||||
"tools": {
|
||||
"csharpier": {
|
||||
"version": "1.0.0",
|
||||
"commands": [
|
||||
"csharpier"
|
||||
],
|
||||
"rollForward": false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,16 +2,20 @@
|
||||
using Slugify;
|
||||
|
||||
namespace Pf2eDataScrapper.Importers;
|
||||
|
||||
public class DatabaseHelper
|
||||
{
|
||||
public Pf2eDbContext Context = new();
|
||||
|
||||
public SlugHelper Slugger = new();
|
||||
|
||||
|
||||
private int _id = 0;
|
||||
|
||||
public int NextEntityId { get => ++_id; set => _id = value; }
|
||||
public int NextEntityId
|
||||
{
|
||||
get => ++_id;
|
||||
set => _id = value;
|
||||
}
|
||||
|
||||
private DatabaseHelper()
|
||||
{
|
||||
@@ -23,11 +27,7 @@ public class DatabaseHelper
|
||||
return Slugger.GenerateSlug(name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static readonly DatabaseHelper Instance = new();
|
||||
|
||||
public static readonly Pf2eDbContext DbContext = Instance.Context;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -10,7 +10,8 @@ internal class AonprdImporter : AbstractImporter
|
||||
|
||||
public override string Slug => "aonprd";
|
||||
|
||||
public override AbstractImporterRepository Repository => new AonprdRepository(this, "https://elasticsearch.aonprd.com");
|
||||
public override AbstractImporterRepository Repository =>
|
||||
new AonprdRepository(this, "https://elasticsearch.aonprd.com");
|
||||
|
||||
public AonprdLoader Loader { get; }
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ internal class AonprdLoader(AonprdImporter importer)
|
||||
foreach (KeyValuePair<string, JToken?> kvp in indexJson)
|
||||
{
|
||||
string file = kvp.Key.ToString();
|
||||
JArray items = (JArray) kvp.Value!;
|
||||
JArray items = (JArray)kvp.Value!;
|
||||
|
||||
foreach (JToken item in items)
|
||||
{
|
||||
@@ -54,7 +54,7 @@ internal class AonprdLoader(AonprdImporter importer)
|
||||
continue;
|
||||
}
|
||||
|
||||
LoaderEntry entry = new(id, file, (JObject) item);
|
||||
LoaderEntry entry = new(id, file, (JObject)item);
|
||||
|
||||
if (types.Contains(entry.Type))
|
||||
{
|
||||
@@ -64,7 +64,6 @@ internal class AonprdLoader(AonprdImporter importer)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class LoaderEntry(string id, string file, JObject itemJson) : AonprdReference(id, file)
|
||||
{
|
||||
public JObject Json { get; } = itemJson;
|
||||
|
||||
@@ -4,7 +4,8 @@ using Pf2eDataScrapper.Importers.Repositories;
|
||||
|
||||
namespace Pf2eDataScrapper.Importers.Implementations.Aonprd;
|
||||
|
||||
internal class AonprdRepository(AbstractImporter importer, string searchUrl) : AbstractImporterRepository(importer)
|
||||
internal class AonprdRepository(AbstractImporter importer, string searchUrl)
|
||||
: AbstractImporterRepository(importer)
|
||||
{
|
||||
public readonly string SearchUrl = searchUrl;
|
||||
|
||||
@@ -24,7 +25,6 @@ internal class AonprdRepository(AbstractImporter importer, string searchUrl) : A
|
||||
return reader.ReadToEnd();
|
||||
}
|
||||
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
if (CheckRevision())
|
||||
@@ -33,7 +33,9 @@ internal class AonprdRepository(AbstractImporter importer, string searchUrl) : A
|
||||
return;
|
||||
}
|
||||
|
||||
Console.WriteLine($"Данные Aonprd устарели, обновляем {RepositoryDirPath} до ревизии {Revision}...");
|
||||
Console.WriteLine(
|
||||
$"Данные Aonprd устарели, обновляем {RepositoryDirPath} до ревизии {Revision}..."
|
||||
);
|
||||
|
||||
if (Directory.Exists(RepositoryDirPath))
|
||||
{
|
||||
@@ -63,7 +65,6 @@ internal class AonprdRepository(AbstractImporter importer, string searchUrl) : A
|
||||
WriteFile($"{fileName}.json", fileContent);
|
||||
}
|
||||
|
||||
|
||||
bar.Refresh(indexJson.Count, "Готово!");
|
||||
}
|
||||
|
||||
@@ -75,7 +76,10 @@ internal class AonprdRepository(AbstractImporter importer, string searchUrl) : A
|
||||
{
|
||||
JObject page = JObject.Parse(Load("/aon/_doc/feat-1"));
|
||||
|
||||
Revision = Convert.ToInt32(page.SelectToken("_index")?.ToObject<string>()?.Replace("aon", "") ?? throw new Exception("Can't get revision"));
|
||||
Revision = Convert.ToInt32(
|
||||
page.SelectToken("_index")?.ToObject<string>()?.Replace("aon", "")
|
||||
?? throw new Exception("Can't get revision")
|
||||
);
|
||||
|
||||
string revisionFile = Path.Combine(RepositoryDirPath, "revision.txt");
|
||||
if (!File.Exists(revisionFile))
|
||||
|
||||
@@ -19,13 +19,10 @@ internal class AonprdCompendium
|
||||
}
|
||||
|
||||
public int Count() => Types.Values.Sum(t => t.Count);
|
||||
public int Count(IEnumerable<string> types) => Types.Values
|
||||
.Where(t => types.Contains(t.Type))
|
||||
.Sum(t => t.Count);
|
||||
|
||||
public IEnumerable<string> Files(IEnumerable<string> types) => Types.Values
|
||||
.Where(t => types.Contains(t.Type))
|
||||
.SelectMany(t => t.Files)
|
||||
.Distinct();
|
||||
public int Count(IEnumerable<string> types) =>
|
||||
Types.Values.Where(t => types.Contains(t.Type)).Sum(t => t.Count);
|
||||
|
||||
public IEnumerable<string> Files(IEnumerable<string> types) =>
|
||||
Types.Values.Where(t => types.Contains(t.Type)).SelectMany(t => t.Files).Distinct();
|
||||
}
|
||||
|
||||
@@ -12,7 +12,11 @@ internal class AonprdReference(string id, string file)
|
||||
{
|
||||
static string? subType(string type, string cat)
|
||||
{
|
||||
return type.StartsWith($"{cat}-") && type != cat ? type.EndsWith("-bonus") ? $"{cat}-bonus" : $"{cat}-sub" : null;
|
||||
return type.StartsWith($"{cat}-") && type != cat
|
||||
? type.EndsWith("-bonus")
|
||||
? $"{cat}-bonus"
|
||||
: $"{cat}-sub"
|
||||
: null;
|
||||
}
|
||||
|
||||
string type = string.Join('-', id.Split('-')[0..^1]);
|
||||
|
||||
@@ -6,7 +6,8 @@ internal class AonprdType(string type)
|
||||
|
||||
public readonly List<AonprdReference> Items = [];
|
||||
|
||||
public AonprdType(AonprdReference reference) : this(reference.Type)
|
||||
public AonprdType(AonprdReference reference)
|
||||
: this(reference.Type)
|
||||
{
|
||||
Items.Add(reference);
|
||||
}
|
||||
|
||||
@@ -34,9 +34,19 @@ internal class AonprdDataBuilder(AonprdLoader loader)
|
||||
{
|
||||
Console.WriteLine("Building data...");
|
||||
|
||||
ConcurrentWriter window = new Window(0, 0, Console.WindowWidth, Console.WindowHeight).Concurrent();
|
||||
ConcurrentWriter window = new Window(
|
||||
0,
|
||||
0,
|
||||
Console.WindowWidth,
|
||||
Console.WindowHeight
|
||||
).Concurrent();
|
||||
|
||||
IConsole bars = window.OpenBox("Progress", Console.WindowWidth, 4, new BoxStyle { Body = Colors.WhiteOnBlack });
|
||||
IConsole bars = window.OpenBox(
|
||||
"Progress",
|
||||
Console.WindowWidth,
|
||||
4,
|
||||
new BoxStyle { Body = Colors.WhiteOnBlack }
|
||||
);
|
||||
|
||||
Window output = new(0, 4, Console.WindowWidth, Console.WindowHeight - 4, window);
|
||||
|
||||
@@ -56,7 +66,7 @@ internal class AonprdDataBuilder(AonprdLoader loader)
|
||||
bar2.Refresh(j++, $"{entry.Id}");
|
||||
|
||||
AonprdProcessorInput input = new(entry.Json);
|
||||
AbstractProcessor processor = (AbstractProcessor) item.Constructor.Invoke([input]);
|
||||
AbstractProcessor processor = (AbstractProcessor)item.Constructor.Invoke([input]);
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@@ -90,5 +90,4 @@ internal class AonprdProcessorInput(JObject input) : ProcessorInput(input)
|
||||
public bool IsReaction = false;
|
||||
public bool IsFreeAction = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+8
-9
@@ -9,13 +9,12 @@ public class AonprdProcessorAttribute(string name, string type, string[] depende
|
||||
|
||||
public readonly IEnumerable<string> Dependencies = dependencies;
|
||||
|
||||
public AonprdProcessorAttribute(string type) : this(type, type, ["trait", "source"])
|
||||
{
|
||||
}
|
||||
public AonprdProcessorAttribute(string type, string[] dependencies) : this(type, type, dependencies)
|
||||
{
|
||||
}
|
||||
public AonprdProcessorAttribute(string name, string type) : this(name, type, ["trait", "source"])
|
||||
{
|
||||
}
|
||||
public AonprdProcessorAttribute(string type)
|
||||
: this(type, type, ["trait", "source"]) { }
|
||||
|
||||
public AonprdProcessorAttribute(string type, string[] dependencies)
|
||||
: this(type, type, dependencies) { }
|
||||
|
||||
public AonprdProcessorAttribute(string name, string type)
|
||||
: this(name, type, ["trait", "source"]) { }
|
||||
}
|
||||
|
||||
+15
-10
@@ -26,18 +26,25 @@ internal class AonprdProcessorCollection
|
||||
|
||||
if (!type.IsSubclassOf(typeof(AbstractProcessor)))
|
||||
{
|
||||
throw new Exception($"'AonprdProcessor' attribute should only be applied to children of 'AbstractProcessor' class. '{type.FullName}' is not.");
|
||||
throw new Exception(
|
||||
$"'AonprdProcessor' attribute should only be applied to children of 'AbstractProcessor' class. '{type.FullName}' is not."
|
||||
);
|
||||
}
|
||||
|
||||
AonprdProcessorAttribute attribute = type.GetCustomAttribute<AonprdProcessorAttribute>()!;
|
||||
AonprdProcessorAttribute attribute =
|
||||
type.GetCustomAttribute<AonprdProcessorAttribute>()!;
|
||||
|
||||
ConstructorInfo constructor = type.GetConstructor([typeof(AonprdProcessorInput)])!;
|
||||
|
||||
ProcessorItem? collision = Items.FirstOrDefault(i => i.Attribute.Name == attribute.Name);
|
||||
ProcessorItem? collision = Items.FirstOrDefault(i =>
|
||||
i.Attribute.Name == attribute.Name
|
||||
);
|
||||
if (collision is not null)
|
||||
{
|
||||
throw new Exception($"Multiply attributes 'AonprdProcessor' have same name '{attribute.Name}'." +
|
||||
$" They are added to classes: '{type.FullName}' and '{collision.Constructor.DeclaringType!.FullName}'");
|
||||
throw new Exception(
|
||||
$"Multiply attributes 'AonprdProcessor' have same name '{attribute.Name}'."
|
||||
+ $" They are added to classes: '{type.FullName}' and '{collision.Constructor.DeclaringType!.FullName}'"
|
||||
);
|
||||
}
|
||||
|
||||
Items.Add(new ProcessorItem(attribute, constructor));
|
||||
@@ -57,7 +64,9 @@ internal class AonprdProcessorCollection
|
||||
continue;
|
||||
}
|
||||
|
||||
IEnumerable<int> dependencyPriorities = item.Attribute.Dependencies.Select(d => priorities.TryGetValue(d, out int value) ? value : -1);
|
||||
IEnumerable<int> dependencyPriorities = item.Attribute.Dependencies.Select(d =>
|
||||
priorities.TryGetValue(d, out int value) ? value : -1
|
||||
);
|
||||
|
||||
if (dependencyPriorities.Any(p => p == -1))
|
||||
{
|
||||
@@ -81,8 +90,4 @@ internal class AonprdProcessorCollection
|
||||
yield return item;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -16,4 +16,4 @@ internal class LanguageProcessor(AonprdProcessorInput input) : AbstractProcessor
|
||||
{
|
||||
base.Process();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-5
@@ -26,9 +26,6 @@ internal class TraitProcessor(AonprdProcessorInput input) : AbstractProcessor(in
|
||||
// Необходимо пропускать
|
||||
}
|
||||
|
||||
protected override string GetDescription()
|
||||
=> base.GetDescription() + AddedDescription([
|
||||
"summary_markdown",
|
||||
"search_markdown"
|
||||
]);
|
||||
protected override string GetDescription() =>
|
||||
base.GetDescription() + AddedDescription(["summary_markdown", "search_markdown"]);
|
||||
}
|
||||
|
||||
+17
-8
@@ -22,7 +22,7 @@ internal class AonprdSchemaBuilder(AonprdLoader loader)
|
||||
value = new SchemaNode()
|
||||
{
|
||||
// Resolver = Resolver,
|
||||
Path = key
|
||||
Path = key,
|
||||
};
|
||||
Schemas[key] = value;
|
||||
}
|
||||
@@ -64,7 +64,11 @@ internal class AonprdSchemaBuilder(AonprdLoader loader)
|
||||
protected void SaveSchema(string dir, string name, SchemaNode schema)
|
||||
{
|
||||
char[] invalids = Path.GetInvalidFileNameChars();
|
||||
string fileName = string.Join("_", schema.Path.Split(invalids, StringSplitOptions.RemoveEmptyEntries)).TrimEnd('.');
|
||||
string fileName = string.Join(
|
||||
"_",
|
||||
schema.Path.Split(invalids, StringSplitOptions.RemoveEmptyEntries)
|
||||
)
|
||||
.TrimEnd('.');
|
||||
string path = Path.Combine(dir, fileName + ".yaml");
|
||||
|
||||
string? dirPath = Path.GetDirectoryName(path);
|
||||
@@ -77,10 +81,15 @@ internal class AonprdSchemaBuilder(AonprdLoader loader)
|
||||
|
||||
schema.Beautify();
|
||||
|
||||
writer.WriteLine(SchemaNode.FormatYaml(new Dictionary<string, string>()
|
||||
{
|
||||
["name"] = name,
|
||||
["values"] = schema.Values.ToString()
|
||||
}, schema.Types[0].GetYamlData()));
|
||||
writer.WriteLine(
|
||||
SchemaNode.FormatYaml(
|
||||
new Dictionary<string, string>()
|
||||
{
|
||||
["name"] = name,
|
||||
["values"] = schema.Values.ToString(),
|
||||
},
|
||||
schema.Types[0].GetYamlData()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -13,5 +13,5 @@ internal enum CompendiumDocumentType
|
||||
Macro,
|
||||
Playlist,
|
||||
RollTable,
|
||||
Scene
|
||||
Scene,
|
||||
}
|
||||
|
||||
+2
-1
@@ -60,7 +60,8 @@ internal class CompendiumFolder
|
||||
IsContained = false;
|
||||
}
|
||||
|
||||
Type = (CompendiumDocumentType) Enum.Parse(typeof(CompendiumDocumentType), json["type"]!.ToString());
|
||||
Type = (CompendiumDocumentType)
|
||||
Enum.Parse(typeof(CompendiumDocumentType), json["type"]!.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -38,15 +38,12 @@ internal class CompendiumLoader(Pf2EFoundryImporter importer)
|
||||
{
|
||||
foreach (JToken token in folders)
|
||||
{
|
||||
JObject obj = (JObject) token;
|
||||
JObject obj = (JObject)token;
|
||||
|
||||
string id = $"folder-{_folderCount++}";
|
||||
string name = obj["name"]!.ToString();
|
||||
|
||||
CompendiumFolder folder = new(id, name)
|
||||
{
|
||||
Parent = parent
|
||||
};
|
||||
CompendiumFolder folder = new(id, name) { Parent = parent };
|
||||
Collection.Add(folder);
|
||||
|
||||
if (obj.TryGetValue("packs", out JToken? packs))
|
||||
@@ -65,7 +62,7 @@ internal class CompendiumLoader(Pf2EFoundryImporter importer)
|
||||
|
||||
if (obj.TryGetValue("folders", out JToken? innerFolders))
|
||||
{
|
||||
ProcessPackFolders((JArray) innerFolders!, folder);
|
||||
ProcessPackFolders((JArray)innerFolders!, folder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,14 +79,14 @@ internal class CompendiumLoader(Pf2EFoundryImporter importer)
|
||||
|
||||
foreach (JToken pack in systemData["packs"]!)
|
||||
{
|
||||
CompendiumFolder folder = new((JObject) pack);
|
||||
CompendiumFolder folder = new((JObject)pack);
|
||||
|
||||
Collection.Add(folder);
|
||||
}
|
||||
|
||||
if (systemData.TryGetValue("packFolders", out JToken? packFolders))
|
||||
{
|
||||
ProcessPackFolders((JArray) packFolders, null);
|
||||
ProcessPackFolders((JArray)packFolders, null);
|
||||
}
|
||||
|
||||
// Поиск _folders.json
|
||||
@@ -102,10 +99,15 @@ internal class CompendiumLoader(Pf2EFoundryImporter importer)
|
||||
|
||||
string dirPath = Path.Combine(Importer.Dir, parent.Path);
|
||||
|
||||
ItemCount += Directory.GetFiles(dirPath, "*.json", SearchOption.AllDirectories)
|
||||
.Length;
|
||||
ItemCount += Directory.GetFiles(dirPath, "*.json", SearchOption.AllDirectories).Length;
|
||||
|
||||
foreach (string foldersFilePath in Directory.GetFiles(dirPath, "_folders.json", SearchOption.AllDirectories))
|
||||
foreach (
|
||||
string foldersFilePath in Directory.GetFiles(
|
||||
dirPath,
|
||||
"_folders.json",
|
||||
SearchOption.AllDirectories
|
||||
)
|
||||
)
|
||||
{
|
||||
ItemCount--;
|
||||
using StreamReader file = new(foldersFilePath);
|
||||
@@ -113,7 +115,7 @@ internal class CompendiumLoader(Pf2EFoundryImporter importer)
|
||||
|
||||
foreach (JToken pack in data)
|
||||
{
|
||||
CompendiumFolder folder = new((JObject) pack) { Parent = parent };
|
||||
CompendiumFolder folder = new((JObject)pack) { Parent = parent };
|
||||
Collection.Add(folder);
|
||||
}
|
||||
}
|
||||
@@ -135,7 +137,13 @@ internal class CompendiumLoader(Pf2EFoundryImporter importer)
|
||||
{
|
||||
string dirPath = Path.Combine(Importer.Dir, folder.Path!);
|
||||
|
||||
foreach (string filePath in Directory.GetFiles(dirPath, "*.json", SearchOption.AllDirectories))
|
||||
foreach (
|
||||
string filePath in Directory.GetFiles(
|
||||
dirPath,
|
||||
"*.json",
|
||||
SearchOption.AllDirectories
|
||||
)
|
||||
)
|
||||
{
|
||||
FileInfo file = new(filePath);
|
||||
|
||||
@@ -163,7 +171,8 @@ internal class CompendiumLoader(Pf2EFoundryImporter importer)
|
||||
public FileInfo File { get; } = file;
|
||||
public JObject Json { get; } = itemJson;
|
||||
public CompendiumFolder Folder { get; } = folder;
|
||||
public string Type { get; } = itemJson["type"]?.ToString()
|
||||
public string Type { get; } =
|
||||
itemJson["type"]?.ToString()
|
||||
?? throw new Exception($"Expected to have `type` field in file {file.FullName}");
|
||||
}
|
||||
}
|
||||
|
||||
+13
-12
@@ -1,4 +1,6 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Pf2eModel;
|
||||
using Pf2eModel.Model;
|
||||
using Pf2eModel.Model.Base;
|
||||
@@ -7,8 +9,6 @@ using Pf2eModel.Model.Base.Targets;
|
||||
using Pf2eModel.Model.Common.I18n;
|
||||
using Pf2eModel.Model.Enum;
|
||||
using Pf2eModel.Model.Structure;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace Pf2eDataScrapper.Importers.Implementations.Pf2eFoundry.DataBuilder;
|
||||
|
||||
@@ -39,7 +39,10 @@ internal abstract class AbstractProcessor(ProcessorInput input)
|
||||
Entity.IsChecked = false;
|
||||
|
||||
Entity.Slug = Helper.GenerateSlug(Entity.Name[LocaleType.English]);
|
||||
Entity.Rarity = Input.EnumOptional<EntityRarity>("system.traits.rarity", EntityRarity.Common);
|
||||
Entity.Rarity = Input.EnumOptional<EntityRarity>(
|
||||
"system.traits.rarity",
|
||||
EntityRarity.Common
|
||||
);
|
||||
|
||||
Object.Id = Entity.Id;
|
||||
|
||||
@@ -64,7 +67,7 @@ internal abstract class AbstractProcessor(ProcessorInput input)
|
||||
Source = GetSource(Input.GetRequired<string>("system.publication.title")),
|
||||
|
||||
Suffix = "",
|
||||
IsRemaster = Input.GetRequired<bool>("system.publication.remaster")
|
||||
IsRemaster = Input.GetRequired<bool>("system.publication.remaster"),
|
||||
};
|
||||
Context.EntitySources.Add(source);
|
||||
|
||||
@@ -74,7 +77,7 @@ internal abstract class AbstractProcessor(ProcessorInput input)
|
||||
Entity = Entity,
|
||||
Target = GetTarget(),
|
||||
Suffix = Input.GetRequired<string>("_id"),
|
||||
Md5 = Md5(Input.Input.ToString())
|
||||
Md5 = Md5(Input.Input.ToString()),
|
||||
};
|
||||
Context.EntityExternals.Add(external);
|
||||
|
||||
@@ -97,7 +100,6 @@ internal abstract class AbstractProcessor(ProcessorInput input)
|
||||
Context.SaveChanges();
|
||||
}
|
||||
|
||||
|
||||
protected Source GetSource(string name)
|
||||
{
|
||||
Source? source = Context.Sources.FirstOrDefault(s => s.Name == name);
|
||||
@@ -107,10 +109,7 @@ internal abstract class AbstractProcessor(ProcessorInput input)
|
||||
return source;
|
||||
}
|
||||
|
||||
source = new()
|
||||
{
|
||||
Name = name
|
||||
};
|
||||
source = new() { Name = name };
|
||||
|
||||
Context.Sources.Add(source);
|
||||
return source;
|
||||
@@ -140,7 +139,9 @@ internal abstract class AbstractProcessor(ProcessorInput input)
|
||||
|
||||
protected IEnumerable<Trait> GetTraits(IEnumerable<string> names)
|
||||
{
|
||||
List<Trait> result = Context.Traits.Where(t => names.Contains(t.Entity.ToString())).ToList();
|
||||
List<Trait> result = Context
|
||||
.Traits.Where(t => names.Contains(t.Entity.ToString()))
|
||||
.ToList();
|
||||
|
||||
foreach (string name in names)
|
||||
{
|
||||
|
||||
+9
-4
@@ -1,7 +1,7 @@
|
||||
using Konsole;
|
||||
using System.Reflection;
|
||||
using Konsole;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Pf2eDataScrapper.Importers.Implementations.Pf2eFoundry.Compendium;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Pf2eDataScrapper.Importers.Implementations.Pf2eFoundry.DataBuilder;
|
||||
|
||||
@@ -42,7 +42,9 @@ internal class PF2eFoundryDataBuilder
|
||||
|
||||
public AbstractProcessor? GetProcessor(string type, JObject input)
|
||||
{
|
||||
return Processors.TryGetValue(type, out ConstructorInfo? constructor) ? (AbstractProcessor) constructor.Invoke([new ProcessorInput(input)]) : null;
|
||||
return Processors.TryGetValue(type, out ConstructorInfo? constructor)
|
||||
? (AbstractProcessor)constructor.Invoke([new ProcessorInput(input)])
|
||||
: null;
|
||||
}
|
||||
|
||||
public void TruncateTables()
|
||||
@@ -65,7 +67,10 @@ internal class PF2eFoundryDataBuilder
|
||||
{
|
||||
bar.Refresh(i++, $"{entry.Folder.Name}/{entry.File.Name}");
|
||||
|
||||
AbstractProcessor? processor = GetProcessor($"{entry.Folder.Type}.{entry.Type}", entry.Json);
|
||||
AbstractProcessor? processor = GetProcessor(
|
||||
$"{entry.Folder.Type}.{entry.Type}",
|
||||
entry.Json
|
||||
);
|
||||
if (processor is null)
|
||||
{
|
||||
continue;
|
||||
|
||||
+1
-4
@@ -19,10 +19,7 @@ internal class ActionProcessor(ProcessorInput input) : AbstractProcessor(input)
|
||||
Object.Actions = GetOptional<int>("system.actions.value");
|
||||
Object.DeathNote = GetOptional<bool>("system.deathNote");
|
||||
*/
|
||||
JObject extra = new()
|
||||
{
|
||||
{ "selfEffect", Input.Input.SelectToken("system.selfEffect") }
|
||||
};
|
||||
JObject extra = new() { { "selfEffect", Input.Input.SelectToken("system.selfEffect") } };
|
||||
|
||||
Object.Extra = extra.ToString(Newtonsoft.Json.Formatting.None);
|
||||
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ internal class ConditionProcessor(ProcessorInput input) : AbstractProcessor(inpu
|
||||
{ "duration", Input.Input.SelectToken("system.duration") },
|
||||
{ "overrides", Input.Input.SelectToken("system.overrides") },
|
||||
{ "references", Input.Input.SelectToken("system.references") },
|
||||
{ "value", Input.Input.SelectToken("system.value") }
|
||||
{ "value", Input.Input.SelectToken("system.value") },
|
||||
};
|
||||
|
||||
Object.Extra = extra.ToString(Newtonsoft.Json.Formatting.None);
|
||||
|
||||
@@ -19,7 +19,8 @@ internal class Pf2EFoundryImporter : AbstractImporter
|
||||
/// </summary>
|
||||
public override string Slug => "pf2e";
|
||||
|
||||
public override AbstractImporterRepository Repository => new GitRepository(this, "https://github.com/foundryvtt/pf2e.git");
|
||||
public override AbstractImporterRepository Repository =>
|
||||
new GitRepository(this, "https://github.com/foundryvtt/pf2e.git");
|
||||
|
||||
/// <summary>
|
||||
/// Загрузчик данных компендиума.
|
||||
|
||||
+28
-17
@@ -35,17 +35,23 @@ internal class CompendiumSchemaBuilder(CompendiumLoader loader)
|
||||
/// </summary>
|
||||
public Dictionary<string, SchemaNode> TypeSchemas = [];
|
||||
|
||||
private readonly string[] _equipmentTypes = ["equipment", "armor", "backpack", "consumable", "kit", "shield", "treasure", "weapon"];
|
||||
private readonly string[] _equipmentTypes =
|
||||
[
|
||||
"equipment",
|
||||
"armor",
|
||||
"backpack",
|
||||
"consumable",
|
||||
"kit",
|
||||
"shield",
|
||||
"treasure",
|
||||
"weapon",
|
||||
];
|
||||
|
||||
private SchemaNode GetPackSchema(CompendiumFolder folder)
|
||||
{
|
||||
if (!PackSchemas.TryGetValue(folder, out SchemaNode? value))
|
||||
{
|
||||
value = new SchemaNode()
|
||||
{
|
||||
Resolver = Resolver,
|
||||
Path = folder.Name
|
||||
};
|
||||
value = new SchemaNode() { Resolver = Resolver, Path = folder.Name };
|
||||
PackSchemas[folder] = value;
|
||||
}
|
||||
|
||||
@@ -56,11 +62,7 @@ internal class CompendiumSchemaBuilder(CompendiumLoader loader)
|
||||
{
|
||||
if (!TypeSchemas.TryGetValue(key, out SchemaNode? value))
|
||||
{
|
||||
value = new SchemaNode()
|
||||
{
|
||||
Resolver = Resolver,
|
||||
Path = key
|
||||
};
|
||||
value = new SchemaNode() { Resolver = Resolver, Path = key };
|
||||
TypeSchemas[key] = value;
|
||||
}
|
||||
|
||||
@@ -157,7 +159,11 @@ internal class CompendiumSchemaBuilder(CompendiumLoader loader)
|
||||
protected void SaveSchema(string dir, string name, SchemaNode schema)
|
||||
{
|
||||
char[] invalids = Path.GetInvalidFileNameChars();
|
||||
string fileName = string.Join("_", schema.Path.Split(invalids, StringSplitOptions.RemoveEmptyEntries)).TrimEnd('.');
|
||||
string fileName = string.Join(
|
||||
"_",
|
||||
schema.Path.Split(invalids, StringSplitOptions.RemoveEmptyEntries)
|
||||
)
|
||||
.TrimEnd('.');
|
||||
|
||||
string path = Path.Combine(dir, fileName + ".yaml");
|
||||
|
||||
@@ -172,11 +178,16 @@ internal class CompendiumSchemaBuilder(CompendiumLoader loader)
|
||||
|
||||
schema.Beautify();
|
||||
|
||||
writer.WriteLine(SchemaNode.FormatYaml(new Dictionary<string, string>()
|
||||
{
|
||||
["name"] = name,
|
||||
["values"] = schema.Values.ToString()
|
||||
}, schema.Types[0].GetYamlData()));
|
||||
writer.WriteLine(
|
||||
SchemaNode.FormatYaml(
|
||||
new Dictionary<string, string>()
|
||||
{
|
||||
["name"] = name,
|
||||
["values"] = schema.Values.ToString(),
|
||||
},
|
||||
schema.Types[0].GetYamlData()
|
||||
)
|
||||
);
|
||||
|
||||
//writer.WriteLine(name);
|
||||
//writer.WriteLine($"Different values: {schema.Values}");
|
||||
|
||||
+7
-6
@@ -14,7 +14,8 @@ internal class CompendiumSchemaTypeResolver : TypeResolver
|
||||
}
|
||||
}
|
||||
|
||||
protected readonly List<string> DictionaryPaths = [
|
||||
protected readonly List<string> DictionaryPaths =
|
||||
[
|
||||
"Actor.character.items.[].system.items",
|
||||
"Actor.character.items.[].system.overlays",
|
||||
"Item.ancestry.system.items",
|
||||
@@ -35,8 +36,8 @@ internal class CompendiumSchemaTypeResolver : TypeResolver
|
||||
"Item.spell.system.overlays",
|
||||
"Item.spell.system.overlays.[value].system.damage",
|
||||
"Item.spell.system.overlays.[value].system.heightening",
|
||||
"Item.spell.system.overlays.[value].system.heightening.[value]"
|
||||
];
|
||||
"Item.spell.system.overlays.[value].system.heightening.[value]",
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// Частное определение типа поля.
|
||||
@@ -46,8 +47,8 @@ internal class CompendiumSchemaTypeResolver : TypeResolver
|
||||
/// <returns>Новый тип для схемы данных. `null`, что бы использовать значение по умолчанию</returns>
|
||||
protected override AbstractSchemaType? CustomResolve(SchemaNode node, JToken? value)
|
||||
{
|
||||
return CheckPath(node, DictionaryPaths)
|
||||
? new DictionarySchemaType(node)
|
||||
: node.Path.EndsWith(".rules") ? new FoundryRulesSchemaType(node) : (AbstractSchemaType?) null;
|
||||
return CheckPath(node, DictionaryPaths) ? new DictionarySchemaType(node)
|
||||
: node.Path.EndsWith(".rules") ? new FoundryRulesSchemaType(node)
|
||||
: (AbstractSchemaType?)null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,8 @@ internal class ProcessorInput(JObject input)
|
||||
|
||||
public virtual T GetRequired<T>(string path)
|
||||
{
|
||||
JToken token = Input.SelectToken(path) ?? throw new NullReferenceException($"'{path}' is null");
|
||||
JToken token =
|
||||
Input.SelectToken(path) ?? throw new NullReferenceException($"'{path}' is null");
|
||||
|
||||
return token.ToObject<T>() ?? throw new NullReferenceException($"'{path}' is null");
|
||||
}
|
||||
@@ -18,17 +19,23 @@ internal class ProcessorInput(JObject input)
|
||||
{
|
||||
JToken? token = Input.SelectToken(path) ?? null;
|
||||
|
||||
return (token is null || token.Type == JTokenType.Null) ? default! : token.ToObject<T>() ?? default;
|
||||
return (token is null || token.Type == JTokenType.Null)
|
||||
? default!
|
||||
: token.ToObject<T>() ?? default;
|
||||
}
|
||||
|
||||
public virtual T EnumRequired<T>(string path) where T : Enum
|
||||
public virtual T EnumRequired<T>(string path)
|
||||
where T : Enum
|
||||
{
|
||||
string value = GetOptional<string>(path) ?? throw new NullReferenceException($"Value in path {path} null or not exists");
|
||||
string value =
|
||||
GetOptional<string>(path)
|
||||
?? throw new NullReferenceException($"Value in path {path} null or not exists");
|
||||
|
||||
return Enum<T>(value);
|
||||
}
|
||||
|
||||
public virtual T EnumOptional<T>(string path, T defaultValue) where T : Enum
|
||||
public virtual T EnumOptional<T>(string path, T defaultValue)
|
||||
where T : Enum
|
||||
{
|
||||
string? value = GetOptional<string>(path);
|
||||
|
||||
@@ -47,27 +54,30 @@ internal class ProcessorInput(JObject input)
|
||||
}
|
||||
}
|
||||
|
||||
public virtual T Enum<T>(string value) where T : Enum
|
||||
public virtual T Enum<T>(string value)
|
||||
where T : Enum
|
||||
{
|
||||
foreach (System.Reflection.FieldInfo field in typeof(T).GetFields())
|
||||
{
|
||||
List<string> variants = [field.Name];
|
||||
|
||||
if (Attribute.GetCustomAttribute(field, typeof(PgNameAttribute)) is PgNameAttribute pgAttribute)
|
||||
if (
|
||||
Attribute.GetCustomAttribute(field, typeof(PgNameAttribute))
|
||||
is PgNameAttribute pgAttribute
|
||||
)
|
||||
{
|
||||
variants.Add(pgAttribute.PgName);
|
||||
}
|
||||
|
||||
if (variants.Contains(value))
|
||||
{
|
||||
return (T) field.GetValue(null)!;
|
||||
return (T)field.GetValue(null)!;
|
||||
}
|
||||
}
|
||||
|
||||
throw new InvalidEnumStringException(typeof(T), value);
|
||||
}
|
||||
|
||||
public class InvalidEnumStringException(Type type, string value) : Exception($"Invalid value '{value}' for enum type {type.FullName}.")
|
||||
{
|
||||
}
|
||||
public class InvalidEnumStringException(Type type, string value)
|
||||
: Exception($"Invalid value '{value}' for enum type {type.FullName}.") { }
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@ namespace Pf2eDataScrapper.Importers.Repositories;
|
||||
/// Загрузчик данных из git-репозиториев
|
||||
/// </summary>
|
||||
/// <param name="repositoryDirPath"></param>
|
||||
internal class GitRepository(AbstractImporter importer, string url) : AbstractImporterRepository(importer)
|
||||
internal class GitRepository(AbstractImporter importer, string url)
|
||||
: AbstractImporterRepository(importer)
|
||||
{
|
||||
public readonly string Url = url;
|
||||
|
||||
@@ -27,7 +28,7 @@ internal class GitRepository(AbstractImporter importer, string url) : AbstractIm
|
||||
FileName = "git",
|
||||
WorkingDirectory = gitPath,
|
||||
Arguments = "pull",
|
||||
}
|
||||
},
|
||||
};
|
||||
process.Start();
|
||||
}
|
||||
@@ -41,10 +42,9 @@ internal class GitRepository(AbstractImporter importer, string url) : AbstractIm
|
||||
FileName = "git",
|
||||
WorkingDirectory = RepositoryDirPath,
|
||||
Arguments = $"clone {Url} {Importer.Slug}",
|
||||
}
|
||||
},
|
||||
};
|
||||
process.Start();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<LangVersion>13.0</LangVersion>
|
||||
<LangVersion>13.0</LangVersion>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="dotenv.net" Version="3.2.1" />
|
||||
<PackageReference Include="EFCore.NamingConventions" Version="9.0.0" />
|
||||
@@ -23,11 +21,9 @@
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
|
||||
<PackageReference Include="Slugify.Core" Version="5.1.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Pf2eModel\Pf2eModel.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update=".env">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
@@ -36,9 +32,7 @@
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Importers\Implementations\Aonprd\DataBuilder\Processors\Subclasses\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Npgsql;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Text.RegularExpressions;
|
||||
using Npgsql;
|
||||
|
||||
namespace Pf2eDataScrapper;
|
||||
|
||||
@@ -10,7 +10,6 @@ public partial class Pf2eDatabase
|
||||
public readonly string Username;
|
||||
public readonly string DatabaseName;
|
||||
|
||||
|
||||
private Pf2eDatabase()
|
||||
{
|
||||
Username = UsernamePattern().Match(EnvSettings.DatabaseConnection).Groups[1].Value;
|
||||
@@ -61,9 +60,6 @@ public partial class Pf2eDatabase
|
||||
return new NpgsqlCommand(sql, Connection);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
public void RebuildDatabase()
|
||||
{
|
||||
@@ -95,7 +91,7 @@ public partial class Pf2eDatabase
|
||||
|
||||
string[] permissionCommands = [
|
||||
$"GRANT TEMPORARY, CONNECT ON DATABASE {databaseName} TO PUBLIC;",
|
||||
$"GRANT ALL ON DATABASE {databaseName} TO {username} WITH GRANT OPTION;",
|
||||
$"GRANT ALL ON DATABASE {databaseName} TO {username} WITH GRANT OPTION;",
|
||||
$"GRANT ALL ON DATABASE {databaseName} TO postgres;"
|
||||
];
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ internal class SchemaNode
|
||||
["type"] = GetTypeName(),
|
||||
["path"] = Path,
|
||||
["is_null"] = IsNullable ? "true" : "false",
|
||||
["values"] = Values.ToString()
|
||||
["values"] = Values.ToString(),
|
||||
};
|
||||
|
||||
if (IsSimple)
|
||||
@@ -178,8 +178,6 @@ internal class SchemaNode
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Отступ для строкового представления.
|
||||
/// </summary>
|
||||
@@ -219,7 +217,9 @@ internal class SchemaNode
|
||||
return result.Trim();
|
||||
}
|
||||
|
||||
public static Dictionary<string, string> MergeDictionaries(params List<Dictionary<string, string>> input)
|
||||
public static Dictionary<string, string> MergeDictionaries(
|
||||
params List<Dictionary<string, string>> input
|
||||
)
|
||||
{
|
||||
Dictionary<string, string> result = [];
|
||||
|
||||
|
||||
@@ -24,7 +24,9 @@ internal class TypeResolver
|
||||
string[] pathParts = path.Split('.');
|
||||
string[] nodeParts = node.Path.Split('.');
|
||||
|
||||
return pathParts.Length > nodeParts.Length ? false : !pathParts.Where((t, i) => t != "*" && t != nodeParts[i]).Any();
|
||||
return pathParts.Length > nodeParts.Length
|
||||
? false
|
||||
: !pathParts.Where((t, i) => t != "*" && t != nodeParts[i]).Any();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -45,7 +47,11 @@ internal class TypeResolver
|
||||
/// <returns>Типа значения.</returns>
|
||||
public JTokenType TokenType(JToken? value)
|
||||
{
|
||||
return value is null || value.Type is JTokenType.Null or JTokenType.Undefined or JTokenType.None ? JTokenType.Null : value.Type;
|
||||
return
|
||||
value is null
|
||||
|| value.Type is JTokenType.Null or JTokenType.Undefined or JTokenType.None
|
||||
? JTokenType.Null
|
||||
: value.Type;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -90,7 +96,7 @@ internal class TypeResolver
|
||||
{
|
||||
JTokenType.Array => new ArraySchemaType(node),
|
||||
JTokenType.Object => new ObjectSchemaType(node),
|
||||
_ => new StaticSchemaType(node, type)
|
||||
_ => new StaticSchemaType(node, type),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -61,4 +61,4 @@ internal abstract class AbstractSchemaType(SchemaNode parent)
|
||||
{
|
||||
return SchemaNode.FormatYaml(GetYamlData());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ internal class ArraySchemaType(SchemaNode parent) : AbstractSchemaType(parent)
|
||||
throw new Exception("Value is not an array, did you forget to call IsCompatibleValue?");
|
||||
}
|
||||
|
||||
JArray array = (JArray) value;
|
||||
JArray array = (JArray)value;
|
||||
|
||||
MinCount = Math.Min(MinCount, array.Count);
|
||||
MaxCount = Math.Max(MaxCount, array.Count);
|
||||
@@ -82,7 +82,7 @@ internal class ArraySchemaType(SchemaNode parent) : AbstractSchemaType(parent)
|
||||
{
|
||||
["min_count"] = MinCount.ToString(),
|
||||
["max_count"] = MaxCount.ToString(),
|
||||
["value_type"] = ElementSchema.ToString()
|
||||
["value_type"] = ElementSchema.ToString(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ internal class DictionarySchemaType(SchemaNode parent) : AbstractSchemaType(pare
|
||||
/// <param name="value">Новое значение.</param>
|
||||
public override void AddValue(JToken value)
|
||||
{
|
||||
JObject obj = (JObject) value;
|
||||
JObject obj = (JObject)value;
|
||||
|
||||
foreach (KeyValuePair<string, JToken?> pair in obj)
|
||||
{
|
||||
@@ -70,7 +70,7 @@ internal class DictionarySchemaType(SchemaNode parent) : AbstractSchemaType(pare
|
||||
return new Dictionary<string, string>()
|
||||
{
|
||||
["_key"] = KeyNode.ToString(),
|
||||
["_value"] = ItemNode.ToString()
|
||||
["_value"] = ItemNode.ToString(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,16 +22,12 @@ internal class IgnoreSchemaType(SchemaNode parent) : AbstractSchemaType(parent)
|
||||
/// Добавление нового значения.
|
||||
/// </summary>
|
||||
/// <param name="value">Новое значение.</param>
|
||||
public override void AddValue(JToken value)
|
||||
{
|
||||
}
|
||||
public override void AddValue(JToken value) { }
|
||||
|
||||
/// <summary>
|
||||
/// Подготовка типа к красивому представлению.
|
||||
/// </summary>
|
||||
public override void Beautify()
|
||||
{
|
||||
}
|
||||
public override void Beautify() { }
|
||||
|
||||
/// <summary>
|
||||
/// Получение строкового представоения типа элемента.
|
||||
@@ -42,7 +38,6 @@ internal class IgnoreSchemaType(SchemaNode parent) : AbstractSchemaType(parent)
|
||||
return "ignore";
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Получение данных для форматирования в YAML.
|
||||
/// </summary>
|
||||
|
||||
@@ -29,7 +29,7 @@ internal class ObjectSchemaType(SchemaNode parent) : AbstractSchemaType(parent)
|
||||
/// <param name="value">Новое значение.</param>
|
||||
public override void AddValue(JToken value)
|
||||
{
|
||||
JObject obj = (JObject) value;
|
||||
JObject obj = (JObject)value;
|
||||
|
||||
foreach (SchemaNode field in Fields)
|
||||
{
|
||||
@@ -58,10 +58,14 @@ internal class ObjectSchemaType(SchemaNode parent) : AbstractSchemaType(parent)
|
||||
/// </summary>
|
||||
public override void Beautify()
|
||||
{
|
||||
Fields.Sort((a, b) =>
|
||||
{
|
||||
return a.IsNullable && !b.IsNullable ? 0 : string.Compare(a.Name, b.Name, StringComparison.Ordinal);
|
||||
});
|
||||
Fields.Sort(
|
||||
(a, b) =>
|
||||
{
|
||||
return a.IsNullable && !b.IsNullable
|
||||
? 0
|
||||
: string.Compare(a.Name, b.Name, StringComparison.Ordinal);
|
||||
}
|
||||
);
|
||||
|
||||
foreach (SchemaNode field in Fields)
|
||||
{
|
||||
@@ -102,9 +106,6 @@ internal class ObjectSchemaType(SchemaNode parent) : AbstractSchemaType(parent)
|
||||
/// <returns>Словарь данных</returns>
|
||||
public override Dictionary<string, string> GetYamlData()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
["schema"] = SchemaNode.FormatYaml(GetSchemaYaml())
|
||||
};
|
||||
return new() { ["schema"] = SchemaNode.FormatYaml(GetSchemaYaml()) };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,9 @@ internal class StaticSchemaType(SchemaNode parent, JTokenType type) : AbstractSc
|
||||
Values = newValues;
|
||||
}
|
||||
|
||||
Values = Values.OrderByDescending(pair => pair.Value).ToDictionary(pair => pair.Key, pair => pair.Value);
|
||||
Values = Values
|
||||
.OrderByDescending(pair => pair.Value)
|
||||
.ToDictionary(pair => pair.Key, pair => pair.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -82,7 +84,10 @@ internal class StaticSchemaType(SchemaNode parent, JTokenType type) : AbstractSc
|
||||
|
||||
string prefix = (count == 1) ? "" : "- ";
|
||||
|
||||
if (count is <= SchemaNode.ElementLimit and > 0 && (Type != JTokenType.String || !Values.Any(s => s.ToString().Contains('\n'))))
|
||||
if (
|
||||
count is <= SchemaNode.ElementLimit and > 0
|
||||
&& (Type != JTokenType.String || !Values.Any(s => s.ToString().Contains('\n')))
|
||||
)
|
||||
{
|
||||
foreach (KeyValuePair<JToken, int> kvp in Values)
|
||||
{
|
||||
@@ -92,10 +97,11 @@ internal class StaticSchemaType(SchemaNode parent, JTokenType type) : AbstractSc
|
||||
|
||||
return new()
|
||||
{
|
||||
["different_values"] = count.ToString() +
|
||||
((count == Root.Values) ? " (all different)" : "") +
|
||||
((count == 1) ? " (all same)" : ""),
|
||||
["variants"] = (values.Count > 0) ? string.Join("\r\n", values) : "[omitted]"
|
||||
["different_values"] =
|
||||
count.ToString()
|
||||
+ ((count == Root.Values) ? " (all different)" : "")
|
||||
+ ((count == 1) ? " (all same)" : ""),
|
||||
["variants"] = (values.Count > 0) ? string.Join("\r\n", values) : "[omitted]",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Pf2eModel.Model;
|
||||
using System.Reflection;
|
||||
using Pf2eModel.Model;
|
||||
using Pf2eModel.Model.Base;
|
||||
using Pf2eModel.Model.Enum;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Pf2eModel;
|
||||
|
||||
@@ -21,7 +21,9 @@ public class EntityOfTypeAttribute(EntityType type) : Attribute
|
||||
|
||||
if (!type.IsAssignableTo(typeof(IEntity)))
|
||||
{
|
||||
throw new Exception($"'EntityOfTypeAttribute' attribute should only be applied to children of 'IEntity' class. '{type.FullName}' is not.");
|
||||
throw new Exception(
|
||||
$"'EntityOfTypeAttribute' attribute should only be applied to children of 'IEntity' class. '{type.FullName}' is not."
|
||||
);
|
||||
}
|
||||
|
||||
EntityOfTypeAttribute attribute = type.GetCustomAttribute<EntityOfTypeAttribute>()!;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Pf2eModel.Model.Base.Keywords;
|
||||
using Pf2eModel.Model.Base.Source;
|
||||
using Pf2eModel.Model.Base.Targets;
|
||||
using Pf2eModel.Model.Common.I18n;
|
||||
using Pf2eModel.Model.Enum;
|
||||
using Pf2eModel.Model.Structure;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Pf2eModel.Model.Base;
|
||||
|
||||
|
||||
@@ -17,5 +17,4 @@ public partial class Keyword
|
||||
public virtual ICollection<Entity> Entities { get; set; } = [];
|
||||
|
||||
public virtual ICollection<KeywordAlias> Aliases { get; set; } = [];
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Pf2eModel.Model.Base.Source;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Pf2eModel.Model.Enum;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Pf2eModel.Model.Enum;
|
||||
|
||||
namespace Pf2eModel.Model.Base.Source;
|
||||
|
||||
@@ -21,7 +21,6 @@ public partial class Source
|
||||
[Column(Order = 4)]
|
||||
public DateOnly? ReleaseDate { get; set; }
|
||||
|
||||
|
||||
[Newtonsoft.Json.JsonIgnore]
|
||||
public ICollection<EntitySource> EntitySources { get; set; } = [];
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Pf2eModel.Model.Base.Targets;
|
||||
|
||||
|
||||
@@ -6,5 +6,6 @@ public class LocaleItem(LocaleType type, string value)
|
||||
|
||||
public string Value { get; set; } = value;
|
||||
|
||||
public LocaleItem(KeyValuePair<string, string> item) : this(LocaleExtension.GetTypeByString(item.Key), item.Value) { }
|
||||
public LocaleItem(KeyValuePair<string, string> item)
|
||||
: this(LocaleExtension.GetTypeByString(item.Key), item.Value) { }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Pf2eModel.Model.Enum;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Pf2eModel.Model.Enum;
|
||||
|
||||
namespace Pf2eModel.Model.Common;
|
||||
|
||||
|
||||
@@ -15,10 +15,6 @@ public enum ActionCategory
|
||||
[PgName("class-feat")]
|
||||
ClassFeat,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[PgName("offensive")]
|
||||
Offensive,
|
||||
|
||||
@@ -45,4 +41,4 @@ public enum ActionCategory
|
||||
|
||||
[PgName("kingdom_feature")]
|
||||
KingdomFeature,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,4 +12,4 @@ public enum AncestryVision
|
||||
|
||||
[PgName("dark-vision")]
|
||||
DarkVision,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,5 +23,5 @@ public enum AttributeValues
|
||||
Wisdom,
|
||||
|
||||
[PgName("cha")]
|
||||
Charisma
|
||||
Charisma,
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace Pf2eModel.Model.Enum;
|
||||
|
||||
|
||||
public enum ConditionGroup
|
||||
{
|
||||
[PgName("unknown")]
|
||||
@@ -21,5 +20,5 @@ public enum ConditionGroup
|
||||
Attitudes,
|
||||
|
||||
[PgName("detection")]
|
||||
Detection
|
||||
}
|
||||
Detection,
|
||||
}
|
||||
|
||||
@@ -12,4 +12,4 @@ public enum DeitySanctification
|
||||
|
||||
[PgName("any")]
|
||||
Any,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,5 +14,5 @@ public enum EntityRarity
|
||||
Rare,
|
||||
|
||||
[PgName("unique")]
|
||||
Unique
|
||||
Unique,
|
||||
}
|
||||
|
||||
@@ -47,5 +47,5 @@ public enum EntityType
|
||||
Spell,
|
||||
|
||||
[PgName("language")]
|
||||
Language
|
||||
}
|
||||
Language,
|
||||
}
|
||||
|
||||
@@ -42,4 +42,4 @@ public enum FeatCategory
|
||||
|
||||
[PgName("campaign-feature")]
|
||||
CampaignFeature,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,4 +15,4 @@ public enum Size
|
||||
|
||||
[PgName("large")]
|
||||
Large,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using NpgsqlTypes;
|
||||
|
||||
namespace Pf2eModel.Model.Enum;
|
||||
|
||||
public enum SourceCategory
|
||||
{
|
||||
[PgName("rulebook")]
|
||||
|
||||
@@ -24,4 +24,4 @@ public enum SpellAreaType
|
||||
|
||||
[PgName("cylinder")]
|
||||
Cylinder,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,4 +9,4 @@ public enum SpellDamageCategory
|
||||
|
||||
[PgName("splash")]
|
||||
Splash,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,4 +12,4 @@ public enum SpellDamageKinds
|
||||
|
||||
[PgName("any")]
|
||||
Any,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,4 +21,4 @@ public enum SpellTradition
|
||||
|
||||
[PgName("all")]
|
||||
All,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
namespace Pf2eModel.Model.Enum;
|
||||
|
||||
public enum TrainingStage
|
||||
{
|
||||
Untrained = 0,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using NpgsqlTypes;
|
||||
|
||||
namespace Pf2eModel.Model.Enum;
|
||||
|
||||
public enum TrainingType
|
||||
{
|
||||
[PgName("perception")]
|
||||
|
||||
@@ -11,5 +11,5 @@ public enum TraitType
|
||||
Class,
|
||||
|
||||
[PgName("tradition")]
|
||||
Tradition
|
||||
Tradition,
|
||||
}
|
||||
|
||||
@@ -9,5 +9,4 @@ public interface IEntity
|
||||
|
||||
[JsonIgnore]
|
||||
public Entity Entity { get; set; }
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Pf2eModel.Model.Base;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Pf2eModel.Model.Base;
|
||||
using Pf2eModel.Model.Enum;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Pf2eModel.Model.Structure;
|
||||
|
||||
@@ -30,6 +30,5 @@ public partial class Action : IEntity
|
||||
[Column(Order = 6)]
|
||||
public string? Extra { get; set; }
|
||||
|
||||
|
||||
public Entity Entity { get; set; } = null!;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Pf2eModel.Model.Base;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Pf2eModel.Model.Base;
|
||||
using Pf2eModel.Model.Enum;
|
||||
using Pf2eModel.Model.Structure.AncestryRelation;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Pf2eModel.Model.Structure;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Pf2eModel.Model.Structure.AncestryRelation;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Pf2eModel.Model.Base;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Pf2eModel.Model.Structure.AncestryRelation;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Pf2eModel.Model.Structure.AncestryRelation;
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using Pf2eModel.Model.Base;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Pf2eModel.Model.Base;
|
||||
using Pf2eModel.Model.Enum;
|
||||
using Pf2eModel.Model.Structure.BackgroundRelation;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Pf2eModel.Model.Structure;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Newtonsoft.Json;
|
||||
using Pf2eModel.Model.Enum;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Newtonsoft.Json;
|
||||
using Pf2eModel.Model.Enum;
|
||||
|
||||
namespace Pf2eModel.Model.Structure.BackgroundRelation;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Newtonsoft.Json;
|
||||
using Pf2eModel.Model.Base;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Pf2eModel.Model.Structure.BackgroundRelation;
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Newtonsoft.Json;
|
||||
using Pf2eModel.Model.Common;
|
||||
using Pf2eModel.Model.Enum;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Pf2eModel.Model.Structure.BackgroundRelation;
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using Pf2eModel.Model.Base;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Pf2eModel.Model.Base;
|
||||
using Pf2eModel.Model.Enum;
|
||||
using Pf2eModel.Model.Structure.ClassRelation;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Pf2eModel.Model.Structure;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Newtonsoft.Json;
|
||||
using Pf2eModel.Model.Enum;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Newtonsoft.Json;
|
||||
using Pf2eModel.Model.Enum;
|
||||
|
||||
namespace Pf2eModel.Model.Structure.ClassRelation;
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Newtonsoft.Json;
|
||||
using Pf2eModel.Model.Base;
|
||||
using Pf2eModel.Model.Enum;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Pf2eModel.Model.Structure.ClassRelation;
|
||||
|
||||
public partial class ClassProgression
|
||||
{
|
||||
[Key]
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Newtonsoft.Json;
|
||||
using Pf2eModel.Model.Common;
|
||||
using Pf2eModel.Model.Enum;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Pf2eModel.Model.Structure.ClassRelation;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Pf2eModel.Model.Base;
|
||||
using Pf2eModel.Model.Enum;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Pf2eModel.Model.Base;
|
||||
using Pf2eModel.Model.Enum;
|
||||
|
||||
namespace Pf2eModel.Model.Structure;
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using Pf2eModel.Model.Base;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Pf2eModel.Model.Base;
|
||||
using Pf2eModel.Model.Common;
|
||||
using Pf2eModel.Model.Enum;
|
||||
using Pf2eModel.Model.Structure.DeityRelation;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Pf2eModel.Model.Structure;
|
||||
|
||||
@@ -29,7 +29,8 @@ public partial class Deity : IEntity
|
||||
[Column(Order = 5)]
|
||||
public bool SanctificationMust { get; set; }
|
||||
|
||||
public virtual ICollection<DeityAttribute> DeityAttributes { get; set; } = new List<DeityAttribute>();
|
||||
public virtual ICollection<DeityAttribute> DeityAttributes { get; set; } =
|
||||
new List<DeityAttribute>();
|
||||
|
||||
public virtual ICollection<DeityDomain> DeityDomains { get; set; } = new List<DeityDomain>();
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Pf2eModel.Model.Enum;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Pf2eModel.Model.Structure.DeityRelation;
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using Pf2eModel.Model.Base;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Pf2eModel.Model.Base;
|
||||
using Pf2eModel.Model.Enum;
|
||||
using Pf2eModel.Model.Structure.FeatRelation;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Pf2eModel.Model.Structure;
|
||||
|
||||
@@ -37,7 +37,6 @@ public partial class Feat : IEntity
|
||||
[Column(Order = 9)]
|
||||
public bool IsPassive { get; set; } = false;
|
||||
|
||||
|
||||
[Column(Order = 10)]
|
||||
public string? Extra { get; set; }
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Pf2eModel.Model.Base;
|
||||
using Pf2eModel.Model.Enum;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Pf2eModel.Model.Base;
|
||||
using Pf2eModel.Model.Enum;
|
||||
|
||||
namespace Pf2eModel.Model.Structure;
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using Pf2eModel.Model.Base;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Pf2eModel.Model.Base;
|
||||
using Pf2eModel.Model.Enum;
|
||||
using Pf2eModel.Model.Structure.SpellRelation;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Pf2eModel.Model.Structure;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Pf2eModel.Model.Enum;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Pf2eModel.Model.Enum;
|
||||
|
||||
namespace Pf2eModel.Model.Structure.SpellRelation;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Pf2eModel.Model.Enum;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Pf2eModel.Model.Enum;
|
||||
|
||||
namespace Pf2eModel.Model.Structure.SpellRelation;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Pf2eModel.Model.Base;
|
||||
using Pf2eModel.Model.Enum;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Pf2eModel.Model.Base;
|
||||
using Pf2eModel.Model.Enum;
|
||||
|
||||
namespace Pf2eModel.Model.Structure;
|
||||
|
||||
|
||||
@@ -20,14 +20,10 @@ namespace Pf2eModel;
|
||||
|
||||
public partial class Pf2eDbContext : DbContext
|
||||
{
|
||||
public Pf2eDbContext()
|
||||
{
|
||||
}
|
||||
public Pf2eDbContext() { }
|
||||
|
||||
public Pf2eDbContext(DbContextOptions<Pf2eDbContext> options)
|
||||
: base(options)
|
||||
{
|
||||
}
|
||||
: base(options) { }
|
||||
|
||||
#region DbSets
|
||||
|
||||
@@ -118,7 +114,8 @@ public partial class Pf2eDbContext : DbContext
|
||||
|
||||
// optionsBuilder.LogTo(Console.WriteLine);
|
||||
optionsBuilder.UseSnakeCaseNamingConvention();
|
||||
optionsBuilder.UseNpgsql(databaseCnnection,
|
||||
optionsBuilder.UseNpgsql(
|
||||
databaseCnnection,
|
||||
builder =>
|
||||
{
|
||||
builder
|
||||
@@ -141,10 +138,8 @@ public partial class Pf2eDbContext : DbContext
|
||||
.MapEnum<SpellDamageKinds>()
|
||||
.MapEnum<AttributeValues>()
|
||||
.MapEnum<TrainingStage>()
|
||||
.MapEnum<SourceCategory>()
|
||||
;
|
||||
.MapEnum<SourceCategory>();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+16
-23
@@ -1,43 +1,37 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<GenerateRuntimeConfigurationFiles>True</GenerateRuntimeConfigurationFiles>
|
||||
<GenerateRuntimeConfigurationFiles>True</GenerateRuntimeConfigurationFiles>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="..\Pf2eDataScrapper\.env" Link=".env">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="..\Pf2eDataScrapper\.env" Link=".env">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="dotenv.net" Version="3.2.1" />
|
||||
<PackageReference Include="EFCore.NamingConventions" Version="9.0.0" />
|
||||
<PackageReference Include="linq2db" Version="5.4.1" />
|
||||
<PackageReference Include="linq2db.EntityFrameworkCore" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.4">
|
||||
<!--<PrivateAssets>all</PrivateAssets>-->
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="9.0.4" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Npgsql" Version="9.0.3" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
|
||||
<PackageReference Include="dotenv.net" Version="3.2.1" />
|
||||
<PackageReference Include="EFCore.NamingConventions" Version="9.0.0" />
|
||||
<PackageReference Include="linq2db" Version="5.4.1" />
|
||||
<PackageReference Include="linq2db.EntityFrameworkCore" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.4">
|
||||
<!--<PrivateAssets>all</PrivateAssets>-->
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="9.0.4" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Npgsql" Version="9.0.3" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="RebuildDatabase.bat">
|
||||
<Generator></Generator>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="RebuildDatabase.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
@@ -45,5 +39,4 @@
|
||||
<DependentUpon>RebuildDatabase.bat</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
@@ -7,17 +6,13 @@
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Pf2eModel\Pf2eModel.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Properties\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
@@ -13,4 +13,4 @@ internal static class Program
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new MainViewForm());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user