diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json new file mode 100644 index 0000000..431059b --- /dev/null +++ b/.config/dotnet-tools.json @@ -0,0 +1,13 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "csharpier": { + "version": "1.0.0", + "commands": [ + "csharpier" + ], + "rollForward": false + } + } +} \ No newline at end of file diff --git a/Pf2eDataScrapper/Importers/DatabaseHelper.cs b/Pf2eDataScrapper/Importers/DatabaseHelper.cs index c6a377f..d36220f 100644 --- a/Pf2eDataScrapper/Importers/DatabaseHelper.cs +++ b/Pf2eDataScrapper/Importers/DatabaseHelper.cs @@ -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; - - } diff --git a/Pf2eDataScrapper/Importers/Implementations/Aonprd/AonprdImporter.cs b/Pf2eDataScrapper/Importers/Implementations/Aonprd/AonprdImporter.cs index d0f6be7..03e744b 100644 --- a/Pf2eDataScrapper/Importers/Implementations/Aonprd/AonprdImporter.cs +++ b/Pf2eDataScrapper/Importers/Implementations/Aonprd/AonprdImporter.cs @@ -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; } diff --git a/Pf2eDataScrapper/Importers/Implementations/Aonprd/AonprdLoader.cs b/Pf2eDataScrapper/Importers/Implementations/Aonprd/AonprdLoader.cs index f73f641..e161398 100644 --- a/Pf2eDataScrapper/Importers/Implementations/Aonprd/AonprdLoader.cs +++ b/Pf2eDataScrapper/Importers/Implementations/Aonprd/AonprdLoader.cs @@ -19,7 +19,7 @@ internal class AonprdLoader(AonprdImporter importer) foreach (KeyValuePair 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; diff --git a/Pf2eDataScrapper/Importers/Implementations/Aonprd/AonprdRepository.cs b/Pf2eDataScrapper/Importers/Implementations/Aonprd/AonprdRepository.cs index 112df9a..4d21dd2 100644 --- a/Pf2eDataScrapper/Importers/Implementations/Aonprd/AonprdRepository.cs +++ b/Pf2eDataScrapper/Importers/Implementations/Aonprd/AonprdRepository.cs @@ -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()?.Replace("aon", "") ?? throw new Exception("Can't get revision")); + Revision = Convert.ToInt32( + page.SelectToken("_index")?.ToObject()?.Replace("aon", "") + ?? throw new Exception("Can't get revision") + ); string revisionFile = Path.Combine(RepositoryDirPath, "revision.txt"); if (!File.Exists(revisionFile)) diff --git a/Pf2eDataScrapper/Importers/Implementations/Aonprd/Compendium/AonprdCompendium.cs b/Pf2eDataScrapper/Importers/Implementations/Aonprd/Compendium/AonprdCompendium.cs index 24780dd..86a4624 100644 --- a/Pf2eDataScrapper/Importers/Implementations/Aonprd/Compendium/AonprdCompendium.cs +++ b/Pf2eDataScrapper/Importers/Implementations/Aonprd/Compendium/AonprdCompendium.cs @@ -19,13 +19,10 @@ internal class AonprdCompendium } public int Count() => Types.Values.Sum(t => t.Count); - public int Count(IEnumerable types) => Types.Values - .Where(t => types.Contains(t.Type)) - .Sum(t => t.Count); - public IEnumerable Files(IEnumerable types) => Types.Values - .Where(t => types.Contains(t.Type)) - .SelectMany(t => t.Files) - .Distinct(); + public int Count(IEnumerable types) => + Types.Values.Where(t => types.Contains(t.Type)).Sum(t => t.Count); + public IEnumerable Files(IEnumerable types) => + Types.Values.Where(t => types.Contains(t.Type)).SelectMany(t => t.Files).Distinct(); } diff --git a/Pf2eDataScrapper/Importers/Implementations/Aonprd/Compendium/AonprdReference.cs b/Pf2eDataScrapper/Importers/Implementations/Aonprd/Compendium/AonprdReference.cs index 0558e90..a53290f 100644 --- a/Pf2eDataScrapper/Importers/Implementations/Aonprd/Compendium/AonprdReference.cs +++ b/Pf2eDataScrapper/Importers/Implementations/Aonprd/Compendium/AonprdReference.cs @@ -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]); diff --git a/Pf2eDataScrapper/Importers/Implementations/Aonprd/Compendium/AonprdType.cs b/Pf2eDataScrapper/Importers/Implementations/Aonprd/Compendium/AonprdType.cs index 5a52fb9..527d250 100644 --- a/Pf2eDataScrapper/Importers/Implementations/Aonprd/Compendium/AonprdType.cs +++ b/Pf2eDataScrapper/Importers/Implementations/Aonprd/Compendium/AonprdType.cs @@ -6,7 +6,8 @@ internal class AonprdType(string type) public readonly List Items = []; - public AonprdType(AonprdReference reference) : this(reference.Type) + public AonprdType(AonprdReference reference) + : this(reference.Type) { Items.Add(reference); } diff --git a/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/AonprdDataBuilder.cs b/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/AonprdDataBuilder.cs index bc3e998..eb5e402 100644 --- a/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/AonprdDataBuilder.cs +++ b/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/AonprdDataBuilder.cs @@ -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 { diff --git a/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/AonprdProcessorInput.cs b/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/AonprdProcessorInput.cs index 3ec718b..2e5e3e2 100644 --- a/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/AonprdProcessorInput.cs +++ b/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/AonprdProcessorInput.cs @@ -90,5 +90,4 @@ internal class AonprdProcessorInput(JObject input) : ProcessorInput(input) public bool IsReaction = false; public bool IsFreeAction = false; } - } diff --git a/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/Processors/AonprdProcessorAttribute.cs b/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/Processors/AonprdProcessorAttribute.cs index fd9af3d..4b2c973 100644 --- a/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/Processors/AonprdProcessorAttribute.cs +++ b/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/Processors/AonprdProcessorAttribute.cs @@ -9,13 +9,12 @@ public class AonprdProcessorAttribute(string name, string type, string[] depende public readonly IEnumerable 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"]) { } } diff --git a/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/Processors/AonprdProcessorCollection.cs b/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/Processors/AonprdProcessorCollection.cs index 35c009d..d50c117 100644 --- a/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/Processors/AonprdProcessorCollection.cs +++ b/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/Processors/AonprdProcessorCollection.cs @@ -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 attribute = + type.GetCustomAttribute()!; 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 dependencyPriorities = item.Attribute.Dependencies.Select(d => priorities.TryGetValue(d, out int value) ? value : -1); + IEnumerable 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; } } - - - - } diff --git a/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/Processors/Types/LanguageProcessor.cs b/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/Processors/Types/LanguageProcessor.cs index 7786213..0538f97 100644 --- a/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/Processors/Types/LanguageProcessor.cs +++ b/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/Processors/Types/LanguageProcessor.cs @@ -16,4 +16,4 @@ internal class LanguageProcessor(AonprdProcessorInput input) : AbstractProcessor { base.Process(); } -} \ No newline at end of file +} diff --git a/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/Processors/Types/TraitProcessor.cs b/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/Processors/Types/TraitProcessor.cs index b35da45..e4b2b06 100644 --- a/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/Processors/Types/TraitProcessor.cs +++ b/Pf2eDataScrapper/Importers/Implementations/Aonprd/DataBuilder/Processors/Types/TraitProcessor.cs @@ -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"]); } diff --git a/Pf2eDataScrapper/Importers/Implementations/Aonprd/SchemaBuilder/AonprdSchemaBuilder.cs b/Pf2eDataScrapper/Importers/Implementations/Aonprd/SchemaBuilder/AonprdSchemaBuilder.cs index f06a888..aee9267 100644 --- a/Pf2eDataScrapper/Importers/Implementations/Aonprd/SchemaBuilder/AonprdSchemaBuilder.cs +++ b/Pf2eDataScrapper/Importers/Implementations/Aonprd/SchemaBuilder/AonprdSchemaBuilder.cs @@ -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() - { - ["name"] = name, - ["values"] = schema.Values.ToString() - }, schema.Types[0].GetYamlData())); + writer.WriteLine( + SchemaNode.FormatYaml( + new Dictionary() + { + ["name"] = name, + ["values"] = schema.Values.ToString(), + }, + schema.Types[0].GetYamlData() + ) + ); } -} \ No newline at end of file +} diff --git a/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/Compendium/CompendiumDocumentType.cs b/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/Compendium/CompendiumDocumentType.cs index 3c2e48a..72928df 100644 --- a/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/Compendium/CompendiumDocumentType.cs +++ b/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/Compendium/CompendiumDocumentType.cs @@ -13,5 +13,5 @@ internal enum CompendiumDocumentType Macro, Playlist, RollTable, - Scene + Scene, } diff --git a/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/Compendium/CompendiumFolder.cs b/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/Compendium/CompendiumFolder.cs index 9a6bd91..4cf26bc 100644 --- a/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/Compendium/CompendiumFolder.cs +++ b/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/Compendium/CompendiumFolder.cs @@ -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()); } /// diff --git a/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/CompendiumLoader.cs b/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/CompendiumLoader.cs index 1c7d645..ae02121 100644 --- a/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/CompendiumLoader.cs +++ b/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/CompendiumLoader.cs @@ -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}"); } } diff --git a/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/DataBuilder/AbstractProcessor.cs b/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/DataBuilder/AbstractProcessor.cs index 3225744..2b74479 100644 --- a/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/DataBuilder/AbstractProcessor.cs +++ b/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/DataBuilder/AbstractProcessor.cs @@ -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("system.traits.rarity", EntityRarity.Common); + Entity.Rarity = Input.EnumOptional( + "system.traits.rarity", + EntityRarity.Common + ); Object.Id = Entity.Id; @@ -64,7 +67,7 @@ internal abstract class AbstractProcessor(ProcessorInput input) Source = GetSource(Input.GetRequired("system.publication.title")), Suffix = "", - IsRemaster = Input.GetRequired("system.publication.remaster") + IsRemaster = Input.GetRequired("system.publication.remaster"), }; Context.EntitySources.Add(source); @@ -74,7 +77,7 @@ internal abstract class AbstractProcessor(ProcessorInput input) Entity = Entity, Target = GetTarget(), Suffix = Input.GetRequired("_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 GetTraits(IEnumerable names) { - List result = Context.Traits.Where(t => names.Contains(t.Entity.ToString())).ToList(); + List result = Context + .Traits.Where(t => names.Contains(t.Entity.ToString())) + .ToList(); foreach (string name in names) { diff --git a/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/DataBuilder/PF2eFoundryDataBuilder.cs b/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/DataBuilder/PF2eFoundryDataBuilder.cs index 756cd9e..0249020 100644 --- a/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/DataBuilder/PF2eFoundryDataBuilder.cs +++ b/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/DataBuilder/PF2eFoundryDataBuilder.cs @@ -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; diff --git a/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/DataBuilder/Processors/ActionProcessor.cs b/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/DataBuilder/Processors/ActionProcessor.cs index d406427..b17f9b2 100644 --- a/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/DataBuilder/Processors/ActionProcessor.cs +++ b/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/DataBuilder/Processors/ActionProcessor.cs @@ -19,10 +19,7 @@ internal class ActionProcessor(ProcessorInput input) : AbstractProcessor(input) Object.Actions = GetOptional("system.actions.value"); Object.DeathNote = GetOptional("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); diff --git a/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/DataBuilder/Processors/ConditionProcessor.cs b/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/DataBuilder/Processors/ConditionProcessor.cs index fba77e1..ab74cd4 100644 --- a/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/DataBuilder/Processors/ConditionProcessor.cs +++ b/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/DataBuilder/Processors/ConditionProcessor.cs @@ -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); diff --git a/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/Pf2eFoundryImporter.cs b/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/Pf2eFoundryImporter.cs index 9baf816..b98dd8b 100644 --- a/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/Pf2eFoundryImporter.cs +++ b/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/Pf2eFoundryImporter.cs @@ -19,7 +19,8 @@ internal class Pf2EFoundryImporter : AbstractImporter /// 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"); /// /// Загрузчик данных компендиума. diff --git a/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/SchemaBuilder/CompendiumSchemaBuilder.cs b/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/SchemaBuilder/CompendiumSchemaBuilder.cs index 906ba91..01392f8 100644 --- a/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/SchemaBuilder/CompendiumSchemaBuilder.cs +++ b/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/SchemaBuilder/CompendiumSchemaBuilder.cs @@ -35,17 +35,23 @@ internal class CompendiumSchemaBuilder(CompendiumLoader loader) /// public Dictionary 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() - { - ["name"] = name, - ["values"] = schema.Values.ToString() - }, schema.Types[0].GetYamlData())); + writer.WriteLine( + SchemaNode.FormatYaml( + new Dictionary() + { + ["name"] = name, + ["values"] = schema.Values.ToString(), + }, + schema.Types[0].GetYamlData() + ) + ); //writer.WriteLine(name); //writer.WriteLine($"Different values: {schema.Values}"); diff --git a/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/SchemaBuilder/CompendiumSchemaTypeResolver.cs b/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/SchemaBuilder/CompendiumSchemaTypeResolver.cs index 370b5eb..b77f11b 100644 --- a/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/SchemaBuilder/CompendiumSchemaTypeResolver.cs +++ b/Pf2eDataScrapper/Importers/Implementations/Pf2eFoundry/SchemaBuilder/CompendiumSchemaTypeResolver.cs @@ -14,7 +14,8 @@ internal class CompendiumSchemaTypeResolver : TypeResolver } } - protected readonly List DictionaryPaths = [ + protected readonly List 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]", + ]; /// /// Частное определение типа поля. @@ -46,8 +47,8 @@ internal class CompendiumSchemaTypeResolver : TypeResolver /// Новый тип для схемы данных. `null`, что бы использовать значение по умолчанию 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; } } diff --git a/Pf2eDataScrapper/Importers/ProcessorInput.cs b/Pf2eDataScrapper/Importers/ProcessorInput.cs index 5e8c9a3..827797e 100644 --- a/Pf2eDataScrapper/Importers/ProcessorInput.cs +++ b/Pf2eDataScrapper/Importers/ProcessorInput.cs @@ -9,7 +9,8 @@ internal class ProcessorInput(JObject input) public virtual T GetRequired(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() ?? 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() ?? default; + return (token is null || token.Type == JTokenType.Null) + ? default! + : token.ToObject() ?? default; } - public virtual T EnumRequired(string path) where T : Enum + public virtual T EnumRequired(string path) + where T : Enum { - string value = GetOptional(path) ?? throw new NullReferenceException($"Value in path {path} null or not exists"); + string value = + GetOptional(path) + ?? throw new NullReferenceException($"Value in path {path} null or not exists"); return Enum(value); } - public virtual T EnumOptional(string path, T defaultValue) where T : Enum + public virtual T EnumOptional(string path, T defaultValue) + where T : Enum { string? value = GetOptional(path); @@ -47,27 +54,30 @@ internal class ProcessorInput(JObject input) } } - public virtual T Enum(string value) where T : Enum + public virtual T Enum(string value) + where T : Enum { foreach (System.Reflection.FieldInfo field in typeof(T).GetFields()) { List 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}.") { } } diff --git a/Pf2eDataScrapper/Importers/Repositories/GitRepository.cs b/Pf2eDataScrapper/Importers/Repositories/GitRepository.cs index a7019a4..39ae89b 100644 --- a/Pf2eDataScrapper/Importers/Repositories/GitRepository.cs +++ b/Pf2eDataScrapper/Importers/Repositories/GitRepository.cs @@ -6,7 +6,8 @@ namespace Pf2eDataScrapper.Importers.Repositories; /// Загрузчик данных из git-репозиториев /// /// -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(); - } } } diff --git a/Pf2eDataScrapper/Pf2eDataScrapper.csproj b/Pf2eDataScrapper/Pf2eDataScrapper.csproj index fb0c769..dc784c7 100644 --- a/Pf2eDataScrapper/Pf2eDataScrapper.csproj +++ b/Pf2eDataScrapper/Pf2eDataScrapper.csproj @@ -1,13 +1,11 @@  - - 13.0 + 13.0 Exe net8.0 enable enable - @@ -23,11 +21,9 @@ - - Always @@ -36,9 +32,7 @@ Always - - diff --git a/Pf2eDataScrapper/Pf2eDatabase.cs b/Pf2eDataScrapper/Pf2eDatabase.cs index cc3ddad..e819070 100644 --- a/Pf2eDataScrapper/Pf2eDatabase.cs +++ b/Pf2eDataScrapper/Pf2eDatabase.cs @@ -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;" ]; diff --git a/Pf2eDataScrapper/SchemaBuilder/SchemaNode.cs b/Pf2eDataScrapper/SchemaBuilder/SchemaNode.cs index 098f985..25856a9 100644 --- a/Pf2eDataScrapper/SchemaBuilder/SchemaNode.cs +++ b/Pf2eDataScrapper/SchemaBuilder/SchemaNode.cs @@ -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 } } - - /// /// Отступ для строкового представления. /// @@ -219,7 +217,9 @@ internal class SchemaNode return result.Trim(); } - public static Dictionary MergeDictionaries(params List> input) + public static Dictionary MergeDictionaries( + params List> input + ) { Dictionary result = []; diff --git a/Pf2eDataScrapper/SchemaBuilder/TypeResolver.cs b/Pf2eDataScrapper/SchemaBuilder/TypeResolver.cs index 7b3b1e9..d4709fd 100644 --- a/Pf2eDataScrapper/SchemaBuilder/TypeResolver.cs +++ b/Pf2eDataScrapper/SchemaBuilder/TypeResolver.cs @@ -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(); } /// @@ -45,7 +47,11 @@ internal class TypeResolver /// Типа значения. 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; } /// @@ -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), }; } diff --git a/Pf2eDataScrapper/SchemaBuilder/Types/AbstractSchemaType.cs b/Pf2eDataScrapper/SchemaBuilder/Types/AbstractSchemaType.cs index 670c63f..ae55f5f 100644 --- a/Pf2eDataScrapper/SchemaBuilder/Types/AbstractSchemaType.cs +++ b/Pf2eDataScrapper/SchemaBuilder/Types/AbstractSchemaType.cs @@ -61,4 +61,4 @@ internal abstract class AbstractSchemaType(SchemaNode parent) { return SchemaNode.FormatYaml(GetYamlData()); } -} \ No newline at end of file +} diff --git a/Pf2eDataScrapper/SchemaBuilder/Types/ArraySchemaType.cs b/Pf2eDataScrapper/SchemaBuilder/Types/ArraySchemaType.cs index 1383c5a..f01cd12 100644 --- a/Pf2eDataScrapper/SchemaBuilder/Types/ArraySchemaType.cs +++ b/Pf2eDataScrapper/SchemaBuilder/Types/ArraySchemaType.cs @@ -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(), }; } } diff --git a/Pf2eDataScrapper/SchemaBuilder/Types/DictionarySchemaType.cs b/Pf2eDataScrapper/SchemaBuilder/Types/DictionarySchemaType.cs index ac3d0a5..fe471f5 100644 --- a/Pf2eDataScrapper/SchemaBuilder/Types/DictionarySchemaType.cs +++ b/Pf2eDataScrapper/SchemaBuilder/Types/DictionarySchemaType.cs @@ -34,7 +34,7 @@ internal class DictionarySchemaType(SchemaNode parent) : AbstractSchemaType(pare /// Новое значение. public override void AddValue(JToken value) { - JObject obj = (JObject) value; + JObject obj = (JObject)value; foreach (KeyValuePair pair in obj) { @@ -70,7 +70,7 @@ internal class DictionarySchemaType(SchemaNode parent) : AbstractSchemaType(pare return new Dictionary() { ["_key"] = KeyNode.ToString(), - ["_value"] = ItemNode.ToString() + ["_value"] = ItemNode.ToString(), }; } } diff --git a/Pf2eDataScrapper/SchemaBuilder/Types/IgnoreSchemaType.cs b/Pf2eDataScrapper/SchemaBuilder/Types/IgnoreSchemaType.cs index c007c53..698fed7 100644 --- a/Pf2eDataScrapper/SchemaBuilder/Types/IgnoreSchemaType.cs +++ b/Pf2eDataScrapper/SchemaBuilder/Types/IgnoreSchemaType.cs @@ -22,16 +22,12 @@ internal class IgnoreSchemaType(SchemaNode parent) : AbstractSchemaType(parent) /// Добавление нового значения. /// /// Новое значение. - public override void AddValue(JToken value) - { - } + public override void AddValue(JToken value) { } /// /// Подготовка типа к красивому представлению. /// - public override void Beautify() - { - } + public override void Beautify() { } /// /// Получение строкового представоения типа элемента. @@ -42,7 +38,6 @@ internal class IgnoreSchemaType(SchemaNode parent) : AbstractSchemaType(parent) return "ignore"; } - /// /// Получение данных для форматирования в YAML. /// diff --git a/Pf2eDataScrapper/SchemaBuilder/Types/ObjectSchemaType.cs b/Pf2eDataScrapper/SchemaBuilder/Types/ObjectSchemaType.cs index 31db02e..8abba41 100644 --- a/Pf2eDataScrapper/SchemaBuilder/Types/ObjectSchemaType.cs +++ b/Pf2eDataScrapper/SchemaBuilder/Types/ObjectSchemaType.cs @@ -29,7 +29,7 @@ internal class ObjectSchemaType(SchemaNode parent) : AbstractSchemaType(parent) /// Новое значение. 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) /// 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) /// Словарь данных public override Dictionary GetYamlData() { - return new() - { - ["schema"] = SchemaNode.FormatYaml(GetSchemaYaml()) - }; + return new() { ["schema"] = SchemaNode.FormatYaml(GetSchemaYaml()) }; } } diff --git a/Pf2eDataScrapper/SchemaBuilder/Types/StaticSchemaType.cs b/Pf2eDataScrapper/SchemaBuilder/Types/StaticSchemaType.cs index 67b870c..6626713 100644 --- a/Pf2eDataScrapper/SchemaBuilder/Types/StaticSchemaType.cs +++ b/Pf2eDataScrapper/SchemaBuilder/Types/StaticSchemaType.cs @@ -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); } /// @@ -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 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]", }; } } diff --git a/Pf2eModel/EntityOfTypeAttribute.cs b/Pf2eModel/EntityOfTypeAttribute.cs index 764c068..6a41600 100644 --- a/Pf2eModel/EntityOfTypeAttribute.cs +++ b/Pf2eModel/EntityOfTypeAttribute.cs @@ -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()!; diff --git a/Pf2eModel/Model/Base/Entity.cs b/Pf2eModel/Model/Base/Entity.cs index 5715fad..693b96e 100644 --- a/Pf2eModel/Model/Base/Entity.cs +++ b/Pf2eModel/Model/Base/Entity.cs @@ -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; diff --git a/Pf2eModel/Model/Base/Keywords/Keyword.cs b/Pf2eModel/Model/Base/Keywords/Keyword.cs index 0b75901..d6a909d 100644 --- a/Pf2eModel/Model/Base/Keywords/Keyword.cs +++ b/Pf2eModel/Model/Base/Keywords/Keyword.cs @@ -17,5 +17,4 @@ public partial class Keyword public virtual ICollection Entities { get; set; } = []; public virtual ICollection Aliases { get; set; } = []; - } diff --git a/Pf2eModel/Model/Base/Source/EntitySource.cs b/Pf2eModel/Model/Base/Source/EntitySource.cs index aca54c0..a0cb13f 100644 --- a/Pf2eModel/Model/Base/Source/EntitySource.cs +++ b/Pf2eModel/Model/Base/Source/EntitySource.cs @@ -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; diff --git a/Pf2eModel/Model/Base/Source/Source.cs b/Pf2eModel/Model/Base/Source/Source.cs index 749d269..4483873 100644 --- a/Pf2eModel/Model/Base/Source/Source.cs +++ b/Pf2eModel/Model/Base/Source/Source.cs @@ -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 EntitySources { get; set; } = []; } diff --git a/Pf2eModel/Model/Base/Targets/EntityExternal.cs b/Pf2eModel/Model/Base/Targets/EntityExternal.cs index ef66b95..75abe92 100644 --- a/Pf2eModel/Model/Base/Targets/EntityExternal.cs +++ b/Pf2eModel/Model/Base/Targets/EntityExternal.cs @@ -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; diff --git a/Pf2eModel/Model/Common/I18n/LocaleItem.cs b/Pf2eModel/Model/Common/I18n/LocaleItem.cs index 1ba7ea1..62fd22a 100644 --- a/Pf2eModel/Model/Common/I18n/LocaleItem.cs +++ b/Pf2eModel/Model/Common/I18n/LocaleItem.cs @@ -6,5 +6,6 @@ public class LocaleItem(LocaleType type, string value) public string Value { get; set; } = value; - public LocaleItem(KeyValuePair item) : this(LocaleExtension.GetTypeByString(item.Key), item.Value) { } + public LocaleItem(KeyValuePair item) + : this(LocaleExtension.GetTypeByString(item.Key), item.Value) { } } diff --git a/Pf2eModel/Model/Common/Training.cs b/Pf2eModel/Model/Common/Training.cs index e80e640..a6118fd 100644 --- a/Pf2eModel/Model/Common/Training.cs +++ b/Pf2eModel/Model/Common/Training.cs @@ -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; diff --git a/Pf2eModel/Model/Enum/ActionCategory.cs b/Pf2eModel/Model/Enum/ActionCategory.cs index e80f946..c2546f6 100644 --- a/Pf2eModel/Model/Enum/ActionCategory.cs +++ b/Pf2eModel/Model/Enum/ActionCategory.cs @@ -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, -} \ No newline at end of file +} diff --git a/Pf2eModel/Model/Enum/AncestryVision.cs b/Pf2eModel/Model/Enum/AncestryVision.cs index fdc4124..dee7ab4 100644 --- a/Pf2eModel/Model/Enum/AncestryVision.cs +++ b/Pf2eModel/Model/Enum/AncestryVision.cs @@ -12,4 +12,4 @@ public enum AncestryVision [PgName("dark-vision")] DarkVision, -} \ No newline at end of file +} diff --git a/Pf2eModel/Model/Enum/AttributeValues.cs b/Pf2eModel/Model/Enum/AttributeValues.cs index 2c818c7..955abc7 100644 --- a/Pf2eModel/Model/Enum/AttributeValues.cs +++ b/Pf2eModel/Model/Enum/AttributeValues.cs @@ -23,5 +23,5 @@ public enum AttributeValues Wisdom, [PgName("cha")] - Charisma + Charisma, } diff --git a/Pf2eModel/Model/Enum/ConditionGroup.cs b/Pf2eModel/Model/Enum/ConditionGroup.cs index 7311fed..f9cdf1a 100644 --- a/Pf2eModel/Model/Enum/ConditionGroup.cs +++ b/Pf2eModel/Model/Enum/ConditionGroup.cs @@ -2,7 +2,6 @@ namespace Pf2eModel.Model.Enum; - public enum ConditionGroup { [PgName("unknown")] @@ -21,5 +20,5 @@ public enum ConditionGroup Attitudes, [PgName("detection")] - Detection -} \ No newline at end of file + Detection, +} diff --git a/Pf2eModel/Model/Enum/DeitySanctification.cs b/Pf2eModel/Model/Enum/DeitySanctification.cs index bf105bd..bda639d 100644 --- a/Pf2eModel/Model/Enum/DeitySanctification.cs +++ b/Pf2eModel/Model/Enum/DeitySanctification.cs @@ -12,4 +12,4 @@ public enum DeitySanctification [PgName("any")] Any, -} \ No newline at end of file +} diff --git a/Pf2eModel/Model/Enum/EntityRarity.cs b/Pf2eModel/Model/Enum/EntityRarity.cs index 91384ca..c23958e 100644 --- a/Pf2eModel/Model/Enum/EntityRarity.cs +++ b/Pf2eModel/Model/Enum/EntityRarity.cs @@ -14,5 +14,5 @@ public enum EntityRarity Rare, [PgName("unique")] - Unique + Unique, } diff --git a/Pf2eModel/Model/Enum/EntityType.cs b/Pf2eModel/Model/Enum/EntityType.cs index 9d0311a..2a5b1bf 100644 --- a/Pf2eModel/Model/Enum/EntityType.cs +++ b/Pf2eModel/Model/Enum/EntityType.cs @@ -47,5 +47,5 @@ public enum EntityType Spell, [PgName("language")] - Language -} \ No newline at end of file + Language, +} diff --git a/Pf2eModel/Model/Enum/FeatCategory.cs b/Pf2eModel/Model/Enum/FeatCategory.cs index eea9e0b..aa9b183 100644 --- a/Pf2eModel/Model/Enum/FeatCategory.cs +++ b/Pf2eModel/Model/Enum/FeatCategory.cs @@ -42,4 +42,4 @@ public enum FeatCategory [PgName("campaign-feature")] CampaignFeature, -} \ No newline at end of file +} diff --git a/Pf2eModel/Model/Enum/Size.cs b/Pf2eModel/Model/Enum/Size.cs index 785e65a..0fc40fc 100644 --- a/Pf2eModel/Model/Enum/Size.cs +++ b/Pf2eModel/Model/Enum/Size.cs @@ -15,4 +15,4 @@ public enum Size [PgName("large")] Large, -} \ No newline at end of file +} diff --git a/Pf2eModel/Model/Enum/SourceCategory.cs b/Pf2eModel/Model/Enum/SourceCategory.cs index ac858ff..c4d140f 100644 --- a/Pf2eModel/Model/Enum/SourceCategory.cs +++ b/Pf2eModel/Model/Enum/SourceCategory.cs @@ -1,6 +1,7 @@ using NpgsqlTypes; namespace Pf2eModel.Model.Enum; + public enum SourceCategory { [PgName("rulebook")] diff --git a/Pf2eModel/Model/Enum/SpellAreaType.cs b/Pf2eModel/Model/Enum/SpellAreaType.cs index e6d9150..f01b2aa 100644 --- a/Pf2eModel/Model/Enum/SpellAreaType.cs +++ b/Pf2eModel/Model/Enum/SpellAreaType.cs @@ -24,4 +24,4 @@ public enum SpellAreaType [PgName("cylinder")] Cylinder, -} \ No newline at end of file +} diff --git a/Pf2eModel/Model/Enum/SpellDamageCategory.cs b/Pf2eModel/Model/Enum/SpellDamageCategory.cs index 45b02b9..24e9775 100644 --- a/Pf2eModel/Model/Enum/SpellDamageCategory.cs +++ b/Pf2eModel/Model/Enum/SpellDamageCategory.cs @@ -9,4 +9,4 @@ public enum SpellDamageCategory [PgName("splash")] Splash, -} \ No newline at end of file +} diff --git a/Pf2eModel/Model/Enum/SpellDamageKinds.cs b/Pf2eModel/Model/Enum/SpellDamageKinds.cs index 237bc23..b2ab3d5 100644 --- a/Pf2eModel/Model/Enum/SpellDamageKinds.cs +++ b/Pf2eModel/Model/Enum/SpellDamageKinds.cs @@ -12,4 +12,4 @@ public enum SpellDamageKinds [PgName("any")] Any, -} \ No newline at end of file +} diff --git a/Pf2eModel/Model/Enum/SpellTradition.cs b/Pf2eModel/Model/Enum/SpellTradition.cs index b9082f2..223c047 100644 --- a/Pf2eModel/Model/Enum/SpellTradition.cs +++ b/Pf2eModel/Model/Enum/SpellTradition.cs @@ -21,4 +21,4 @@ public enum SpellTradition [PgName("all")] All, -} \ No newline at end of file +} diff --git a/Pf2eModel/Model/Enum/TrainingStage.cs b/Pf2eModel/Model/Enum/TrainingStage.cs index dc40271..4af94bf 100644 --- a/Pf2eModel/Model/Enum/TrainingStage.cs +++ b/Pf2eModel/Model/Enum/TrainingStage.cs @@ -1,4 +1,5 @@ namespace Pf2eModel.Model.Enum; + public enum TrainingStage { Untrained = 0, diff --git a/Pf2eModel/Model/Enum/TrainingType.cs b/Pf2eModel/Model/Enum/TrainingType.cs index 5aa18b1..3e715e8 100644 --- a/Pf2eModel/Model/Enum/TrainingType.cs +++ b/Pf2eModel/Model/Enum/TrainingType.cs @@ -1,6 +1,7 @@ using NpgsqlTypes; namespace Pf2eModel.Model.Enum; + public enum TrainingType { [PgName("perception")] diff --git a/Pf2eModel/Model/Enum/TraitType.cs b/Pf2eModel/Model/Enum/TraitType.cs index fc9432d..b75f9d7 100644 --- a/Pf2eModel/Model/Enum/TraitType.cs +++ b/Pf2eModel/Model/Enum/TraitType.cs @@ -11,5 +11,5 @@ public enum TraitType Class, [PgName("tradition")] - Tradition + Tradition, } diff --git a/Pf2eModel/Model/IEntity.cs b/Pf2eModel/Model/IEntity.cs index ff4b33e..3b36e6d 100644 --- a/Pf2eModel/Model/IEntity.cs +++ b/Pf2eModel/Model/IEntity.cs @@ -9,5 +9,4 @@ public interface IEntity [JsonIgnore] public Entity Entity { get; set; } - } diff --git a/Pf2eModel/Model/Structure/Action.cs b/Pf2eModel/Model/Structure/Action.cs index 913e3a3..29e0888 100644 --- a/Pf2eModel/Model/Structure/Action.cs +++ b/Pf2eModel/Model/Structure/Action.cs @@ -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!; } diff --git a/Pf2eModel/Model/Structure/Ancestry.cs b/Pf2eModel/Model/Structure/Ancestry.cs index 310e079..2920c53 100644 --- a/Pf2eModel/Model/Structure/Ancestry.cs +++ b/Pf2eModel/Model/Structure/Ancestry.cs @@ -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; diff --git a/Pf2eModel/Model/Structure/AncestryRelation/AncestryBoost.cs b/Pf2eModel/Model/Structure/AncestryRelation/AncestryBoost.cs index 78f55d8..e053305 100644 --- a/Pf2eModel/Model/Structure/AncestryRelation/AncestryBoost.cs +++ b/Pf2eModel/Model/Structure/AncestryRelation/AncestryBoost.cs @@ -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; diff --git a/Pf2eModel/Model/Structure/AncestryRelation/AncestryItem.cs b/Pf2eModel/Model/Structure/AncestryRelation/AncestryItem.cs index 1f456cc..0272b5c 100644 --- a/Pf2eModel/Model/Structure/AncestryRelation/AncestryItem.cs +++ b/Pf2eModel/Model/Structure/AncestryRelation/AncestryItem.cs @@ -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; diff --git a/Pf2eModel/Model/Structure/AncestryRelation/AncestryLanguage.cs b/Pf2eModel/Model/Structure/AncestryRelation/AncestryLanguage.cs index ed34d82..17c6c9c 100644 --- a/Pf2eModel/Model/Structure/AncestryRelation/AncestryLanguage.cs +++ b/Pf2eModel/Model/Structure/AncestryRelation/AncestryLanguage.cs @@ -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; diff --git a/Pf2eModel/Model/Structure/Background.cs b/Pf2eModel/Model/Structure/Background.cs index bc3dc25..ff88912 100644 --- a/Pf2eModel/Model/Structure/Background.cs +++ b/Pf2eModel/Model/Structure/Background.cs @@ -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; diff --git a/Pf2eModel/Model/Structure/BackgroundRelation/BackgroundBoost.cs b/Pf2eModel/Model/Structure/BackgroundRelation/BackgroundBoost.cs index 7e74e1e..6f5c90b 100644 --- a/Pf2eModel/Model/Structure/BackgroundRelation/BackgroundBoost.cs +++ b/Pf2eModel/Model/Structure/BackgroundRelation/BackgroundBoost.cs @@ -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; diff --git a/Pf2eModel/Model/Structure/BackgroundRelation/BackgroundItem.cs b/Pf2eModel/Model/Structure/BackgroundRelation/BackgroundItem.cs index ea914a5..e4ec5db 100644 --- a/Pf2eModel/Model/Structure/BackgroundRelation/BackgroundItem.cs +++ b/Pf2eModel/Model/Structure/BackgroundRelation/BackgroundItem.cs @@ -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; diff --git a/Pf2eModel/Model/Structure/BackgroundRelation/BackgroundTraining.cs b/Pf2eModel/Model/Structure/BackgroundRelation/BackgroundTraining.cs index f7d8388..1983676 100644 --- a/Pf2eModel/Model/Structure/BackgroundRelation/BackgroundTraining.cs +++ b/Pf2eModel/Model/Structure/BackgroundRelation/BackgroundTraining.cs @@ -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; diff --git a/Pf2eModel/Model/Structure/Class.cs b/Pf2eModel/Model/Structure/Class.cs index 66776aa..3adc028 100644 --- a/Pf2eModel/Model/Structure/Class.cs +++ b/Pf2eModel/Model/Structure/Class.cs @@ -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; diff --git a/Pf2eModel/Model/Structure/ClassRelation/ClassKeyAbility.cs b/Pf2eModel/Model/Structure/ClassRelation/ClassKeyAbility.cs index a2529c6..a2920dc 100644 --- a/Pf2eModel/Model/Structure/ClassRelation/ClassKeyAbility.cs +++ b/Pf2eModel/Model/Structure/ClassRelation/ClassKeyAbility.cs @@ -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; diff --git a/Pf2eModel/Model/Structure/ClassRelation/ClassProgression.cs b/Pf2eModel/Model/Structure/ClassRelation/ClassProgression.cs index 1d8b3ac..6c8f26e 100644 --- a/Pf2eModel/Model/Structure/ClassRelation/ClassProgression.cs +++ b/Pf2eModel/Model/Structure/ClassRelation/ClassProgression.cs @@ -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] diff --git a/Pf2eModel/Model/Structure/ClassRelation/ClassTraining.cs b/Pf2eModel/Model/Structure/ClassRelation/ClassTraining.cs index 18541fb..83f23c4 100644 --- a/Pf2eModel/Model/Structure/ClassRelation/ClassTraining.cs +++ b/Pf2eModel/Model/Structure/ClassRelation/ClassTraining.cs @@ -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; diff --git a/Pf2eModel/Model/Structure/Condition.cs b/Pf2eModel/Model/Structure/Condition.cs index a67f1b5..934c4d0 100644 --- a/Pf2eModel/Model/Structure/Condition.cs +++ b/Pf2eModel/Model/Structure/Condition.cs @@ -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; diff --git a/Pf2eModel/Model/Structure/Deity.cs b/Pf2eModel/Model/Structure/Deity.cs index b4fd3e3..f87f653 100644 --- a/Pf2eModel/Model/Structure/Deity.cs +++ b/Pf2eModel/Model/Structure/Deity.cs @@ -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 DeityAttributes { get; set; } = new List(); + public virtual ICollection DeityAttributes { get; set; } = + new List(); public virtual ICollection DeityDomains { get; set; } = new List(); diff --git a/Pf2eModel/Model/Structure/DeityRelation/DeityAttribute.cs b/Pf2eModel/Model/Structure/DeityRelation/DeityAttribute.cs index 616c653..f8d4420 100644 --- a/Pf2eModel/Model/Structure/DeityRelation/DeityAttribute.cs +++ b/Pf2eModel/Model/Structure/DeityRelation/DeityAttribute.cs @@ -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; diff --git a/Pf2eModel/Model/Structure/Feat.cs b/Pf2eModel/Model/Structure/Feat.cs index 043fe92..3e952ce 100644 --- a/Pf2eModel/Model/Structure/Feat.cs +++ b/Pf2eModel/Model/Structure/Feat.cs @@ -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; } diff --git a/Pf2eModel/Model/Structure/Heritage.cs b/Pf2eModel/Model/Structure/Heritage.cs index 38ab84a..b7e367d 100644 --- a/Pf2eModel/Model/Structure/Heritage.cs +++ b/Pf2eModel/Model/Structure/Heritage.cs @@ -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; diff --git a/Pf2eModel/Model/Structure/Spell.cs b/Pf2eModel/Model/Structure/Spell.cs index 10b065f..37a8dea 100644 --- a/Pf2eModel/Model/Structure/Spell.cs +++ b/Pf2eModel/Model/Structure/Spell.cs @@ -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; diff --git a/Pf2eModel/Model/Structure/SpellRelation/SpellArea.cs b/Pf2eModel/Model/Structure/SpellRelation/SpellArea.cs index b2d2ed4..098b22b 100644 --- a/Pf2eModel/Model/Structure/SpellRelation/SpellArea.cs +++ b/Pf2eModel/Model/Structure/SpellRelation/SpellArea.cs @@ -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; diff --git a/Pf2eModel/Model/Structure/SpellRelation/SpellDamage.cs b/Pf2eModel/Model/Structure/SpellRelation/SpellDamage.cs index 003b442..177fa83 100644 --- a/Pf2eModel/Model/Structure/SpellRelation/SpellDamage.cs +++ b/Pf2eModel/Model/Structure/SpellRelation/SpellDamage.cs @@ -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; diff --git a/Pf2eModel/Model/Structure/Trait.cs b/Pf2eModel/Model/Structure/Trait.cs index 234370a..830f664 100644 --- a/Pf2eModel/Model/Structure/Trait.cs +++ b/Pf2eModel/Model/Structure/Trait.cs @@ -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; diff --git a/Pf2eModel/Pf2eDbContext.cs b/Pf2eModel/Pf2eDbContext.cs index fdf5ff4..dfdf028 100644 --- a/Pf2eModel/Pf2eDbContext.cs +++ b/Pf2eModel/Pf2eDbContext.cs @@ -20,14 +20,10 @@ namespace Pf2eModel; public partial class Pf2eDbContext : DbContext { - public Pf2eDbContext() - { - } + public Pf2eDbContext() { } public Pf2eDbContext(DbContextOptions 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() .MapEnum() .MapEnum() - .MapEnum() - ; + .MapEnum(); } ); } - } diff --git a/Pf2eModel/Pf2eModel.csproj b/Pf2eModel/Pf2eModel.csproj index 2411111..d5e7a03 100644 --- a/Pf2eModel/Pf2eModel.csproj +++ b/Pf2eModel/Pf2eModel.csproj @@ -1,43 +1,37 @@  - net8.0 enable enable - True + True - - - Always - + + Always + - - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + - - - True @@ -45,5 +39,4 @@ RebuildDatabase.bat - diff --git a/Pf2eViewer/Pf2eViewer.csproj b/Pf2eViewer/Pf2eViewer.csproj index a76dae8..6830c67 100644 --- a/Pf2eViewer/Pf2eViewer.csproj +++ b/Pf2eViewer/Pf2eViewer.csproj @@ -1,5 +1,4 @@  - WinExe net8.0-windows @@ -7,17 +6,13 @@ true enable - - - - - \ No newline at end of file + diff --git a/Pf2eViewer/Program.cs b/Pf2eViewer/Program.cs index 20e2262..cef9888 100644 --- a/Pf2eViewer/Program.cs +++ b/Pf2eViewer/Program.cs @@ -13,4 +13,4 @@ internal static class Program ApplicationConfiguration.Initialize(); Application.Run(new MainViewForm()); } -} \ No newline at end of file +}