diff --git a/CHANGELOG.md b/CHANGELOG.md index 79a88a6f..fd6fdfa3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,12 +3,13 @@ #### Version - 3.0.6.1 - TBD * Game support: * Added Mount & Blade II: Bennerlord support (Steam,GOG) +* Fixed BA2 files not being compressed properly due to MipMaps not being detected properly #### Version - 3.0.6.0 - 1/21/2023 * Add support for Cubemaps in BA2 files, if you have problems with BA2 recompression, be sure to delete your `GlobalVFSCache3.sqlite` from your AppData before the next compile * Fixed slides not being shown during installation for lists compile with the 3.0 compiler * Set the "While loading slide" debug message to be `Trace` level, set the default minimum log level to `Information` -* Switched back to using TexConv for texture converting on Windows, should greatly improve compatability of texture conversion (on windows systems) +* Switched back to using TexConv for texture converting on Windows, should greatly improve compatibility of texture conversion (on windows systems) #### Version - 3.0.5.0 - 12/22/2022 * Add support for https://www.nexusmods.com/site hosted mods. diff --git a/Wabbajack.Compiler.Test/SanityTests.cs b/Wabbajack.Compiler.Test/SanityTests.cs index b3c80812..d14ae696 100644 --- a/Wabbajack.Compiler.Test/SanityTests.cs +++ b/Wabbajack.Compiler.Test/SanityTests.cs @@ -202,7 +202,7 @@ public class CompilerSanityTests : IAsyncLifetime var oldState = await _imageLoader.Load(file); Assert.NotEqual(DXGI_FORMAT.UNKNOWN, oldState.Format); _logger.LogInformation("Recompressing {file}", file.FileName); - await _imageLoader.Recompress(file, 512, 512, DXGI_FORMAT.BC7_UNORM, file, CancellationToken.None); + await _imageLoader.Recompress(file, 512, 512, 1, DXGI_FORMAT.BC7_UNORM, file, CancellationToken.None); var state = await _imageLoader.Load(file); Assert.Equal(DXGI_FORMAT.BC7_UNORM, state.Format); diff --git a/Wabbajack.Compression.BSA/FO4Archive/Builder.cs b/Wabbajack.Compression.BSA/FO4Archive/Builder.cs index 2cad5238..7116fdb7 100644 --- a/Wabbajack.Compression.BSA/FO4Archive/Builder.cs +++ b/Wabbajack.Compression.BSA/FO4Archive/Builder.cs @@ -20,24 +20,31 @@ public class Builder : IBuilder public async ValueTask AddFile(AFile state, Stream src, CancellationToken token) { - switch (_state.Type) + try { - case BA2EntryType.GNRL: - var result = await FileEntryBuilder.Create((BA2File) state, src, _slab, token); - lock (_entries) - { - _entries.Add(result); - } + switch (_state.Type) + { + case BA2EntryType.GNRL: + var result = await FileEntryBuilder.Create((BA2File)state, src, _slab, token); + lock (_entries) + { + _entries.Add(result); + } - break; - case BA2EntryType.DX10: - var resultdx10 = await DX10FileEntryBuilder.Create((BA2DX10File) state, src, _slab, token); - lock (_entries) - { - _entries.Add(resultdx10); - } + break; + case BA2EntryType.DX10: + var resultdx10 = await DX10FileEntryBuilder.Create((BA2DX10File)state, src, _slab, token); + lock (_entries) + { + _entries.Add(resultdx10); + } - break; + break; + } + } + catch (Exception ex) + { + throw new InvalidDataException($"Error adding file {state.Path} to archive: {ex.Message}", ex); } } diff --git a/Wabbajack.DTOs/JsonConverters/Generated.cs b/Wabbajack.DTOs/JsonConverters/Generated.cs index 644a59c9..c02ba069 100644 --- a/Wabbajack.DTOs/JsonConverters/Generated.cs +++ b/Wabbajack.DTOs/JsonConverters/Generated.cs @@ -1,2708 +1,2223 @@ // THIS FILE IS AUTOGENERATED DO NOT EDIT BY HAND - using System; using System.Text.Json; using System.Text.Json.Serialization; using Wabbajack.Hashing.xxHash64; using Microsoft.Extensions.DependencyInjection; -public class - Wabbajack_DTOs_DownloadStates_IDownloadStateConverter : JsonConverter -{ - public static void ConfigureServices(IServiceCollection services) - { - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); +public class Wabbajack_DTOs_DownloadStates_IDownloadStateConverter : JsonConverter { + public static void ConfigureServices(IServiceCollection services) { + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + } + public override Wabbajack.DTOs.DownloadStates.IDownloadState Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + var cReader = reader; + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + cReader.Read(); + if (cReader.GetString() != "$type") + throw new JsonException(); + cReader.Read(); + var type = cReader.GetString(); + switch(type) { + case "Bethesda": + return JsonSerializer.Deserialize(ref reader, options)!; + case "LoversLabDownloader, Wabbajack.Lib": + return JsonSerializer.Deserialize(ref reader, options)!; + case "GameFileSourceDownloader, Wabbajack.Lib": + return JsonSerializer.Deserialize(ref reader, options)!; + case "GameFileSource": + return JsonSerializer.Deserialize(ref reader, options)!; + case "GoogleDriveDownloader, Wabbajack.Lib": + return JsonSerializer.Deserialize(ref reader, options)!; + case "GoogleDrive": + return JsonSerializer.Deserialize(ref reader, options)!; + case "HttpDownloader, Wabbajack.Lib": + return JsonSerializer.Deserialize(ref reader, options)!; + case "Http": + return JsonSerializer.Deserialize(ref reader, options)!; + case "HttpDownloader": + return JsonSerializer.Deserialize(ref reader, options)!; + case "LoversLabOAuthDownloader, Wabbajack.Lib": + return JsonSerializer.Deserialize(ref reader, options)!; + case "LoversLab": + return JsonSerializer.Deserialize(ref reader, options)!; + case "ManualDownloader, Wabbajack.Lib": + return JsonSerializer.Deserialize(ref reader, options)!; + case "Manual": + return JsonSerializer.Deserialize(ref reader, options)!; + case "MediaFireDownloader+State, Wabbajack.Lib": + return JsonSerializer.Deserialize(ref reader, options)!; + case "MediaFire": + return JsonSerializer.Deserialize(ref reader, options)!; + case "MediaFireDownloader": + return JsonSerializer.Deserialize(ref reader, options)!; + case "MegaDownloader, Wabbajack.Lib": + return JsonSerializer.Deserialize(ref reader, options)!; + case "Mega": + return JsonSerializer.Deserialize(ref reader, options)!; + case "ModDBDownloader, Wabbajack.Lib": + return JsonSerializer.Deserialize(ref reader, options)!; + case "ModDB": + return JsonSerializer.Deserialize(ref reader, options)!; + case "ModDBDownloader": + return JsonSerializer.Deserialize(ref reader, options)!; + case "NexusDownloader, Wabbajack.Lib": + return JsonSerializer.Deserialize(ref reader, options)!; + case "Nexus": + return JsonSerializer.Deserialize(ref reader, options)!; + case "TESAllianceDownloader, Wabbajack.Lib": + return JsonSerializer.Deserialize(ref reader, options)!; + case "TESAlliance": + return JsonSerializer.Deserialize(ref reader, options)!; + case "VectorPlexusOAuthDownloader+State, Wabbajack.Lib": + return JsonSerializer.Deserialize(ref reader, options)!; + case "VectorPlexus": + return JsonSerializer.Deserialize(ref reader, options)!; + case "WabbajackCDNDownloader+State, Wabbajack.Lib": + return JsonSerializer.Deserialize(ref reader, options)!; + case "WabbajackCDN": + return JsonSerializer.Deserialize(ref reader, options)!; + default: + throw new JsonException($"No Type dispatch for {type}"); } - - public override Wabbajack.DTOs.DownloadStates.IDownloadState Read(ref Utf8JsonReader reader, Type typeToConvert, - JsonSerializerOptions options) - { - var cReader = reader; - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException(); - cReader.Read(); - if (cReader.GetString() != "$type") - throw new JsonException(); - cReader.Read(); - var type = cReader.GetString(); - switch (type) - { - case "Bethesda": - return JsonSerializer.Deserialize(ref reader, options)!; - case "LoversLabDownloader, Wabbajack.Lib": - return JsonSerializer.Deserialize(ref reader, - options)!; - case "GameFileSourceDownloader, Wabbajack.Lib": - return JsonSerializer.Deserialize(ref reader, options)!; - case "GameFileSource": - return JsonSerializer.Deserialize(ref reader, options)!; - case "GoogleDriveDownloader, Wabbajack.Lib": - return JsonSerializer.Deserialize(ref reader, options)!; - case "GoogleDrive": - return JsonSerializer.Deserialize(ref reader, options)!; - case "HttpDownloader, Wabbajack.Lib": - return JsonSerializer.Deserialize(ref reader, options)!; - case "Http": - return JsonSerializer.Deserialize(ref reader, options)!; - case "HttpDownloader": - return JsonSerializer.Deserialize(ref reader, options)!; - case "LoversLabOAuthDownloader, Wabbajack.Lib": - return JsonSerializer.Deserialize(ref reader, options)!; - case "LoversLab": - return JsonSerializer.Deserialize(ref reader, options)!; - case "ManualDownloader, Wabbajack.Lib": - return JsonSerializer.Deserialize(ref reader, options)!; - case "Manual": - return JsonSerializer.Deserialize(ref reader, options)!; - case "MediaFireDownloader+State, Wabbajack.Lib": - return JsonSerializer.Deserialize(ref reader, options)!; - case "MediaFire": - return JsonSerializer.Deserialize(ref reader, options)!; - case "MediaFireDownloader": - return JsonSerializer.Deserialize(ref reader, options)!; - case "MegaDownloader, Wabbajack.Lib": - return JsonSerializer.Deserialize(ref reader, options)!; - case "Mega": - return JsonSerializer.Deserialize(ref reader, options)!; - case "ModDBDownloader, Wabbajack.Lib": - return JsonSerializer.Deserialize(ref reader, options)!; - case "ModDB": - return JsonSerializer.Deserialize(ref reader, options)!; - case "ModDBDownloader": - return JsonSerializer.Deserialize(ref reader, options)!; - case "NexusDownloader, Wabbajack.Lib": - return JsonSerializer.Deserialize(ref reader, options)!; - case "Nexus": - return JsonSerializer.Deserialize(ref reader, options)!; - case "TESAllianceDownloader, Wabbajack.Lib": - return JsonSerializer.Deserialize(ref reader, options)!; - case "TESAlliance": - return JsonSerializer.Deserialize(ref reader, options)!; - case "VectorPlexusOAuthDownloader+State, Wabbajack.Lib": - return JsonSerializer.Deserialize(ref reader, options)!; - case "VectorPlexus": - return JsonSerializer.Deserialize(ref reader, options)!; - case "WabbajackCDNDownloader+State, Wabbajack.Lib": - return JsonSerializer.Deserialize(ref reader, options)!; - case "WabbajackCDN": - return JsonSerializer.Deserialize(ref reader, options)!; - default: - throw new JsonException($"No Type dispatch for {type}"); - } - } - - public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.DownloadStates.IDownloadState value, - JsonSerializerOptions options) - { - switch (value) - { - case Wabbajack.DTOs.DownloadStates.LoversLab v0: - JsonSerializer.Serialize(writer, v0, options); - return; - case Wabbajack.DTOs.DownloadStates.VectorPlexus v1: - JsonSerializer.Serialize(writer, v1, options); - return; - case Wabbajack.DTOs.DownloadStates.Bethesda v2: - JsonSerializer.Serialize(writer, v2, options); - return; - case Wabbajack.DTOs.DownloadStates.DeprecatedLoversLab v3: - JsonSerializer.Serialize(writer, v3, options); - return; - case Wabbajack.DTOs.DownloadStates.GameFileSource v4: - JsonSerializer.Serialize(writer, v4, options); - return; - case Wabbajack.DTOs.DownloadStates.GoogleDrive v5: - JsonSerializer.Serialize(writer, v5, options); - return; - case Wabbajack.DTOs.DownloadStates.Http v6: - JsonSerializer.Serialize(writer, v6, options); - return; - case Wabbajack.DTOs.DownloadStates.Manual v7: - JsonSerializer.Serialize(writer, v7, options); - return; - case Wabbajack.DTOs.DownloadStates.MediaFire v8: - JsonSerializer.Serialize(writer, v8, options); - return; - case Wabbajack.DTOs.DownloadStates.Mega v9: - JsonSerializer.Serialize(writer, v9, options); - return; - case Wabbajack.DTOs.DownloadStates.ModDB v10: - JsonSerializer.Serialize(writer, v10, options); - return; - case Wabbajack.DTOs.DownloadStates.Nexus v11: - JsonSerializer.Serialize(writer, v11, options); - return; - case Wabbajack.DTOs.DownloadStates.TESAlliance v12: - JsonSerializer.Serialize(writer, v12, options); - return; - case Wabbajack.DTOs.DownloadStates.WabbajackCDN v13: - JsonSerializer.Serialize(writer, v13, options); - return; - } + } + public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.DownloadStates.IDownloadState value, JsonSerializerOptions options) { + switch (value) { + case Wabbajack.DTOs.DownloadStates.LoversLab v0: + JsonSerializer.Serialize(writer, v0, options); + return; + case Wabbajack.DTOs.DownloadStates.VectorPlexus v1: + JsonSerializer.Serialize(writer, v1, options); + return; + case Wabbajack.DTOs.DownloadStates.Bethesda v2: + JsonSerializer.Serialize(writer, v2, options); + return; + case Wabbajack.DTOs.DownloadStates.DeprecatedLoversLab v3: + JsonSerializer.Serialize(writer, v3, options); + return; + case Wabbajack.DTOs.DownloadStates.GameFileSource v4: + JsonSerializer.Serialize(writer, v4, options); + return; + case Wabbajack.DTOs.DownloadStates.GoogleDrive v5: + JsonSerializer.Serialize(writer, v5, options); + return; + case Wabbajack.DTOs.DownloadStates.Http v6: + JsonSerializer.Serialize(writer, v6, options); + return; + case Wabbajack.DTOs.DownloadStates.Manual v7: + JsonSerializer.Serialize(writer, v7, options); + return; + case Wabbajack.DTOs.DownloadStates.MediaFire v8: + JsonSerializer.Serialize(writer, v8, options); + return; + case Wabbajack.DTOs.DownloadStates.Mega v9: + JsonSerializer.Serialize(writer, v9, options); + return; + case Wabbajack.DTOs.DownloadStates.ModDB v10: + JsonSerializer.Serialize(writer, v10, options); + return; + case Wabbajack.DTOs.DownloadStates.Nexus v11: + JsonSerializer.Serialize(writer, v11, options); + return; + case Wabbajack.DTOs.DownloadStates.TESAlliance v12: + JsonSerializer.Serialize(writer, v12, options); + return; + case Wabbajack.DTOs.DownloadStates.WabbajackCDN v13: + JsonSerializer.Serialize(writer, v13, options); + return; } + } } - -public class Wabbajack_DTOs_DownloadStates_BethesdaConverter : JsonConverter -{ - public override Wabbajack.DTOs.DownloadStates.Bethesda Read(ref Utf8JsonReader reader, Type typeToConvert, - JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException(); - System.Int64 branchidProp = default; - System.String contentidProp = default; - Wabbajack.DTOs.Game gameProp = default; - System.Boolean isccmodProp = default; - System.String nameProp = default; - System.Int64 productidProp = default; - while (true) - { - reader.Read(); - if (reader.TokenType == JsonTokenType.EndObject) - { - reader.Read(); - break; - } - - var prop = reader.GetString(); - reader.Read(); - switch (prop) - { - case "BranchId": - branchidProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "ContentId": - contentidProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "Game": - gameProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "IsCCMod": - isccmodProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "Name": - nameProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "ProductId": - productidProp = JsonSerializer.Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } +public class Wabbajack_DTOs_DownloadStates_BethesdaConverter : JsonConverter { + public override Wabbajack.DTOs.DownloadStates.Bethesda Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + System.Int64 branchidProp = default; + System.String contentidProp = default; + Wabbajack.DTOs.Game gameProp = default; + System.Boolean isccmodProp = default; + System.String nameProp = default; + System.Int64 productidProp = default; + while (true) { + reader.Read(); + if (reader.TokenType == JsonTokenType.EndObject) { + reader.Read(); + break; + } + var prop = reader.GetString(); + reader.Read(); + switch (prop) { + case "BranchId": + branchidProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "ContentId": + contentidProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Game": + gameProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "IsCCMod": + isccmodProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Name": + nameProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "ProductId": + productidProp = JsonSerializer.Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + return new Wabbajack.DTOs.DownloadStates.Bethesda { + BranchId = branchidProp, + ContentId = contentidProp, + Game = gameProp, + IsCCMod = isccmodProp, + Name = nameProp, + ProductId = productidProp, + }; + } + public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.DownloadStates.Bethesda value, JsonSerializerOptions options) { + writer.WriteStartObject(); + writer.WriteString("$type", "Bethesda"); + writer.WritePropertyName("BranchId"); + JsonSerializer.Serialize(writer, value.BranchId, options); + writer.WritePropertyName("ContentId"); + JsonSerializer.Serialize(writer, value.ContentId, options); + writer.WritePropertyName("Game"); + JsonSerializer.Serialize(writer, value.Game, options); + writer.WritePropertyName("IsCCMod"); + JsonSerializer.Serialize(writer, value.IsCCMod, options); + writer.WritePropertyName("Name"); + JsonSerializer.Serialize(writer, value.Name, options); + writer.WritePropertyName("ProductId"); + JsonSerializer.Serialize(writer, value.ProductId, options); + writer.WriteEndObject(); + } + } + public class Wabbajack_DTOs_DownloadStates_DeprecatedLoversLabConverter : JsonConverter { + public override Wabbajack.DTOs.DownloadStates.DeprecatedLoversLab Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + while (true) { + reader.Read(); + if (reader.TokenType == JsonTokenType.EndObject) { + reader.Read(); + break; } - - return new Wabbajack.DTOs.DownloadStates.Bethesda - { - BranchId = branchidProp, - ContentId = contentidProp, - Game = gameProp, - IsCCMod = isccmodProp, - Name = nameProp, - ProductId = productidProp, - }; - } - - public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.DownloadStates.Bethesda value, - JsonSerializerOptions options) - { - writer.WriteStartObject(); - writer.WriteString("$type", "Bethesda"); - writer.WritePropertyName("BranchId"); - JsonSerializer.Serialize(writer, value.BranchId, options); - writer.WritePropertyName("ContentId"); - JsonSerializer.Serialize(writer, value.ContentId, options); - writer.WritePropertyName("Game"); - JsonSerializer.Serialize(writer, value.Game, options); - writer.WritePropertyName("IsCCMod"); - JsonSerializer.Serialize(writer, value.IsCCMod, options); - writer.WritePropertyName("Name"); - JsonSerializer.Serialize(writer, value.Name, options); - writer.WritePropertyName("ProductId"); - JsonSerializer.Serialize(writer, value.ProductId, options); - writer.WriteEndObject(); - } -} - -public class - Wabbajack_DTOs_DownloadStates_DeprecatedLoversLabConverter : JsonConverter< - Wabbajack.DTOs.DownloadStates.DeprecatedLoversLab> -{ - public override Wabbajack.DTOs.DownloadStates.DeprecatedLoversLab Read(ref Utf8JsonReader reader, - Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException(); - while (true) - { - reader.Read(); - if (reader.TokenType == JsonTokenType.EndObject) - { - reader.Read(); - break; - } - - var prop = reader.GetString(); - reader.Read(); - switch (prop) - { - default: - reader.Skip(); - break; - } + var prop = reader.GetString(); + reader.Read(); + switch (prop) { + default: + reader.Skip(); + break; } - - return new Wabbajack.DTOs.DownloadStates.DeprecatedLoversLab - { + } + return new Wabbajack.DTOs.DownloadStates.DeprecatedLoversLab { }; - } - - public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.DownloadStates.DeprecatedLoversLab value, - JsonSerializerOptions options) - { + } + public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.DownloadStates.DeprecatedLoversLab value, JsonSerializerOptions options) { writer.WriteStartObject(); writer.WriteString("$type", "LoversLabDownloader, Wabbajack.Lib"); writer.WriteEndObject(); + } } -} - -public class - Wabbajack_DTOs_DownloadStates_GameFileSourceConverter : JsonConverter -{ - public override Wabbajack.DTOs.DownloadStates.GameFileSource Read(ref Utf8JsonReader reader, Type typeToConvert, - JsonSerializerOptions options) - { + public class Wabbajack_DTOs_DownloadStates_GameFileSourceConverter : JsonConverter { + public override Wabbajack.DTOs.DownloadStates.GameFileSource Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException(); + throw new JsonException(); Wabbajack.DTOs.Game gameProp = default; Wabbajack.Paths.RelativePath gamefileProp = default; System.String gameversionProp = default; Wabbajack.Hashing.xxHash64.Hash hashProp = default; - while (true) - { + while (true) { + reader.Read(); + if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); - if (reader.TokenType == JsonTokenType.EndObject) - { - reader.Read(); - break; - } - - var prop = reader.GetString(); - reader.Read(); - switch (prop) - { - case "Game": - gameProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "GameFile": - gamefileProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "GameVersion": - gameversionProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "Hash": - hashProp = JsonSerializer.Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } + break; + } + var prop = reader.GetString(); + reader.Read(); + switch (prop) { + case "Game": + gameProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "GameFile": + gamefileProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "GameVersion": + gameversionProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Hash": + hashProp = JsonSerializer.Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } } - - return new Wabbajack.DTOs.DownloadStates.GameFileSource - { - Game = gameProp, - GameFile = gamefileProp, - GameVersion = gameversionProp, - Hash = hashProp, - }; - } - - public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.DownloadStates.GameFileSource value, - JsonSerializerOptions options) - { - writer.WriteStartObject(); - writer.WriteString("$type", "GameFileSourceDownloader, Wabbajack.Lib"); - writer.WritePropertyName("Game"); - JsonSerializer.Serialize(writer, value.Game, options); - writer.WritePropertyName("GameFile"); - JsonSerializer.Serialize(writer, value.GameFile, options); - writer.WritePropertyName("GameVersion"); - JsonSerializer.Serialize(writer, value.GameVersion, options); - writer.WritePropertyName("Hash"); - JsonSerializer.Serialize(writer, value.Hash, options); - writer.WriteEndObject(); - } -} - -public class - Wabbajack_DTOs_DownloadStates_GoogleDriveConverter : JsonConverter -{ - public override Wabbajack.DTOs.DownloadStates.GoogleDrive Read(ref Utf8JsonReader reader, Type typeToConvert, - JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) + return new Wabbajack.DTOs.DownloadStates.GameFileSource { + Game = gameProp, + GameFile = gamefileProp, + GameVersion = gameversionProp, + Hash = hashProp, + }; + } + public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.DownloadStates.GameFileSource value, JsonSerializerOptions options) { + writer.WriteStartObject(); + writer.WriteString("$type", "GameFileSourceDownloader, Wabbajack.Lib"); + writer.WritePropertyName("Game"); + JsonSerializer.Serialize(writer, value.Game, options); + writer.WritePropertyName("GameFile"); + JsonSerializer.Serialize(writer, value.GameFile, options); + writer.WritePropertyName("GameVersion"); + JsonSerializer.Serialize(writer, value.GameVersion, options); + writer.WritePropertyName("Hash"); + JsonSerializer.Serialize(writer, value.Hash, options); + writer.WriteEndObject(); + } + } + public class Wabbajack_DTOs_DownloadStates_GoogleDriveConverter : JsonConverter { + public override Wabbajack.DTOs.DownloadStates.GoogleDrive Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType != JsonTokenType.StartObject) throw new JsonException(); - System.String idProp = default; - while (true) - { + System.String idProp = default; + while (true) { reader.Read(); - if (reader.TokenType == JsonTokenType.EndObject) - { - reader.Read(); - break; + if (reader.TokenType == JsonTokenType.EndObject) { + reader.Read(); + break; } - var prop = reader.GetString(); reader.Read(); - switch (prop) - { - case "Id": - idProp = JsonSerializer.Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; + switch (prop) { + case "Id": + idProp = JsonSerializer.Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; } - } - - return new Wabbajack.DTOs.DownloadStates.GoogleDrive - { + } + return new Wabbajack.DTOs.DownloadStates.GoogleDrive { Id = idProp, - }; - } - - public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.DownloadStates.GoogleDrive value, - JsonSerializerOptions options) - { - writer.WriteStartObject(); - writer.WriteString("$type", "GoogleDriveDownloader, Wabbajack.Lib"); - writer.WritePropertyName("Id"); - JsonSerializer.Serialize(writer, value.Id, options); - writer.WriteEndObject(); - } -} - -public class Wabbajack_DTOs_DownloadStates_HttpConverter : JsonConverter -{ - public override Wabbajack.DTOs.DownloadStates.Http Read(ref Utf8JsonReader reader, Type typeToConvert, - JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException(); - System.String[] headersProp = default; - System.Uri urlProp = default; - while (true) - { - reader.Read(); - if (reader.TokenType == JsonTokenType.EndObject) - { + }; + } + public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.DownloadStates.GoogleDrive value, JsonSerializerOptions options) { + writer.WriteStartObject(); + writer.WriteString("$type", "GoogleDriveDownloader, Wabbajack.Lib"); + writer.WritePropertyName("Id"); + JsonSerializer.Serialize(writer, value.Id, options); + writer.WriteEndObject(); + } + } + public class Wabbajack_DTOs_DownloadStates_HttpConverter : JsonConverter { + public override Wabbajack.DTOs.DownloadStates.Http Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + System.String[] headersProp = default; + System.Uri urlProp = default; + while (true) { + reader.Read(); + if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); break; - } - - var prop = reader.GetString(); - reader.Read(); - switch (prop) - { + } + var prop = reader.GetString(); + reader.Read(); + switch (prop) { case "Headers": - headersProp = JsonSerializer.Deserialize(ref reader, options); - break; + headersProp = JsonSerializer.Deserialize(ref reader, options); + break; case "Url": - urlProp = JsonSerializer.Deserialize(ref reader, options); - break; + urlProp = JsonSerializer.Deserialize(ref reader, options); + break; default: - reader.Skip(); - break; + reader.Skip(); + break; + } } - } - - return new Wabbajack.DTOs.DownloadStates.Http - { - Headers = headersProp, - Url = urlProp, - }; - } - - public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.DownloadStates.Http value, - JsonSerializerOptions options) - { - writer.WriteStartObject(); - writer.WriteString("$type", "HttpDownloader, Wabbajack.Lib"); - writer.WritePropertyName("Headers"); - JsonSerializer.Serialize(writer, value.Headers, options); - writer.WritePropertyName("Url"); - JsonSerializer.Serialize(writer, value.Url, options); - writer.WriteEndObject(); - } -} - -public class Wabbajack_DTOs_DownloadStates_LoversLabConverter : JsonConverter -{ - public override Wabbajack.DTOs.DownloadStates.LoversLab Read(ref Utf8JsonReader reader, Type typeToConvert, - JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException(); - System.String authorProp = default; - System.String descriptionProp = default; - System.Uri imageurlProp = default; - System.String ips4fileProp = default; - System.Int64 ips4modProp = default; - System.String ips4urlProp = default; - System.Boolean isattachmentProp = default; - System.Boolean isnsfwProp = default; - System.String nameProp = default; - System.String versionProp = default; - while (true) - { - reader.Read(); - if (reader.TokenType == JsonTokenType.EndObject) - { + return new Wabbajack.DTOs.DownloadStates.Http { + Headers = headersProp, + Url = urlProp, + }; + } + public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.DownloadStates.Http value, JsonSerializerOptions options) { + writer.WriteStartObject(); + writer.WriteString("$type", "HttpDownloader, Wabbajack.Lib"); + writer.WritePropertyName("Headers"); + JsonSerializer.Serialize(writer, value.Headers, options); + writer.WritePropertyName("Url"); + JsonSerializer.Serialize(writer, value.Url, options); + writer.WriteEndObject(); + } + } + public class Wabbajack_DTOs_DownloadStates_LoversLabConverter : JsonConverter { + public override Wabbajack.DTOs.DownloadStates.LoversLab Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + System.String authorProp = default; + System.String descriptionProp = default; + System.Uri imageurlProp = default; + System.String ips4fileProp = default; + System.Int64 ips4modProp = default; + System.String ips4urlProp = default; + System.Boolean isattachmentProp = default; + System.Boolean isnsfwProp = default; + System.String nameProp = default; + System.String versionProp = default; + while (true) { reader.Read(); - break; - } - - var prop = reader.GetString(); - reader.Read(); - switch (prop) - { - case "Author": + if (reader.TokenType == JsonTokenType.EndObject) { + reader.Read(); + break; + } + var prop = reader.GetString(); + reader.Read(); + switch (prop) { + case "Author": authorProp = JsonSerializer.Deserialize(ref reader, options); break; - case "Description": + case "Description": descriptionProp = JsonSerializer.Deserialize(ref reader, options); break; - case "ImageURL": + case "ImageURL": imageurlProp = JsonSerializer.Deserialize(ref reader, options); break; - case "IPS4File": + case "IPS4File": ips4fileProp = JsonSerializer.Deserialize(ref reader, options); break; - case "IPS4Mod": + case "IPS4Mod": ips4modProp = JsonSerializer.Deserialize(ref reader, options); break; - case "IPS4Url": + case "IPS4Url": ips4urlProp = JsonSerializer.Deserialize(ref reader, options); break; - case "IsAttachment": + case "IsAttachment": isattachmentProp = JsonSerializer.Deserialize(ref reader, options); break; - case "IsNSFW": + case "IsNSFW": isnsfwProp = JsonSerializer.Deserialize(ref reader, options); break; - case "Name": + case "Name": nameProp = JsonSerializer.Deserialize(ref reader, options); break; - case "Version": + case "Version": versionProp = JsonSerializer.Deserialize(ref reader, options); break; - default: + default: reader.Skip(); break; + } + } + return new Wabbajack.DTOs.DownloadStates.LoversLab { + Author = authorProp, + Description = descriptionProp, + ImageURL = imageurlProp, + IPS4File = ips4fileProp, + IPS4Mod = ips4modProp, + IPS4Url = ips4urlProp, + IsAttachment = isattachmentProp, + IsNSFW = isnsfwProp, + Name = nameProp, + Version = versionProp, + }; + } + public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.DownloadStates.LoversLab value, JsonSerializerOptions options) { + writer.WriteStartObject(); + writer.WriteString("$type", "LoversLabOAuthDownloader, Wabbajack.Lib"); + writer.WritePropertyName("Author"); + JsonSerializer.Serialize(writer, value.Author, options); + writer.WritePropertyName("Description"); + JsonSerializer.Serialize(writer, value.Description, options); + writer.WritePropertyName("ImageURL"); + JsonSerializer.Serialize(writer, value.ImageURL, options); + writer.WritePropertyName("IPS4File"); + JsonSerializer.Serialize(writer, value.IPS4File, options); + writer.WritePropertyName("IPS4Mod"); + JsonSerializer.Serialize(writer, value.IPS4Mod, options); + writer.WritePropertyName("IPS4Url"); + JsonSerializer.Serialize(writer, value.IPS4Url, options); + writer.WritePropertyName("IsAttachment"); + JsonSerializer.Serialize(writer, value.IsAttachment, options); + writer.WritePropertyName("IsNSFW"); + JsonSerializer.Serialize(writer, value.IsNSFW, options); + writer.WritePropertyName("Name"); + JsonSerializer.Serialize(writer, value.Name, options); + writer.WritePropertyName("Version"); + JsonSerializer.Serialize(writer, value.Version, options); + writer.WriteEndObject(); + } } - } - - return new Wabbajack.DTOs.DownloadStates.LoversLab - { - Author = authorProp, - Description = descriptionProp, - ImageURL = imageurlProp, - IPS4File = ips4fileProp, - IPS4Mod = ips4modProp, - IPS4Url = ips4urlProp, - IsAttachment = isattachmentProp, - IsNSFW = isnsfwProp, - Name = nameProp, - Version = versionProp, - }; - } - - public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.DownloadStates.LoversLab value, - JsonSerializerOptions options) - { - writer.WriteStartObject(); - writer.WriteString("$type", "LoversLabOAuthDownloader, Wabbajack.Lib"); - writer.WritePropertyName("Author"); - JsonSerializer.Serialize(writer, value.Author, options); - writer.WritePropertyName("Description"); - JsonSerializer.Serialize(writer, value.Description, options); - writer.WritePropertyName("ImageURL"); - JsonSerializer.Serialize(writer, value.ImageURL, options); - writer.WritePropertyName("IPS4File"); - JsonSerializer.Serialize(writer, value.IPS4File, options); - writer.WritePropertyName("IPS4Mod"); - JsonSerializer.Serialize(writer, value.IPS4Mod, options); - writer.WritePropertyName("IPS4Url"); - JsonSerializer.Serialize(writer, value.IPS4Url, options); - writer.WritePropertyName("IsAttachment"); - JsonSerializer.Serialize(writer, value.IsAttachment, options); - writer.WritePropertyName("IsNSFW"); - JsonSerializer.Serialize(writer, value.IsNSFW, options); - writer.WritePropertyName("Name"); - JsonSerializer.Serialize(writer, value.Name, options); - writer.WritePropertyName("Version"); - JsonSerializer.Serialize(writer, value.Version, options); - writer.WriteEndObject(); - } -} - -public class Wabbajack_DTOs_DownloadStates_ManualConverter : JsonConverter -{ - public override Wabbajack.DTOs.DownloadStates.Manual Read(ref Utf8JsonReader reader, Type typeToConvert, - JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException(); - System.String promptProp = default; - System.Uri urlProp = default; - while (true) - { - reader.Read(); - if (reader.TokenType == JsonTokenType.EndObject) - { - reader.Read(); - break; - } - - var prop = reader.GetString(); - reader.Read(); - switch (prop) - { - case "Prompt": - promptProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "Url": - urlProp = JsonSerializer.Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - return new Wabbajack.DTOs.DownloadStates.Manual - { - Prompt = promptProp, - Url = urlProp, - }; - } - - public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.DownloadStates.Manual value, - JsonSerializerOptions options) - { - writer.WriteStartObject(); - writer.WriteString("$type", "ManualDownloader, Wabbajack.Lib"); - writer.WritePropertyName("Prompt"); - JsonSerializer.Serialize(writer, value.Prompt, options); - writer.WritePropertyName("Url"); - JsonSerializer.Serialize(writer, value.Url, options); - writer.WriteEndObject(); - } -} - -public class Wabbajack_DTOs_DownloadStates_MediaFireConverter : JsonConverter -{ - public override Wabbajack.DTOs.DownloadStates.MediaFire Read(ref Utf8JsonReader reader, Type typeToConvert, - JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException(); - System.Uri urlProp = default; - while (true) - { - reader.Read(); - if (reader.TokenType == JsonTokenType.EndObject) - { - reader.Read(); - break; - } - - var prop = reader.GetString(); - reader.Read(); - switch (prop) - { - case "Url": - urlProp = JsonSerializer.Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - return new Wabbajack.DTOs.DownloadStates.MediaFire - { - Url = urlProp, - }; - } - - public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.DownloadStates.MediaFire value, - JsonSerializerOptions options) - { - writer.WriteStartObject(); - writer.WriteString("$type", "MediaFireDownloader+State, Wabbajack.Lib"); - writer.WritePropertyName("Url"); - JsonSerializer.Serialize(writer, value.Url, options); - writer.WriteEndObject(); - } -} - -public class Wabbajack_DTOs_DownloadStates_MegaConverter : JsonConverter -{ - public override Wabbajack.DTOs.DownloadStates.Mega Read(ref Utf8JsonReader reader, Type typeToConvert, - JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException(); - System.Uri urlProp = default; - while (true) - { - reader.Read(); - if (reader.TokenType == JsonTokenType.EndObject) - { - reader.Read(); - break; - } - - var prop = reader.GetString(); - reader.Read(); - switch (prop) - { - case "Url": - urlProp = JsonSerializer.Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - return new Wabbajack.DTOs.DownloadStates.Mega - { - Url = urlProp, - }; - } - - public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.DownloadStates.Mega value, - JsonSerializerOptions options) - { - writer.WriteStartObject(); - writer.WriteString("$type", "MegaDownloader, Wabbajack.Lib"); - writer.WritePropertyName("Url"); - JsonSerializer.Serialize(writer, value.Url, options); - writer.WriteEndObject(); - } -} - -public class Wabbajack_DTOs_DownloadStates_ModDBConverter : JsonConverter -{ - public override Wabbajack.DTOs.DownloadStates.ModDB Read(ref Utf8JsonReader reader, Type typeToConvert, - JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException(); - System.Uri urlProp = default; - while (true) - { - reader.Read(); - if (reader.TokenType == JsonTokenType.EndObject) - { - reader.Read(); - break; - } - - var prop = reader.GetString(); - reader.Read(); - switch (prop) - { - case "Url": - urlProp = JsonSerializer.Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - return new Wabbajack.DTOs.DownloadStates.ModDB - { - Url = urlProp, - }; - } - - public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.DownloadStates.ModDB value, - JsonSerializerOptions options) - { - writer.WriteStartObject(); - writer.WriteString("$type", "ModDBDownloader, Wabbajack.Lib"); - writer.WritePropertyName("Url"); - JsonSerializer.Serialize(writer, value.Url, options); - writer.WriteEndObject(); - } -} - -public class Wabbajack_DTOs_DownloadStates_NexusConverter : JsonConverter -{ - public override Wabbajack.DTOs.DownloadStates.Nexus Read(ref Utf8JsonReader reader, Type typeToConvert, - JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException(); - System.String authorProp = default; - System.String descriptionProp = default; - System.Int64 fileidProp = default; - Wabbajack.DTOs.Game gamenameProp = default; - System.Uri imageurlProp = default; - System.Boolean isnsfwProp = default; - System.Int64 modidProp = default; - System.String nameProp = default; - System.String versionProp = default; - while (true) - { - reader.Read(); - if (reader.TokenType == JsonTokenType.EndObject) - { - reader.Read(); - break; - } - - var prop = reader.GetString(); - reader.Read(); - switch (prop) - { - case "Author": - authorProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "Description": - descriptionProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "FileID": - fileidProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "GameName": - gamenameProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "ImageURL": - imageurlProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "IsNSFW": - isnsfwProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "ModID": - modidProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "Name": - nameProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "Version": - versionProp = JsonSerializer.Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - return new Wabbajack.DTOs.DownloadStates.Nexus - { - Author = authorProp, - Description = descriptionProp, - FileID = fileidProp, - Game = gamenameProp, - ImageURL = imageurlProp, - IsNSFW = isnsfwProp, - ModID = modidProp, - Name = nameProp, - Version = versionProp, - }; - } - - public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.DownloadStates.Nexus value, - JsonSerializerOptions options) - { - writer.WriteStartObject(); - writer.WriteString("$type", "NexusDownloader, Wabbajack.Lib"); - writer.WritePropertyName("Author"); - JsonSerializer.Serialize(writer, value.Author, options); - writer.WritePropertyName("Description"); - JsonSerializer.Serialize(writer, value.Description, options); - writer.WritePropertyName("FileID"); - JsonSerializer.Serialize(writer, value.FileID, options); - writer.WritePropertyName("GameName"); - JsonSerializer.Serialize(writer, value.Game, options); - writer.WritePropertyName("ImageURL"); - JsonSerializer.Serialize(writer, value.ImageURL, options); - writer.WritePropertyName("IsNSFW"); - JsonSerializer.Serialize(writer, value.IsNSFW, options); - writer.WritePropertyName("ModID"); - JsonSerializer.Serialize(writer, value.ModID, options); - writer.WritePropertyName("Name"); - JsonSerializer.Serialize(writer, value.Name, options); - writer.WritePropertyName("Version"); - JsonSerializer.Serialize(writer, value.Version, options); - writer.WriteEndObject(); - } -} - -public class - Wabbajack_DTOs_DownloadStates_TESAllianceConverter : JsonConverter -{ - public override Wabbajack.DTOs.DownloadStates.TESAlliance Read(ref Utf8JsonReader reader, Type typeToConvert, - JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException(); - System.String fileidProp = default; - System.String filenameProp = default; - System.Uri fullurlProp = default; - System.Boolean isattachmentProp = default; - while (true) - { - reader.Read(); - if (reader.TokenType == JsonTokenType.EndObject) - { - reader.Read(); - break; - } - - var prop = reader.GetString(); - reader.Read(); - switch (prop) - { - case "FileID": - fileidProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "FileName": - filenameProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "FullURL": - fullurlProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "IsAttachment": - isattachmentProp = JsonSerializer.Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - return new Wabbajack.DTOs.DownloadStates.TESAlliance - { - FileID = fileidProp, - FileName = filenameProp, - FullURL = fullurlProp, - IsAttachment = isattachmentProp, - }; - } - - public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.DownloadStates.TESAlliance value, - JsonSerializerOptions options) - { - writer.WriteStartObject(); - writer.WriteString("$type", "TESAllianceDownloader, Wabbajack.Lib"); - writer.WritePropertyName("FileID"); - JsonSerializer.Serialize(writer, value.FileID, options); - writer.WritePropertyName("FileName"); - JsonSerializer.Serialize(writer, value.FileName, options); - writer.WritePropertyName("FullURL"); - JsonSerializer.Serialize(writer, value.FullURL, options); - writer.WritePropertyName("IsAttachment"); - JsonSerializer.Serialize(writer, value.IsAttachment, options); - writer.WriteEndObject(); - } -} - -public class - Wabbajack_DTOs_DownloadStates_VectorPlexusConverter : JsonConverter -{ - public override Wabbajack.DTOs.DownloadStates.VectorPlexus Read(ref Utf8JsonReader reader, Type typeToConvert, - JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException(); - System.String authorProp = default; - System.String descriptionProp = default; - System.Uri imageurlProp = default; - System.String ips4fileProp = default; - System.Int64 ips4modProp = default; - System.String ips4urlProp = default; - System.Boolean isattachmentProp = default; - System.Boolean isnsfwProp = default; - System.String nameProp = default; - System.String versionProp = default; - while (true) - { - reader.Read(); - if (reader.TokenType == JsonTokenType.EndObject) - { - reader.Read(); - break; - } - - var prop = reader.GetString(); - reader.Read(); - switch (prop) - { - case "Author": - authorProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "Description": - descriptionProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "ImageURL": - imageurlProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "IPS4File": - ips4fileProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "IPS4Mod": - ips4modProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "IPS4Url": - ips4urlProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "IsAttachment": - isattachmentProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "IsNSFW": - isnsfwProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "Name": - nameProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "Version": - versionProp = JsonSerializer.Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - return new Wabbajack.DTOs.DownloadStates.VectorPlexus - { - Author = authorProp, - Description = descriptionProp, - ImageURL = imageurlProp, - IPS4File = ips4fileProp, - IPS4Mod = ips4modProp, - IPS4Url = ips4urlProp, - IsAttachment = isattachmentProp, - IsNSFW = isnsfwProp, - Name = nameProp, - Version = versionProp, - }; - } - - public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.DownloadStates.VectorPlexus value, - JsonSerializerOptions options) - { - writer.WriteStartObject(); - writer.WriteString("$type", "VectorPlexusOAuthDownloader+State, Wabbajack.Lib"); - writer.WritePropertyName("Author"); - JsonSerializer.Serialize(writer, value.Author, options); - writer.WritePropertyName("Description"); - JsonSerializer.Serialize(writer, value.Description, options); - writer.WritePropertyName("ImageURL"); - JsonSerializer.Serialize(writer, value.ImageURL, options); - writer.WritePropertyName("IPS4File"); - JsonSerializer.Serialize(writer, value.IPS4File, options); - writer.WritePropertyName("IPS4Mod"); - JsonSerializer.Serialize(writer, value.IPS4Mod, options); - writer.WritePropertyName("IPS4Url"); - JsonSerializer.Serialize(writer, value.IPS4Url, options); - writer.WritePropertyName("IsAttachment"); - JsonSerializer.Serialize(writer, value.IsAttachment, options); - writer.WritePropertyName("IsNSFW"); - JsonSerializer.Serialize(writer, value.IsNSFW, options); - writer.WritePropertyName("Name"); - JsonSerializer.Serialize(writer, value.Name, options); - writer.WritePropertyName("Version"); - JsonSerializer.Serialize(writer, value.Version, options); - writer.WriteEndObject(); - } -} - -public class - Wabbajack_DTOs_DownloadStates_WabbajackCDNConverter : JsonConverter -{ - public override Wabbajack.DTOs.DownloadStates.WabbajackCDN Read(ref Utf8JsonReader reader, Type typeToConvert, - JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException(); - System.Uri urlProp = default; - while (true) - { - reader.Read(); - if (reader.TokenType == JsonTokenType.EndObject) - { - reader.Read(); - break; - } - - var prop = reader.GetString(); - reader.Read(); - switch (prop) - { - case "Url": - urlProp = JsonSerializer.Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - return new Wabbajack.DTOs.DownloadStates.WabbajackCDN - { - Url = urlProp, - }; - } - - public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.DownloadStates.WabbajackCDN value, - JsonSerializerOptions options) - { - writer.WriteStartObject(); - writer.WriteString("$type", "WabbajackCDNDownloader+State, Wabbajack.Lib"); - writer.WritePropertyName("Url"); - JsonSerializer.Serialize(writer, value.Url, options); - writer.WriteEndObject(); - } -} - -public class - Wabbajack_DTOs_BSA_ArchiveStates_IArchiveConverter : JsonConverter -{ - public static void ConfigureServices(IServiceCollection services) - { - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - } - - public override Wabbajack.DTOs.BSA.ArchiveStates.IArchive Read(ref Utf8JsonReader reader, Type typeToConvert, - JsonSerializerOptions options) - { - var cReader = reader; - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException(); - cReader.Read(); - if (cReader.GetString() != "$type") - throw new JsonException(); - cReader.Read(); - var type = cReader.GetString(); - switch (type) - { - case "BA2State, Compression.BSA": - return JsonSerializer.Deserialize(ref reader, options)!; - case "BA2State": - return JsonSerializer.Deserialize(ref reader, options)!; - case "BSAState, Compression.BSA": - return JsonSerializer.Deserialize(ref reader, options)!; - case "BSAState": - return JsonSerializer.Deserialize(ref reader, options)!; - case "TES3State": - return JsonSerializer.Deserialize(ref reader, options)!; - case "TES3State, Compression.BSA": - return JsonSerializer.Deserialize(ref reader, options)!; - default: - throw new JsonException($"No Type dispatch for {type}"); - } - } - - public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.BSA.ArchiveStates.IArchive value, - JsonSerializerOptions options) - { - switch (value) - { - case Wabbajack.DTOs.BSA.ArchiveStates.BA2State v0: - JsonSerializer.Serialize(writer, v0, options); - return; - case Wabbajack.DTOs.BSA.ArchiveStates.BSAState v1: - JsonSerializer.Serialize(writer, v1, options); - return; - case Wabbajack.DTOs.BSA.ArchiveStates.TES3State v2: - JsonSerializer.Serialize(writer, v2, options); - return; - } - } -} - -public class - Wabbajack_DTOs_BSA_ArchiveStates_BA2StateConverter : JsonConverter -{ - public override Wabbajack.DTOs.BSA.ArchiveStates.BA2State Read(ref Utf8JsonReader reader, Type typeToConvert, - JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException(); - System.Boolean hasnametableProp = default; - System.String headermagicProp = default; - Wabbajack.DTOs.BSA.ArchiveStates.BA2EntryType typeProp = default; - System.UInt32 versionProp = default; - while (true) - { - reader.Read(); - if (reader.TokenType == JsonTokenType.EndObject) - { - reader.Read(); - break; - } - - var prop = reader.GetString(); - reader.Read(); - switch (prop) - { - case "HasNameTable": - hasnametableProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "HeaderMagic": - headermagicProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "Type": - typeProp = JsonSerializer.Deserialize(ref reader, - options); - break; - case "Version": - versionProp = JsonSerializer.Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - return new Wabbajack.DTOs.BSA.ArchiveStates.BA2State - { - HasNameTable = hasnametableProp, - HeaderMagic = headermagicProp, - Type = typeProp, - Version = versionProp, - }; - } - - public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.BSA.ArchiveStates.BA2State value, - JsonSerializerOptions options) - { - writer.WriteStartObject(); - writer.WriteString("$type", "BA2State, Compression.BSA"); - writer.WritePropertyName("HasNameTable"); - JsonSerializer.Serialize(writer, value.HasNameTable, options); - writer.WritePropertyName("HeaderMagic"); - JsonSerializer.Serialize(writer, value.HeaderMagic, options); - writer.WritePropertyName("Type"); - JsonSerializer.Serialize(writer, value.Type, options); - writer.WritePropertyName("Version"); - JsonSerializer.Serialize(writer, value.Version, options); - writer.WriteEndObject(); - } -} - -public class - Wabbajack_DTOs_BSA_ArchiveStates_BSAStateConverter : JsonConverter -{ - public override Wabbajack.DTOs.BSA.ArchiveStates.BSAState Read(ref Utf8JsonReader reader, Type typeToConvert, - JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException(); - System.UInt32 archiveflagsProp = default; - System.UInt32 fileflagsProp = default; - System.String magicProp = default; - System.UInt32 versionProp = default; - while (true) - { - reader.Read(); - if (reader.TokenType == JsonTokenType.EndObject) - { - reader.Read(); - break; - } - - var prop = reader.GetString(); - reader.Read(); - switch (prop) - { - case "ArchiveFlags": - archiveflagsProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "FileFlags": - fileflagsProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "Magic": - magicProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "Version": - versionProp = JsonSerializer.Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - return new Wabbajack.DTOs.BSA.ArchiveStates.BSAState - { - ArchiveFlags = archiveflagsProp, - FileFlags = fileflagsProp, - Magic = magicProp, - Version = versionProp, - }; - } - - public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.BSA.ArchiveStates.BSAState value, - JsonSerializerOptions options) - { - writer.WriteStartObject(); - writer.WriteString("$type", "BSAState, Compression.BSA"); - writer.WritePropertyName("ArchiveFlags"); - JsonSerializer.Serialize(writer, value.ArchiveFlags, options); - writer.WritePropertyName("FileFlags"); - JsonSerializer.Serialize(writer, value.FileFlags, options); - writer.WritePropertyName("Magic"); - JsonSerializer.Serialize(writer, value.Magic, options); - writer.WritePropertyName("Version"); - JsonSerializer.Serialize(writer, value.Version, options); - writer.WriteEndObject(); - } -} - -public class - Wabbajack_DTOs_BSA_ArchiveStates_TES3StateConverter : JsonConverter -{ - public override Wabbajack.DTOs.BSA.ArchiveStates.TES3State Read(ref Utf8JsonReader reader, Type typeToConvert, - JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException(); - System.Int64 dataoffsetProp = default; - System.UInt32 filecountProp = default; - System.UInt32 hashoffsetProp = default; - System.UInt32 versionnumberProp = default; - while (true) - { - reader.Read(); - if (reader.TokenType == JsonTokenType.EndObject) - { - reader.Read(); - break; - } - - var prop = reader.GetString(); - reader.Read(); - switch (prop) - { - case "DataOffset": - dataoffsetProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "FileCount": - filecountProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "HashOffset": - hashoffsetProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "VersionNumber": - versionnumberProp = JsonSerializer.Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - return new Wabbajack.DTOs.BSA.ArchiveStates.TES3State - { - DataOffset = dataoffsetProp, - FileCount = filecountProp, - HashOffset = hashoffsetProp, - VersionNumber = versionnumberProp, - }; - } - - public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.BSA.ArchiveStates.TES3State value, - JsonSerializerOptions options) - { - writer.WriteStartObject(); - writer.WriteString("$type", "TES3State"); - writer.WritePropertyName("DataOffset"); - JsonSerializer.Serialize(writer, value.DataOffset, options); - writer.WritePropertyName("FileCount"); - JsonSerializer.Serialize(writer, value.FileCount, options); - writer.WritePropertyName("HashOffset"); - JsonSerializer.Serialize(writer, value.HashOffset, options); - writer.WritePropertyName("VersionNumber"); - JsonSerializer.Serialize(writer, value.VersionNumber, options); - writer.WriteEndObject(); - } -} - -public class Wabbajack_DTOs_DirectiveConverter : JsonConverter -{ - public static void ConfigureServices(IServiceCollection services) - { - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - } - - public override Wabbajack.DTOs.Directive Read(ref Utf8JsonReader reader, Type typeToConvert, - JsonSerializerOptions options) - { - var cReader = reader; - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException(); - cReader.Read(); - if (cReader.GetString() != "$type") - throw new JsonException(); - cReader.Read(); - var type = cReader.GetString(); - switch (type) - { - case "ArchiveMeta": - return JsonSerializer.Deserialize(ref reader, options)!; - case "ArchiveMeta, Wabbajack.Lib": - return JsonSerializer.Deserialize(ref reader, options)!; - case "CreateBSA": - return JsonSerializer.Deserialize(ref reader, options)!; - case "CreateBSA, Wabbajack.Lib": - return JsonSerializer.Deserialize(ref reader, options)!; - case "FromArchive": - return JsonSerializer.Deserialize(ref reader, options)!; - case "FromArchive, Wabbajack.Lib": - return JsonSerializer.Deserialize(ref reader, options)!; - case "IgnoredDirectly": - return JsonSerializer.Deserialize(ref reader, options)!; - case "InlineFile": - return JsonSerializer.Deserialize(ref reader, options)!; - case "InlineFile, Wabbajack.Lib": - return JsonSerializer.Deserialize(ref reader, options)!; - case "MergedPatch, Wabbajack.Lib": - return JsonSerializer.Deserialize(ref reader, options)!; - case "MergedPatch": - return JsonSerializer.Deserialize(ref reader, options)!; - case "NoMatch": - return JsonSerializer.Deserialize(ref reader, options)!; - case "PatchedFromArchive": - return JsonSerializer.Deserialize(ref reader, options)!; - case "PatchedFromArchive, Wabbajack.Lib": - return JsonSerializer.Deserialize(ref reader, options)!; - case "PropertyFile": - return JsonSerializer.Deserialize(ref reader, options)!; - case "PropertyFile, Wabbajack.Lib": - return JsonSerializer.Deserialize(ref reader, options)!; - case "RemappedInlineFile": - return JsonSerializer.Deserialize(ref reader, options)!; - case "RemappedInlineFile, Wabbajack.Lib": - return JsonSerializer.Deserialize(ref reader, options)!; - case "TransformedTexture": - return JsonSerializer.Deserialize(ref reader, options)!; - case "TransformedTexture, Wabbajack.Lib": - return JsonSerializer.Deserialize(ref reader, options)!; - default: - throw new JsonException($"No Type dispatch for {type}"); - } - } - - public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.Directive value, JsonSerializerOptions options) - { - switch (value) - { - case Wabbajack.DTOs.Directives.NoMatch v0: - JsonSerializer.Serialize(writer, v0, options); - return; - case Wabbajack.DTOs.Directives.PatchedFromArchive v1: - JsonSerializer.Serialize(writer, v1, options); - return; - case Wabbajack.DTOs.Directives.PropertyFile v2: - JsonSerializer.Serialize(writer, v2, options); - return; - case Wabbajack.DTOs.Directives.RemappedInlineFile v3: - JsonSerializer.Serialize(writer, v3, options); - return; - case Wabbajack.DTOs.Directives.TransformedTexture v4: - JsonSerializer.Serialize(writer, v4, options); - return; - case Wabbajack.DTOs.Directives.ArchiveMeta v5: - JsonSerializer.Serialize(writer, v5, options); - return; - case Wabbajack.DTOs.Directives.CreateBSA v6: - JsonSerializer.Serialize(writer, v6, options); - return; - case Wabbajack.DTOs.Directives.FromArchive v7: - JsonSerializer.Serialize(writer, v7, options); - return; - case Wabbajack.DTOs.Directives.IgnoredDirectly v8: - JsonSerializer.Serialize(writer, v8, options); - return; - case Wabbajack.DTOs.Directives.InlineFile v9: - JsonSerializer.Serialize(writer, v9, options); - return; - case Wabbajack.DTOs.Directives.MergedPatch v10: - JsonSerializer.Serialize(writer, v10, options); - return; - } - } -} - -public class Wabbajack_DTOs_Directives_ArchiveMetaConverter : JsonConverter -{ - public override Wabbajack.DTOs.Directives.ArchiveMeta Read(ref Utf8JsonReader reader, Type typeToConvert, - JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException(); - Wabbajack.Hashing.xxHash64.Hash hashProp = default; - System.Int64 sizeProp = default; - Wabbajack.Paths.RelativePath sourcedataidProp = default; - Wabbajack.Paths.RelativePath toProp = default; - while (true) - { - reader.Read(); - if (reader.TokenType == JsonTokenType.EndObject) - { - reader.Read(); - break; - } - - var prop = reader.GetString(); - reader.Read(); - switch (prop) - { - case "Hash": - hashProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "Size": - sizeProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "SourceDataID": - sourcedataidProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "To": - toProp = JsonSerializer.Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - return new Wabbajack.DTOs.Directives.ArchiveMeta - { - Hash = hashProp, - Size = sizeProp, - SourceDataID = sourcedataidProp, - To = toProp, - }; - } - - public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.Directives.ArchiveMeta value, - JsonSerializerOptions options) - { - writer.WriteStartObject(); - writer.WriteString("$type", "ArchiveMeta"); - writer.WritePropertyName("Hash"); - JsonSerializer.Serialize(writer, value.Hash, options); - writer.WritePropertyName("Size"); - JsonSerializer.Serialize(writer, value.Size, options); - writer.WritePropertyName("SourceDataID"); - JsonSerializer.Serialize(writer, value.SourceDataID, options); - writer.WritePropertyName("To"); - JsonSerializer.Serialize(writer, value.To, options); - writer.WriteEndObject(); - } -} - -public class Wabbajack_DTOs_Directives_CreateBSAConverter : JsonConverter -{ - public override Wabbajack.DTOs.Directives.CreateBSA Read(ref Utf8JsonReader reader, Type typeToConvert, - JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException(); - Wabbajack.DTOs.BSA.FileStates.AFile[] filestatesProp = default; - Wabbajack.Hashing.xxHash64.Hash hashProp = default; - System.Int64 sizeProp = default; - Wabbajack.DTOs.BSA.ArchiveStates.IArchive stateProp = default; - Wabbajack.Paths.RelativePath tempidProp = default; - Wabbajack.Paths.RelativePath toProp = default; - while (true) - { - reader.Read(); - if (reader.TokenType == JsonTokenType.EndObject) - { - reader.Read(); - break; - } - - var prop = reader.GetString(); - reader.Read(); - switch (prop) - { - case "FileStates": - filestatesProp = - JsonSerializer.Deserialize(ref reader, options); - break; - case "Hash": - hashProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "Size": - sizeProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "State": - stateProp = JsonSerializer.Deserialize(ref reader, - options); - break; - case "TempID": - tempidProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "To": - toProp = JsonSerializer.Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - return new Wabbajack.DTOs.Directives.CreateBSA - { - FileStates = filestatesProp, - Hash = hashProp, - Size = sizeProp, - State = stateProp, - TempID = tempidProp, - To = toProp, - }; - } - - public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.Directives.CreateBSA value, - JsonSerializerOptions options) - { - writer.WriteStartObject(); - writer.WriteString("$type", "CreateBSA"); - writer.WritePropertyName("FileStates"); - JsonSerializer.Serialize(writer, value.FileStates, options); - writer.WritePropertyName("Hash"); - JsonSerializer.Serialize(writer, value.Hash, options); - writer.WritePropertyName("Size"); - JsonSerializer.Serialize(writer, value.Size, options); - writer.WritePropertyName("State"); - JsonSerializer.Serialize(writer, value.State, options); - writer.WritePropertyName("TempID"); - JsonSerializer.Serialize(writer, value.TempID, options); - writer.WritePropertyName("To"); - JsonSerializer.Serialize(writer, value.To, options); - writer.WriteEndObject(); - } -} - -public class Wabbajack_DTOs_Directives_FromArchiveConverter : JsonConverter -{ - public override Wabbajack.DTOs.Directives.FromArchive Read(ref Utf8JsonReader reader, Type typeToConvert, - JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException(); - Wabbajack.Hashing.xxHash64.HashRelativePath archivehashpathProp = default; - Wabbajack.Hashing.xxHash64.Hash hashProp = default; - System.Int64 sizeProp = default; - Wabbajack.Paths.RelativePath toProp = default; - while (true) - { - reader.Read(); - if (reader.TokenType == JsonTokenType.EndObject) - { - reader.Read(); - break; - } - - var prop = reader.GetString(); - reader.Read(); - switch (prop) - { - case "ArchiveHashPath": - archivehashpathProp = - JsonSerializer.Deserialize(ref reader, options); - break; - case "Hash": - hashProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "Size": - sizeProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "To": - toProp = JsonSerializer.Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - return new Wabbajack.DTOs.Directives.FromArchive - { - ArchiveHashPath = archivehashpathProp, - Hash = hashProp, - Size = sizeProp, - To = toProp, - }; - } - - public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.Directives.FromArchive value, - JsonSerializerOptions options) - { - writer.WriteStartObject(); - writer.WriteString("$type", "FromArchive"); - writer.WritePropertyName("ArchiveHashPath"); - JsonSerializer.Serialize(writer, value.ArchiveHashPath, options); - writer.WritePropertyName("Hash"); - JsonSerializer.Serialize(writer, value.Hash, options); - writer.WritePropertyName("Size"); - JsonSerializer.Serialize(writer, value.Size, options); - writer.WritePropertyName("To"); - JsonSerializer.Serialize(writer, value.To, options); - writer.WriteEndObject(); - } -} - -public class - Wabbajack_DTOs_Directives_IgnoredDirectlyConverter : JsonConverter -{ - public override Wabbajack.DTOs.Directives.IgnoredDirectly Read(ref Utf8JsonReader reader, Type typeToConvert, - JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException(); - Wabbajack.Hashing.xxHash64.Hash hashProp = default; - System.Int64 sizeProp = default; - Wabbajack.Paths.RelativePath toProp = default; - while (true) - { - reader.Read(); - if (reader.TokenType == JsonTokenType.EndObject) - { - reader.Read(); - break; - } - - var prop = reader.GetString(); - reader.Read(); - switch (prop) - { - case "Hash": - hashProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "Size": - sizeProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "To": - toProp = JsonSerializer.Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - return new Wabbajack.DTOs.Directives.IgnoredDirectly - { - Hash = hashProp, - Size = sizeProp, - To = toProp, - }; - } - - public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.Directives.IgnoredDirectly value, - JsonSerializerOptions options) - { - writer.WriteStartObject(); - writer.WriteString("$type", "IgnoredDirectly"); - writer.WritePropertyName("Hash"); - JsonSerializer.Serialize(writer, value.Hash, options); - writer.WritePropertyName("Size"); - JsonSerializer.Serialize(writer, value.Size, options); - writer.WritePropertyName("To"); - JsonSerializer.Serialize(writer, value.To, options); - writer.WriteEndObject(); - } -} - -public class Wabbajack_DTOs_Directives_InlineFileConverter : JsonConverter -{ - public override Wabbajack.DTOs.Directives.InlineFile Read(ref Utf8JsonReader reader, Type typeToConvert, - JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException(); - Wabbajack.Hashing.xxHash64.Hash hashProp = default; - System.Int64 sizeProp = default; - Wabbajack.Paths.RelativePath sourcedataidProp = default; - Wabbajack.Paths.RelativePath toProp = default; - while (true) - { - reader.Read(); - if (reader.TokenType == JsonTokenType.EndObject) - { - reader.Read(); - break; - } - - var prop = reader.GetString(); - reader.Read(); - switch (prop) - { - case "Hash": - hashProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "Size": - sizeProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "SourceDataID": - sourcedataidProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "To": - toProp = JsonSerializer.Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - return new Wabbajack.DTOs.Directives.InlineFile - { - Hash = hashProp, - Size = sizeProp, - SourceDataID = sourcedataidProp, - To = toProp, - }; - } - - public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.Directives.InlineFile value, - JsonSerializerOptions options) - { - writer.WriteStartObject(); - writer.WriteString("$type", "InlineFile"); - writer.WritePropertyName("Hash"); - JsonSerializer.Serialize(writer, value.Hash, options); - writer.WritePropertyName("Size"); - JsonSerializer.Serialize(writer, value.Size, options); - writer.WritePropertyName("SourceDataID"); - JsonSerializer.Serialize(writer, value.SourceDataID, options); - writer.WritePropertyName("To"); - JsonSerializer.Serialize(writer, value.To, options); - writer.WriteEndObject(); - } -} - -public class Wabbajack_DTOs_Directives_MergedPatchConverter : JsonConverter -{ - public override Wabbajack.DTOs.Directives.MergedPatch Read(ref Utf8JsonReader reader, Type typeToConvert, - JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException(); - Wabbajack.Hashing.xxHash64.Hash hashProp = default; - Wabbajack.Paths.RelativePath patchidProp = default; - System.Int64 sizeProp = default; - Wabbajack.DTOs.Directives.SourcePatch[] sourcesProp = default; - Wabbajack.Paths.RelativePath toProp = default; - while (true) - { - reader.Read(); - if (reader.TokenType == JsonTokenType.EndObject) - { - reader.Read(); - break; - } - - var prop = reader.GetString(); - reader.Read(); - switch (prop) - { - case "Hash": - hashProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "PatchID": - patchidProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "Size": - sizeProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "Sources": - sourcesProp = - JsonSerializer.Deserialize(ref reader, options); - break; - case "To": - toProp = JsonSerializer.Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - return new Wabbajack.DTOs.Directives.MergedPatch - { - Hash = hashProp, - PatchID = patchidProp, - Size = sizeProp, - Sources = sourcesProp, - To = toProp, - }; - } - - public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.Directives.MergedPatch value, - JsonSerializerOptions options) - { - writer.WriteStartObject(); - writer.WriteString("$type", "MergedPatch, Wabbajack.Lib"); - writer.WritePropertyName("Hash"); - JsonSerializer.Serialize(writer, value.Hash, options); - writer.WritePropertyName("PatchID"); - JsonSerializer.Serialize(writer, value.PatchID, options); - writer.WritePropertyName("Size"); - JsonSerializer.Serialize(writer, value.Size, options); - writer.WritePropertyName("Sources"); - JsonSerializer.Serialize(writer, value.Sources, options); - writer.WritePropertyName("To"); - JsonSerializer.Serialize(writer, value.To, options); - writer.WriteEndObject(); - } -} - -public class Wabbajack_DTOs_Directives_NoMatchConverter : JsonConverter -{ - public override Wabbajack.DTOs.Directives.NoMatch Read(ref Utf8JsonReader reader, Type typeToConvert, - JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException(); - Wabbajack.Hashing.xxHash64.Hash hashProp = default; - System.Int64 sizeProp = default; - Wabbajack.Paths.RelativePath toProp = default; - while (true) - { - reader.Read(); - if (reader.TokenType == JsonTokenType.EndObject) - { - reader.Read(); - break; - } - - var prop = reader.GetString(); - reader.Read(); - switch (prop) - { - case "Hash": - hashProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "Size": - sizeProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "To": - toProp = JsonSerializer.Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - return new Wabbajack.DTOs.Directives.NoMatch - { - Hash = hashProp, - Size = sizeProp, - To = toProp, - }; - } - - public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.Directives.NoMatch value, - JsonSerializerOptions options) - { - writer.WriteStartObject(); - writer.WriteString("$type", "NoMatch"); - writer.WritePropertyName("Hash"); - JsonSerializer.Serialize(writer, value.Hash, options); - writer.WritePropertyName("Size"); - JsonSerializer.Serialize(writer, value.Size, options); - writer.WritePropertyName("To"); - JsonSerializer.Serialize(writer, value.To, options); - writer.WriteEndObject(); - } -} - -public class - Wabbajack_DTOs_Directives_PatchedFromArchiveConverter : JsonConverter -{ - public override Wabbajack.DTOs.Directives.PatchedFromArchive Read(ref Utf8JsonReader reader, Type typeToConvert, - JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException(); - Wabbajack.Hashing.xxHash64.HashRelativePath archivehashpathProp = default; - Wabbajack.Hashing.xxHash64.Hash fromhashProp = default; - Wabbajack.Hashing.xxHash64.Hash hashProp = default; - Wabbajack.Paths.RelativePath patchidProp = default; - System.Int64 sizeProp = default; - Wabbajack.Paths.RelativePath toProp = default; - while (true) - { - reader.Read(); - if (reader.TokenType == JsonTokenType.EndObject) - { - reader.Read(); - break; - } - - var prop = reader.GetString(); - reader.Read(); - switch (prop) - { - case "ArchiveHashPath": - archivehashpathProp = - JsonSerializer.Deserialize(ref reader, options); - break; - case "FromHash": - fromhashProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "Hash": - hashProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "PatchID": - patchidProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "Size": - sizeProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "To": - toProp = JsonSerializer.Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - return new Wabbajack.DTOs.Directives.PatchedFromArchive - { - ArchiveHashPath = archivehashpathProp, - FromHash = fromhashProp, - Hash = hashProp, - PatchID = patchidProp, - Size = sizeProp, - To = toProp, - }; - } - - public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.Directives.PatchedFromArchive value, - JsonSerializerOptions options) - { - writer.WriteStartObject(); - writer.WriteString("$type", "PatchedFromArchive"); - writer.WritePropertyName("ArchiveHashPath"); - JsonSerializer.Serialize(writer, value.ArchiveHashPath, options); - writer.WritePropertyName("FromHash"); - JsonSerializer.Serialize(writer, value.FromHash, options); - writer.WritePropertyName("Hash"); - JsonSerializer.Serialize(writer, value.Hash, options); - writer.WritePropertyName("PatchID"); - JsonSerializer.Serialize(writer, value.PatchID, options); - writer.WritePropertyName("Size"); - JsonSerializer.Serialize(writer, value.Size, options); - writer.WritePropertyName("To"); - JsonSerializer.Serialize(writer, value.To, options); - writer.WriteEndObject(); - } -} - -public class Wabbajack_DTOs_Directives_PropertyFileConverter : JsonConverter -{ - public override Wabbajack.DTOs.Directives.PropertyFile Read(ref Utf8JsonReader reader, Type typeToConvert, - JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException(); - Wabbajack.Hashing.xxHash64.Hash hashProp = default; - System.Int64 sizeProp = default; - Wabbajack.Paths.RelativePath sourcedataidProp = default; - Wabbajack.Paths.RelativePath toProp = default; - while (true) - { - reader.Read(); - if (reader.TokenType == JsonTokenType.EndObject) - { - reader.Read(); - break; - } - - var prop = reader.GetString(); - reader.Read(); - switch (prop) - { - case "Hash": - hashProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "Size": - sizeProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "SourceDataID": - sourcedataidProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "To": - toProp = JsonSerializer.Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - return new Wabbajack.DTOs.Directives.PropertyFile - { - Hash = hashProp, - Size = sizeProp, - SourceDataID = sourcedataidProp, - To = toProp, - }; - } - - public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.Directives.PropertyFile value, - JsonSerializerOptions options) - { - writer.WriteStartObject(); - writer.WriteString("$type", "PropertyFile"); - writer.WritePropertyName("Hash"); - JsonSerializer.Serialize(writer, value.Hash, options); - writer.WritePropertyName("Size"); - JsonSerializer.Serialize(writer, value.Size, options); - writer.WritePropertyName("SourceDataID"); - JsonSerializer.Serialize(writer, value.SourceDataID, options); - writer.WritePropertyName("To"); - JsonSerializer.Serialize(writer, value.To, options); - writer.WriteEndObject(); - } -} - -public class - Wabbajack_DTOs_Directives_RemappedInlineFileConverter : JsonConverter -{ - public override Wabbajack.DTOs.Directives.RemappedInlineFile Read(ref Utf8JsonReader reader, Type typeToConvert, - JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException(); - Wabbajack.Hashing.xxHash64.Hash hashProp = default; - System.Int64 sizeProp = default; - Wabbajack.Paths.RelativePath sourcedataidProp = default; - Wabbajack.Paths.RelativePath toProp = default; - while (true) - { - reader.Read(); - if (reader.TokenType == JsonTokenType.EndObject) - { - reader.Read(); - break; - } - - var prop = reader.GetString(); - reader.Read(); - switch (prop) - { - case "Hash": - hashProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "Size": - sizeProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "SourceDataID": - sourcedataidProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "To": - toProp = JsonSerializer.Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - return new Wabbajack.DTOs.Directives.RemappedInlineFile - { - Hash = hashProp, - Size = sizeProp, - SourceDataID = sourcedataidProp, - To = toProp, - }; - } - - public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.Directives.RemappedInlineFile value, - JsonSerializerOptions options) - { - writer.WriteStartObject(); - writer.WriteString("$type", "RemappedInlineFile"); - writer.WritePropertyName("Hash"); - JsonSerializer.Serialize(writer, value.Hash, options); - writer.WritePropertyName("Size"); - JsonSerializer.Serialize(writer, value.Size, options); - writer.WritePropertyName("SourceDataID"); - JsonSerializer.Serialize(writer, value.SourceDataID, options); - writer.WritePropertyName("To"); - JsonSerializer.Serialize(writer, value.To, options); - writer.WriteEndObject(); - } -} - -public class - Wabbajack_DTOs_Directives_TransformedTextureConverter : JsonConverter -{ - public override Wabbajack.DTOs.Directives.TransformedTexture Read(ref Utf8JsonReader reader, Type typeToConvert, - JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException(); - Wabbajack.Hashing.xxHash64.HashRelativePath archivehashpathProp = default; - Wabbajack.Hashing.xxHash64.Hash hashProp = default; - Wabbajack.DTOs.Texture.ImageState imagestateProp = default; - System.Int64 sizeProp = default; - Wabbajack.Paths.RelativePath toProp = default; - while (true) - { - reader.Read(); - if (reader.TokenType == JsonTokenType.EndObject) - { - reader.Read(); - break; - } - - var prop = reader.GetString(); - reader.Read(); - switch (prop) - { - case "ArchiveHashPath": - archivehashpathProp = - JsonSerializer.Deserialize(ref reader, options); - break; - case "Hash": - hashProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "ImageState": - imagestateProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "Size": - sizeProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "To": - toProp = JsonSerializer.Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - return new Wabbajack.DTOs.Directives.TransformedTexture - { - ArchiveHashPath = archivehashpathProp, - Hash = hashProp, - ImageState = imagestateProp, - Size = sizeProp, - To = toProp, - }; - } - - public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.Directives.TransformedTexture value, - JsonSerializerOptions options) - { - writer.WriteStartObject(); - writer.WriteString("$type", "TransformedTexture"); - writer.WritePropertyName("ArchiveHashPath"); - JsonSerializer.Serialize(writer, value.ArchiveHashPath, options); - writer.WritePropertyName("Hash"); - JsonSerializer.Serialize(writer, value.Hash, options); - writer.WritePropertyName("ImageState"); - JsonSerializer.Serialize(writer, value.ImageState, options); - writer.WritePropertyName("Size"); - JsonSerializer.Serialize(writer, value.Size, options); - writer.WritePropertyName("To"); - JsonSerializer.Serialize(writer, value.To, options); - writer.WriteEndObject(); - } -} - -public class Wabbajack_DTOs_BSA_FileStates_AFileConverter : JsonConverter -{ - public static void ConfigureServices(IServiceCollection services) - { - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - } - - public override Wabbajack.DTOs.BSA.FileStates.AFile Read(ref Utf8JsonReader reader, Type typeToConvert, - JsonSerializerOptions options) - { - var cReader = reader; - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException(); - cReader.Read(); - if (cReader.GetString() != "$type") - throw new JsonException(); - cReader.Read(); - var type = cReader.GetString(); - switch (type) - { - case "BA2DX10Entry": - return JsonSerializer.Deserialize(ref reader, options)!; - case "BA2DX10Entry, Compression.BSA": - return JsonSerializer.Deserialize(ref reader, options)!; - case "BA2File": - return JsonSerializer.Deserialize(ref reader, options)!; - case "BA2FileEntryState, Compression.BSA": - return JsonSerializer.Deserialize(ref reader, options)!; - case "BSAFileState, Compression.BSA": - return JsonSerializer.Deserialize(ref reader, options)!; - case "BSAFile": - return JsonSerializer.Deserialize(ref reader, options)!; - case "TES3File": - return JsonSerializer.Deserialize(ref reader, options)!; - default: - throw new JsonException($"No Type dispatch for {type}"); - } - } - - public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.BSA.FileStates.AFile value, - JsonSerializerOptions options) - { - switch (value) - { - case Wabbajack.DTOs.BSA.FileStates.BA2DX10File v0: - JsonSerializer.Serialize(writer, v0, options); - return; - case Wabbajack.DTOs.BSA.FileStates.BA2File v1: - JsonSerializer.Serialize(writer, v1, options); - return; - case Wabbajack.DTOs.BSA.FileStates.BSAFile v2: - JsonSerializer.Serialize(writer, v2, options); - return; - case Wabbajack.DTOs.BSA.FileStates.TES3File v3: - JsonSerializer.Serialize(writer, v3, options); - return; - } - } -} - -public class - Wabbajack_DTOs_BSA_FileStates_BA2DX10FileConverter : JsonConverter -{ - public override Wabbajack.DTOs.BSA.FileStates.BA2DX10File Read(ref Utf8JsonReader reader, Type typeToConvert, - JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException(); - System.UInt16 chunkhdrlenProp = default; - Wabbajack.DTOs.BSA.FileStates.BA2Chunk[] chunksProp = default; - System.UInt32 dirhashProp = default; - System.String extensionProp = default; - System.UInt16 heightProp = default; - System.Int32 indexProp = default; - System.Byte iscubemapProp = default; - System.UInt32 namehashProp = default; - System.Byte nummipsProp = default; - Wabbajack.Paths.RelativePath pathProp = default; - System.Byte pixelformatProp = default; - System.Byte tilemodeProp = default; - System.Byte unk8Prop = default; - System.UInt16 widthProp = default; - while (true) - { - reader.Read(); - if (reader.TokenType == JsonTokenType.EndObject) - { - reader.Read(); - break; - } - - var prop = reader.GetString(); - reader.Read(); - switch (prop) - { - case "ChunkHdrLen": - chunkhdrlenProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "Chunks": - chunksProp = - JsonSerializer.Deserialize(ref reader, options); - break; - case "DirHash": - dirhashProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "Extension": - extensionProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "Height": - heightProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "Index": - indexProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "IsCubeMap": - iscubemapProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "NameHash": - namehashProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "NumMips": - nummipsProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "Path": - pathProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "PixelFormat": - pixelformatProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "TileMode": - tilemodeProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "Unk8": - unk8Prop = JsonSerializer.Deserialize(ref reader, options); - break; - case "Width": - widthProp = JsonSerializer.Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - return new Wabbajack.DTOs.BSA.FileStates.BA2DX10File - { - ChunkHdrLen = chunkhdrlenProp, - Chunks = chunksProp, - DirHash = dirhashProp, - Extension = extensionProp, - Height = heightProp, - Index = indexProp, - IsCubeMap = iscubemapProp, - NameHash = namehashProp, - NumMips = nummipsProp, - Path = pathProp, - PixelFormat = pixelformatProp, - TileMode = tilemodeProp, - Unk8 = unk8Prop, - Width = widthProp, - }; - } - - public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.BSA.FileStates.BA2DX10File value, - JsonSerializerOptions options) - { - writer.WriteStartObject(); - writer.WriteString("$type", "BA2DX10Entry"); - writer.WritePropertyName("ChunkHdrLen"); - JsonSerializer.Serialize(writer, value.ChunkHdrLen, options); - writer.WritePropertyName("Chunks"); - JsonSerializer.Serialize(writer, value.Chunks, options); - writer.WritePropertyName("DirHash"); - JsonSerializer.Serialize(writer, value.DirHash, options); - writer.WritePropertyName("Extension"); - JsonSerializer.Serialize(writer, value.Extension, options); - writer.WritePropertyName("Height"); - JsonSerializer.Serialize(writer, value.Height, options); - writer.WritePropertyName("Index"); - JsonSerializer.Serialize(writer, value.Index, options); - writer.WritePropertyName("IsCubeMap"); - JsonSerializer.Serialize(writer, value.IsCubeMap, options); - writer.WritePropertyName("NameHash"); - JsonSerializer.Serialize(writer, value.NameHash, options); - writer.WritePropertyName("NumMips"); - JsonSerializer.Serialize(writer, value.NumMips, options); - writer.WritePropertyName("Path"); - JsonSerializer.Serialize(writer, value.Path, options); - writer.WritePropertyName("PixelFormat"); - JsonSerializer.Serialize(writer, value.PixelFormat, options); - writer.WritePropertyName("TileMode"); - JsonSerializer.Serialize(writer, value.TileMode, options); - writer.WritePropertyName("Unk8"); - JsonSerializer.Serialize(writer, value.Unk8, options); - writer.WritePropertyName("Width"); - JsonSerializer.Serialize(writer, value.Width, options); - writer.WriteEndObject(); - } -} - -public class Wabbajack_DTOs_BSA_FileStates_BA2FileConverter : JsonConverter -{ - public override Wabbajack.DTOs.BSA.FileStates.BA2File Read(ref Utf8JsonReader reader, Type typeToConvert, - JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException(); - System.UInt32 alignProp = default; - System.Boolean compressedProp = default; - System.UInt32 dirhashProp = default; - System.String extensionProp = default; - System.UInt32 flagsProp = default; - System.Int32 indexProp = default; - System.UInt32 namehashProp = default; - Wabbajack.Paths.RelativePath pathProp = default; - while (true) - { - reader.Read(); - if (reader.TokenType == JsonTokenType.EndObject) - { - reader.Read(); - break; - } - - var prop = reader.GetString(); - reader.Read(); - switch (prop) - { - case "Align": - alignProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "Compressed": - compressedProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "DirHash": - dirhashProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "Extension": - extensionProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "Flags": - flagsProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "Index": - indexProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "NameHash": - namehashProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "Path": - pathProp = JsonSerializer.Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - return new Wabbajack.DTOs.BSA.FileStates.BA2File - { - Align = alignProp, - Compressed = compressedProp, - DirHash = dirhashProp, - Extension = extensionProp, - Flags = flagsProp, - Index = indexProp, - NameHash = namehashProp, - Path = pathProp, - }; - } - - public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.BSA.FileStates.BA2File value, - JsonSerializerOptions options) - { - writer.WriteStartObject(); - writer.WriteString("$type", "BA2File"); - writer.WritePropertyName("Align"); - JsonSerializer.Serialize(writer, value.Align, options); - writer.WritePropertyName("Compressed"); - JsonSerializer.Serialize(writer, value.Compressed, options); - writer.WritePropertyName("DirHash"); - JsonSerializer.Serialize(writer, value.DirHash, options); - writer.WritePropertyName("Extension"); - JsonSerializer.Serialize(writer, value.Extension, options); - writer.WritePropertyName("Flags"); - JsonSerializer.Serialize(writer, value.Flags, options); - writer.WritePropertyName("Index"); - JsonSerializer.Serialize(writer, value.Index, options); - writer.WritePropertyName("NameHash"); - JsonSerializer.Serialize(writer, value.NameHash, options); - writer.WritePropertyName("Path"); - JsonSerializer.Serialize(writer, value.Path, options); - writer.WriteEndObject(); - } -} - -public class Wabbajack_DTOs_BSA_FileStates_BSAFileConverter : JsonConverter -{ - public override Wabbajack.DTOs.BSA.FileStates.BSAFile Read(ref Utf8JsonReader reader, Type typeToConvert, - JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException(); - System.Boolean flipcompressionProp = default; - System.Int32 indexProp = default; - Wabbajack.Paths.RelativePath pathProp = default; - while (true) - { - reader.Read(); - if (reader.TokenType == JsonTokenType.EndObject) - { - reader.Read(); - break; - } - - var prop = reader.GetString(); - reader.Read(); - switch (prop) - { - case "FlipCompression": - flipcompressionProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "Index": - indexProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "Path": - pathProp = JsonSerializer.Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - return new Wabbajack.DTOs.BSA.FileStates.BSAFile - { - FlipCompression = flipcompressionProp, - Index = indexProp, - Path = pathProp, - }; - } - - public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.BSA.FileStates.BSAFile value, - JsonSerializerOptions options) - { - writer.WriteStartObject(); - writer.WriteString("$type", "BSAFileState, Compression.BSA"); - writer.WritePropertyName("FlipCompression"); - JsonSerializer.Serialize(writer, value.FlipCompression, options); - writer.WritePropertyName("Index"); - JsonSerializer.Serialize(writer, value.Index, options); - writer.WritePropertyName("Path"); - JsonSerializer.Serialize(writer, value.Path, options); - writer.WriteEndObject(); - } -} - -public class Wabbajack_DTOs_BSA_FileStates_TES3FileConverter : JsonConverter -{ - public override Wabbajack.DTOs.BSA.FileStates.TES3File Read(ref Utf8JsonReader reader, Type typeToConvert, - JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException(); - System.UInt32 hash1Prop = default; - System.UInt32 hash2Prop = default; - System.Int32 indexProp = default; - System.UInt32 nameoffsetProp = default; - System.UInt32 offsetProp = default; - Wabbajack.Paths.RelativePath pathProp = default; - System.UInt32 sizeProp = default; - while (true) - { - reader.Read(); - if (reader.TokenType == JsonTokenType.EndObject) - { - reader.Read(); - break; - } - - var prop = reader.GetString(); - reader.Read(); - switch (prop) - { - case "Hash1": - hash1Prop = JsonSerializer.Deserialize(ref reader, options); - break; - case "Hash2": - hash2Prop = JsonSerializer.Deserialize(ref reader, options); - break; - case "Index": - indexProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "NameOffset": - nameoffsetProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "Offset": - offsetProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "Path": - pathProp = JsonSerializer.Deserialize(ref reader, options); - break; - case "Size": - sizeProp = JsonSerializer.Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - return new Wabbajack.DTOs.BSA.FileStates.TES3File - { - Hash1 = hash1Prop, - Hash2 = hash2Prop, - Index = indexProp, - NameOffset = nameoffsetProp, - Offset = offsetProp, - Path = pathProp, - Size = sizeProp, - }; - } - - public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.BSA.FileStates.TES3File value, - JsonSerializerOptions options) - { - writer.WriteStartObject(); - writer.WriteString("$type", "TES3File"); - writer.WritePropertyName("Hash1"); - JsonSerializer.Serialize(writer, value.Hash1, options); - writer.WritePropertyName("Hash2"); - JsonSerializer.Serialize(writer, value.Hash2, options); - writer.WritePropertyName("Index"); - JsonSerializer.Serialize(writer, value.Index, options); - writer.WritePropertyName("NameOffset"); - JsonSerializer.Serialize(writer, value.NameOffset, options); - writer.WritePropertyName("Offset"); - JsonSerializer.Serialize(writer, value.Offset, options); - writer.WritePropertyName("Path"); - JsonSerializer.Serialize(writer, value.Path, options); - writer.WritePropertyName("Size"); - JsonSerializer.Serialize(writer, value.Size, options); - writer.WriteEndObject(); - } -} \ No newline at end of file + public class Wabbajack_DTOs_DownloadStates_ManualConverter : JsonConverter { + public override Wabbajack.DTOs.DownloadStates.Manual Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + System.String promptProp = default; + System.Uri urlProp = default; + while (true) { + reader.Read(); + if (reader.TokenType == JsonTokenType.EndObject) { + reader.Read(); + break; + } + var prop = reader.GetString(); + reader.Read(); + switch (prop) { + case "Prompt": + promptProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Url": + urlProp = JsonSerializer.Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + return new Wabbajack.DTOs.DownloadStates.Manual { + Prompt = promptProp, + Url = urlProp, + }; + } + public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.DownloadStates.Manual value, JsonSerializerOptions options) { + writer.WriteStartObject(); + writer.WriteString("$type", "ManualDownloader, Wabbajack.Lib"); + writer.WritePropertyName("Prompt"); + JsonSerializer.Serialize(writer, value.Prompt, options); + writer.WritePropertyName("Url"); + JsonSerializer.Serialize(writer, value.Url, options); + writer.WriteEndObject(); + } + } + public class Wabbajack_DTOs_DownloadStates_MediaFireConverter : JsonConverter { + public override Wabbajack.DTOs.DownloadStates.MediaFire Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + System.Uri urlProp = default; + while (true) { + reader.Read(); + if (reader.TokenType == JsonTokenType.EndObject) { + reader.Read(); + break; + } + var prop = reader.GetString(); + reader.Read(); + switch (prop) { + case "Url": + urlProp = JsonSerializer.Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + return new Wabbajack.DTOs.DownloadStates.MediaFire { + Url = urlProp, + }; + } + public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.DownloadStates.MediaFire value, JsonSerializerOptions options) { + writer.WriteStartObject(); + writer.WriteString("$type", "MediaFireDownloader+State, Wabbajack.Lib"); + writer.WritePropertyName("Url"); + JsonSerializer.Serialize(writer, value.Url, options); + writer.WriteEndObject(); + } + } + public class Wabbajack_DTOs_DownloadStates_MegaConverter : JsonConverter { + public override Wabbajack.DTOs.DownloadStates.Mega Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + System.Uri urlProp = default; + while (true) { + reader.Read(); + if (reader.TokenType == JsonTokenType.EndObject) { + reader.Read(); + break; + } + var prop = reader.GetString(); + reader.Read(); + switch (prop) { + case "Url": + urlProp = JsonSerializer.Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + return new Wabbajack.DTOs.DownloadStates.Mega { + Url = urlProp, + }; + } + public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.DownloadStates.Mega value, JsonSerializerOptions options) { + writer.WriteStartObject(); + writer.WriteString("$type", "MegaDownloader, Wabbajack.Lib"); + writer.WritePropertyName("Url"); + JsonSerializer.Serialize(writer, value.Url, options); + writer.WriteEndObject(); + } + } + public class Wabbajack_DTOs_DownloadStates_ModDBConverter : JsonConverter { + public override Wabbajack.DTOs.DownloadStates.ModDB Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + System.Uri urlProp = default; + while (true) { + reader.Read(); + if (reader.TokenType == JsonTokenType.EndObject) { + reader.Read(); + break; + } + var prop = reader.GetString(); + reader.Read(); + switch (prop) { + case "Url": + urlProp = JsonSerializer.Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + return new Wabbajack.DTOs.DownloadStates.ModDB { + Url = urlProp, + }; + } + public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.DownloadStates.ModDB value, JsonSerializerOptions options) { + writer.WriteStartObject(); + writer.WriteString("$type", "ModDBDownloader, Wabbajack.Lib"); + writer.WritePropertyName("Url"); + JsonSerializer.Serialize(writer, value.Url, options); + writer.WriteEndObject(); + } + } + public class Wabbajack_DTOs_DownloadStates_NexusConverter : JsonConverter { + public override Wabbajack.DTOs.DownloadStates.Nexus Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + System.String authorProp = default; + System.String descriptionProp = default; + System.Int64 fileidProp = default; + Wabbajack.DTOs.Game gamenameProp = default; + System.Uri imageurlProp = default; + System.Boolean isnsfwProp = default; + System.Int64 modidProp = default; + System.String nameProp = default; + System.String versionProp = default; + while (true) { + reader.Read(); + if (reader.TokenType == JsonTokenType.EndObject) { + reader.Read(); + break; + } + var prop = reader.GetString(); + reader.Read(); + switch (prop) { + case "Author": + authorProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Description": + descriptionProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "FileID": + fileidProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "GameName": + gamenameProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "ImageURL": + imageurlProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "IsNSFW": + isnsfwProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "ModID": + modidProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Name": + nameProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Version": + versionProp = JsonSerializer.Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + return new Wabbajack.DTOs.DownloadStates.Nexus { + Author = authorProp, + Description = descriptionProp, + FileID = fileidProp, + Game = gamenameProp, + ImageURL = imageurlProp, + IsNSFW = isnsfwProp, + ModID = modidProp, + Name = nameProp, + Version = versionProp, + }; + } + public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.DownloadStates.Nexus value, JsonSerializerOptions options) { + writer.WriteStartObject(); + writer.WriteString("$type", "NexusDownloader, Wabbajack.Lib"); + writer.WritePropertyName("Author"); + JsonSerializer.Serialize(writer, value.Author, options); + writer.WritePropertyName("Description"); + JsonSerializer.Serialize(writer, value.Description, options); + writer.WritePropertyName("FileID"); + JsonSerializer.Serialize(writer, value.FileID, options); + writer.WritePropertyName("GameName"); + JsonSerializer.Serialize(writer, value.Game, options); + writer.WritePropertyName("ImageURL"); + JsonSerializer.Serialize(writer, value.ImageURL, options); + writer.WritePropertyName("IsNSFW"); + JsonSerializer.Serialize(writer, value.IsNSFW, options); + writer.WritePropertyName("ModID"); + JsonSerializer.Serialize(writer, value.ModID, options); + writer.WritePropertyName("Name"); + JsonSerializer.Serialize(writer, value.Name, options); + writer.WritePropertyName("Version"); + JsonSerializer.Serialize(writer, value.Version, options); + writer.WriteEndObject(); + } + } + public class Wabbajack_DTOs_DownloadStates_TESAllianceConverter : JsonConverter { + public override Wabbajack.DTOs.DownloadStates.TESAlliance Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + System.String fileidProp = default; + System.String filenameProp = default; + System.Uri fullurlProp = default; + System.Boolean isattachmentProp = default; + while (true) { + reader.Read(); + if (reader.TokenType == JsonTokenType.EndObject) { + reader.Read(); + break; + } + var prop = reader.GetString(); + reader.Read(); + switch (prop) { + case "FileID": + fileidProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "FileName": + filenameProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "FullURL": + fullurlProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "IsAttachment": + isattachmentProp = JsonSerializer.Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + return new Wabbajack.DTOs.DownloadStates.TESAlliance { + FileID = fileidProp, + FileName = filenameProp, + FullURL = fullurlProp, + IsAttachment = isattachmentProp, + }; + } + public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.DownloadStates.TESAlliance value, JsonSerializerOptions options) { + writer.WriteStartObject(); + writer.WriteString("$type", "TESAllianceDownloader, Wabbajack.Lib"); + writer.WritePropertyName("FileID"); + JsonSerializer.Serialize(writer, value.FileID, options); + writer.WritePropertyName("FileName"); + JsonSerializer.Serialize(writer, value.FileName, options); + writer.WritePropertyName("FullURL"); + JsonSerializer.Serialize(writer, value.FullURL, options); + writer.WritePropertyName("IsAttachment"); + JsonSerializer.Serialize(writer, value.IsAttachment, options); + writer.WriteEndObject(); + } + } + public class Wabbajack_DTOs_DownloadStates_VectorPlexusConverter : JsonConverter { + public override Wabbajack.DTOs.DownloadStates.VectorPlexus Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + System.String authorProp = default; + System.String descriptionProp = default; + System.Uri imageurlProp = default; + System.String ips4fileProp = default; + System.Int64 ips4modProp = default; + System.String ips4urlProp = default; + System.Boolean isattachmentProp = default; + System.Boolean isnsfwProp = default; + System.String nameProp = default; + System.String versionProp = default; + while (true) { + reader.Read(); + if (reader.TokenType == JsonTokenType.EndObject) { + reader.Read(); + break; + } + var prop = reader.GetString(); + reader.Read(); + switch (prop) { + case "Author": + authorProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Description": + descriptionProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "ImageURL": + imageurlProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "IPS4File": + ips4fileProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "IPS4Mod": + ips4modProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "IPS4Url": + ips4urlProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "IsAttachment": + isattachmentProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "IsNSFW": + isnsfwProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Name": + nameProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Version": + versionProp = JsonSerializer.Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + return new Wabbajack.DTOs.DownloadStates.VectorPlexus { + Author = authorProp, + Description = descriptionProp, + ImageURL = imageurlProp, + IPS4File = ips4fileProp, + IPS4Mod = ips4modProp, + IPS4Url = ips4urlProp, + IsAttachment = isattachmentProp, + IsNSFW = isnsfwProp, + Name = nameProp, + Version = versionProp, + }; + } + public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.DownloadStates.VectorPlexus value, JsonSerializerOptions options) { + writer.WriteStartObject(); + writer.WriteString("$type", "VectorPlexusOAuthDownloader+State, Wabbajack.Lib"); + writer.WritePropertyName("Author"); + JsonSerializer.Serialize(writer, value.Author, options); + writer.WritePropertyName("Description"); + JsonSerializer.Serialize(writer, value.Description, options); + writer.WritePropertyName("ImageURL"); + JsonSerializer.Serialize(writer, value.ImageURL, options); + writer.WritePropertyName("IPS4File"); + JsonSerializer.Serialize(writer, value.IPS4File, options); + writer.WritePropertyName("IPS4Mod"); + JsonSerializer.Serialize(writer, value.IPS4Mod, options); + writer.WritePropertyName("IPS4Url"); + JsonSerializer.Serialize(writer, value.IPS4Url, options); + writer.WritePropertyName("IsAttachment"); + JsonSerializer.Serialize(writer, value.IsAttachment, options); + writer.WritePropertyName("IsNSFW"); + JsonSerializer.Serialize(writer, value.IsNSFW, options); + writer.WritePropertyName("Name"); + JsonSerializer.Serialize(writer, value.Name, options); + writer.WritePropertyName("Version"); + JsonSerializer.Serialize(writer, value.Version, options); + writer.WriteEndObject(); + } + } + public class Wabbajack_DTOs_DownloadStates_WabbajackCDNConverter : JsonConverter { + public override Wabbajack.DTOs.DownloadStates.WabbajackCDN Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + System.Uri urlProp = default; + while (true) { + reader.Read(); + if (reader.TokenType == JsonTokenType.EndObject) { + reader.Read(); + break; + } + var prop = reader.GetString(); + reader.Read(); + switch (prop) { + case "Url": + urlProp = JsonSerializer.Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + return new Wabbajack.DTOs.DownloadStates.WabbajackCDN { + Url = urlProp, + }; + } + public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.DownloadStates.WabbajackCDN value, JsonSerializerOptions options) { + writer.WriteStartObject(); + writer.WriteString("$type", "WabbajackCDNDownloader+State, Wabbajack.Lib"); + writer.WritePropertyName("Url"); + JsonSerializer.Serialize(writer, value.Url, options); + writer.WriteEndObject(); + } + } + public class Wabbajack_DTOs_BSA_ArchiveStates_IArchiveConverter : JsonConverter { + public static void ConfigureServices(IServiceCollection services) { + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + } + public override Wabbajack.DTOs.BSA.ArchiveStates.IArchive Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + var cReader = reader; + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + cReader.Read(); + if (cReader.GetString() != "$type") + throw new JsonException(); + cReader.Read(); + var type = cReader.GetString(); + switch(type) { + case "BA2State, Compression.BSA": + return JsonSerializer.Deserialize(ref reader, options)!; + case "BA2State": + return JsonSerializer.Deserialize(ref reader, options)!; + case "BSAState, Compression.BSA": + return JsonSerializer.Deserialize(ref reader, options)!; + case "BSAState": + return JsonSerializer.Deserialize(ref reader, options)!; + case "TES3State": + return JsonSerializer.Deserialize(ref reader, options)!; + case "TES3State, Compression.BSA": + return JsonSerializer.Deserialize(ref reader, options)!; + default: + throw new JsonException($"No Type dispatch for {type}"); + } + } + public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.BSA.ArchiveStates.IArchive value, JsonSerializerOptions options) { + switch (value) { + case Wabbajack.DTOs.BSA.ArchiveStates.BA2State v0: + JsonSerializer.Serialize(writer, v0, options); + return; + case Wabbajack.DTOs.BSA.ArchiveStates.BSAState v1: + JsonSerializer.Serialize(writer, v1, options); + return; + case Wabbajack.DTOs.BSA.ArchiveStates.TES3State v2: + JsonSerializer.Serialize(writer, v2, options); + return; + } + } + } + public class Wabbajack_DTOs_BSA_ArchiveStates_BA2StateConverter : JsonConverter { + public override Wabbajack.DTOs.BSA.ArchiveStates.BA2State Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + System.Boolean hasnametableProp = default; + System.String headermagicProp = default; + Wabbajack.DTOs.BSA.ArchiveStates.BA2EntryType typeProp = default; + System.UInt32 versionProp = default; + while (true) { + reader.Read(); + if (reader.TokenType == JsonTokenType.EndObject) { + reader.Read(); + break; + } + var prop = reader.GetString(); + reader.Read(); + switch (prop) { + case "HasNameTable": + hasnametableProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "HeaderMagic": + headermagicProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Type": + typeProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Version": + versionProp = JsonSerializer.Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + return new Wabbajack.DTOs.BSA.ArchiveStates.BA2State { + HasNameTable = hasnametableProp, + HeaderMagic = headermagicProp, + Type = typeProp, + Version = versionProp, + }; + } + public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.BSA.ArchiveStates.BA2State value, JsonSerializerOptions options) { + writer.WriteStartObject(); + writer.WriteString("$type", "BA2State, Compression.BSA"); + writer.WritePropertyName("HasNameTable"); + JsonSerializer.Serialize(writer, value.HasNameTable, options); + writer.WritePropertyName("HeaderMagic"); + JsonSerializer.Serialize(writer, value.HeaderMagic, options); + writer.WritePropertyName("Type"); + JsonSerializer.Serialize(writer, value.Type, options); + writer.WritePropertyName("Version"); + JsonSerializer.Serialize(writer, value.Version, options); + writer.WriteEndObject(); + } + } + public class Wabbajack_DTOs_BSA_ArchiveStates_BSAStateConverter : JsonConverter { + public override Wabbajack.DTOs.BSA.ArchiveStates.BSAState Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + System.UInt32 archiveflagsProp = default; + System.UInt32 fileflagsProp = default; + System.String magicProp = default; + System.UInt32 versionProp = default; + while (true) { + reader.Read(); + if (reader.TokenType == JsonTokenType.EndObject) { + reader.Read(); + break; + } + var prop = reader.GetString(); + reader.Read(); + switch (prop) { + case "ArchiveFlags": + archiveflagsProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "FileFlags": + fileflagsProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Magic": + magicProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Version": + versionProp = JsonSerializer.Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + return new Wabbajack.DTOs.BSA.ArchiveStates.BSAState { + ArchiveFlags = archiveflagsProp, + FileFlags = fileflagsProp, + Magic = magicProp, + Version = versionProp, + }; + } + public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.BSA.ArchiveStates.BSAState value, JsonSerializerOptions options) { + writer.WriteStartObject(); + writer.WriteString("$type", "BSAState, Compression.BSA"); + writer.WritePropertyName("ArchiveFlags"); + JsonSerializer.Serialize(writer, value.ArchiveFlags, options); + writer.WritePropertyName("FileFlags"); + JsonSerializer.Serialize(writer, value.FileFlags, options); + writer.WritePropertyName("Magic"); + JsonSerializer.Serialize(writer, value.Magic, options); + writer.WritePropertyName("Version"); + JsonSerializer.Serialize(writer, value.Version, options); + writer.WriteEndObject(); + } + } + public class Wabbajack_DTOs_BSA_ArchiveStates_TES3StateConverter : JsonConverter { + public override Wabbajack.DTOs.BSA.ArchiveStates.TES3State Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + System.Int64 dataoffsetProp = default; + System.UInt32 filecountProp = default; + System.UInt32 hashoffsetProp = default; + System.UInt32 versionnumberProp = default; + while (true) { + reader.Read(); + if (reader.TokenType == JsonTokenType.EndObject) { + reader.Read(); + break; + } + var prop = reader.GetString(); + reader.Read(); + switch (prop) { + case "DataOffset": + dataoffsetProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "FileCount": + filecountProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "HashOffset": + hashoffsetProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "VersionNumber": + versionnumberProp = JsonSerializer.Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + return new Wabbajack.DTOs.BSA.ArchiveStates.TES3State { + DataOffset = dataoffsetProp, + FileCount = filecountProp, + HashOffset = hashoffsetProp, + VersionNumber = versionnumberProp, + }; + } + public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.BSA.ArchiveStates.TES3State value, JsonSerializerOptions options) { + writer.WriteStartObject(); + writer.WriteString("$type", "TES3State"); + writer.WritePropertyName("DataOffset"); + JsonSerializer.Serialize(writer, value.DataOffset, options); + writer.WritePropertyName("FileCount"); + JsonSerializer.Serialize(writer, value.FileCount, options); + writer.WritePropertyName("HashOffset"); + JsonSerializer.Serialize(writer, value.HashOffset, options); + writer.WritePropertyName("VersionNumber"); + JsonSerializer.Serialize(writer, value.VersionNumber, options); + writer.WriteEndObject(); + } + } + public class Wabbajack_DTOs_DirectiveConverter : JsonConverter { + public static void ConfigureServices(IServiceCollection services) { + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + } + public override Wabbajack.DTOs.Directive Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + var cReader = reader; + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + cReader.Read(); + if (cReader.GetString() != "$type") + throw new JsonException(); + cReader.Read(); + var type = cReader.GetString(); + switch(type) { + case "ArchiveMeta": + return JsonSerializer.Deserialize(ref reader, options)!; + case "ArchiveMeta, Wabbajack.Lib": + return JsonSerializer.Deserialize(ref reader, options)!; + case "CreateBSA": + return JsonSerializer.Deserialize(ref reader, options)!; + case "CreateBSA, Wabbajack.Lib": + return JsonSerializer.Deserialize(ref reader, options)!; + case "FromArchive": + return JsonSerializer.Deserialize(ref reader, options)!; + case "FromArchive, Wabbajack.Lib": + return JsonSerializer.Deserialize(ref reader, options)!; + case "IgnoredDirectly": + return JsonSerializer.Deserialize(ref reader, options)!; + case "InlineFile": + return JsonSerializer.Deserialize(ref reader, options)!; + case "InlineFile, Wabbajack.Lib": + return JsonSerializer.Deserialize(ref reader, options)!; + case "MergedPatch, Wabbajack.Lib": + return JsonSerializer.Deserialize(ref reader, options)!; + case "MergedPatch": + return JsonSerializer.Deserialize(ref reader, options)!; + case "NoMatch": + return JsonSerializer.Deserialize(ref reader, options)!; + case "PatchedFromArchive": + return JsonSerializer.Deserialize(ref reader, options)!; + case "PatchedFromArchive, Wabbajack.Lib": + return JsonSerializer.Deserialize(ref reader, options)!; + case "PropertyFile": + return JsonSerializer.Deserialize(ref reader, options)!; + case "PropertyFile, Wabbajack.Lib": + return JsonSerializer.Deserialize(ref reader, options)!; + case "RemappedInlineFile": + return JsonSerializer.Deserialize(ref reader, options)!; + case "RemappedInlineFile, Wabbajack.Lib": + return JsonSerializer.Deserialize(ref reader, options)!; + case "TransformedTexture": + return JsonSerializer.Deserialize(ref reader, options)!; + case "TransformedTexture, Wabbajack.Lib": + return JsonSerializer.Deserialize(ref reader, options)!; + default: + throw new JsonException($"No Type dispatch for {type}"); + } + } + public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.Directive value, JsonSerializerOptions options) { + switch (value) { + case Wabbajack.DTOs.Directives.NoMatch v0: + JsonSerializer.Serialize(writer, v0, options); + return; + case Wabbajack.DTOs.Directives.PatchedFromArchive v1: + JsonSerializer.Serialize(writer, v1, options); + return; + case Wabbajack.DTOs.Directives.PropertyFile v2: + JsonSerializer.Serialize(writer, v2, options); + return; + case Wabbajack.DTOs.Directives.RemappedInlineFile v3: + JsonSerializer.Serialize(writer, v3, options); + return; + case Wabbajack.DTOs.Directives.TransformedTexture v4: + JsonSerializer.Serialize(writer, v4, options); + return; + case Wabbajack.DTOs.Directives.ArchiveMeta v5: + JsonSerializer.Serialize(writer, v5, options); + return; + case Wabbajack.DTOs.Directives.CreateBSA v6: + JsonSerializer.Serialize(writer, v6, options); + return; + case Wabbajack.DTOs.Directives.FromArchive v7: + JsonSerializer.Serialize(writer, v7, options); + return; + case Wabbajack.DTOs.Directives.IgnoredDirectly v8: + JsonSerializer.Serialize(writer, v8, options); + return; + case Wabbajack.DTOs.Directives.InlineFile v9: + JsonSerializer.Serialize(writer, v9, options); + return; + case Wabbajack.DTOs.Directives.MergedPatch v10: + JsonSerializer.Serialize(writer, v10, options); + return; + } + } + } + public class Wabbajack_DTOs_Directives_ArchiveMetaConverter : JsonConverter { + public override Wabbajack.DTOs.Directives.ArchiveMeta Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + Wabbajack.Hashing.xxHash64.Hash hashProp = default; + System.Int64 sizeProp = default; + Wabbajack.Paths.RelativePath sourcedataidProp = default; + Wabbajack.Paths.RelativePath toProp = default; + while (true) { + reader.Read(); + if (reader.TokenType == JsonTokenType.EndObject) { + reader.Read(); + break; + } + var prop = reader.GetString(); + reader.Read(); + switch (prop) { + case "Hash": + hashProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Size": + sizeProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "SourceDataID": + sourcedataidProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "To": + toProp = JsonSerializer.Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + return new Wabbajack.DTOs.Directives.ArchiveMeta { + Hash = hashProp, + Size = sizeProp, + SourceDataID = sourcedataidProp, + To = toProp, + }; + } + public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.Directives.ArchiveMeta value, JsonSerializerOptions options) { + writer.WriteStartObject(); + writer.WriteString("$type", "ArchiveMeta"); + writer.WritePropertyName("Hash"); + JsonSerializer.Serialize(writer, value.Hash, options); + writer.WritePropertyName("Size"); + JsonSerializer.Serialize(writer, value.Size, options); + writer.WritePropertyName("SourceDataID"); + JsonSerializer.Serialize(writer, value.SourceDataID, options); + writer.WritePropertyName("To"); + JsonSerializer.Serialize(writer, value.To, options); + writer.WriteEndObject(); + } + } + public class Wabbajack_DTOs_Directives_CreateBSAConverter : JsonConverter { + public override Wabbajack.DTOs.Directives.CreateBSA Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + Wabbajack.DTOs.BSA.FileStates.AFile[] filestatesProp = default; + Wabbajack.Hashing.xxHash64.Hash hashProp = default; + System.Int64 sizeProp = default; + Wabbajack.DTOs.BSA.ArchiveStates.IArchive stateProp = default; + Wabbajack.Paths.RelativePath tempidProp = default; + Wabbajack.Paths.RelativePath toProp = default; + while (true) { + reader.Read(); + if (reader.TokenType == JsonTokenType.EndObject) { + reader.Read(); + break; + } + var prop = reader.GetString(); + reader.Read(); + switch (prop) { + case "FileStates": + filestatesProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Hash": + hashProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Size": + sizeProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "State": + stateProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "TempID": + tempidProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "To": + toProp = JsonSerializer.Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + return new Wabbajack.DTOs.Directives.CreateBSA { + FileStates = filestatesProp, + Hash = hashProp, + Size = sizeProp, + State = stateProp, + TempID = tempidProp, + To = toProp, + }; + } + public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.Directives.CreateBSA value, JsonSerializerOptions options) { + writer.WriteStartObject(); + writer.WriteString("$type", "CreateBSA"); + writer.WritePropertyName("FileStates"); + JsonSerializer.Serialize(writer, value.FileStates, options); + writer.WritePropertyName("Hash"); + JsonSerializer.Serialize(writer, value.Hash, options); + writer.WritePropertyName("Size"); + JsonSerializer.Serialize(writer, value.Size, options); + writer.WritePropertyName("State"); + JsonSerializer.Serialize(writer, value.State, options); + writer.WritePropertyName("TempID"); + JsonSerializer.Serialize(writer, value.TempID, options); + writer.WritePropertyName("To"); + JsonSerializer.Serialize(writer, value.To, options); + writer.WriteEndObject(); + } + } + public class Wabbajack_DTOs_Directives_FromArchiveConverter : JsonConverter { + public override Wabbajack.DTOs.Directives.FromArchive Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + Wabbajack.Hashing.xxHash64.HashRelativePath archivehashpathProp = default; + Wabbajack.Hashing.xxHash64.Hash hashProp = default; + System.Int64 sizeProp = default; + Wabbajack.Paths.RelativePath toProp = default; + while (true) { + reader.Read(); + if (reader.TokenType == JsonTokenType.EndObject) { + reader.Read(); + break; + } + var prop = reader.GetString(); + reader.Read(); + switch (prop) { + case "ArchiveHashPath": + archivehashpathProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Hash": + hashProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Size": + sizeProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "To": + toProp = JsonSerializer.Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + return new Wabbajack.DTOs.Directives.FromArchive { + ArchiveHashPath = archivehashpathProp, + Hash = hashProp, + Size = sizeProp, + To = toProp, + }; + } + public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.Directives.FromArchive value, JsonSerializerOptions options) { + writer.WriteStartObject(); + writer.WriteString("$type", "FromArchive"); + writer.WritePropertyName("ArchiveHashPath"); + JsonSerializer.Serialize(writer, value.ArchiveHashPath, options); + writer.WritePropertyName("Hash"); + JsonSerializer.Serialize(writer, value.Hash, options); + writer.WritePropertyName("Size"); + JsonSerializer.Serialize(writer, value.Size, options); + writer.WritePropertyName("To"); + JsonSerializer.Serialize(writer, value.To, options); + writer.WriteEndObject(); + } + } + public class Wabbajack_DTOs_Directives_IgnoredDirectlyConverter : JsonConverter { + public override Wabbajack.DTOs.Directives.IgnoredDirectly Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + Wabbajack.Hashing.xxHash64.Hash hashProp = default; + System.Int64 sizeProp = default; + Wabbajack.Paths.RelativePath toProp = default; + while (true) { + reader.Read(); + if (reader.TokenType == JsonTokenType.EndObject) { + reader.Read(); + break; + } + var prop = reader.GetString(); + reader.Read(); + switch (prop) { + case "Hash": + hashProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Size": + sizeProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "To": + toProp = JsonSerializer.Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + return new Wabbajack.DTOs.Directives.IgnoredDirectly { + Hash = hashProp, + Size = sizeProp, + To = toProp, + }; + } + public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.Directives.IgnoredDirectly value, JsonSerializerOptions options) { + writer.WriteStartObject(); + writer.WriteString("$type", "IgnoredDirectly"); + writer.WritePropertyName("Hash"); + JsonSerializer.Serialize(writer, value.Hash, options); + writer.WritePropertyName("Size"); + JsonSerializer.Serialize(writer, value.Size, options); + writer.WritePropertyName("To"); + JsonSerializer.Serialize(writer, value.To, options); + writer.WriteEndObject(); + } + } + public class Wabbajack_DTOs_Directives_InlineFileConverter : JsonConverter { + public override Wabbajack.DTOs.Directives.InlineFile Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + Wabbajack.Hashing.xxHash64.Hash hashProp = default; + System.Int64 sizeProp = default; + Wabbajack.Paths.RelativePath sourcedataidProp = default; + Wabbajack.Paths.RelativePath toProp = default; + while (true) { + reader.Read(); + if (reader.TokenType == JsonTokenType.EndObject) { + reader.Read(); + break; + } + var prop = reader.GetString(); + reader.Read(); + switch (prop) { + case "Hash": + hashProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Size": + sizeProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "SourceDataID": + sourcedataidProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "To": + toProp = JsonSerializer.Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + return new Wabbajack.DTOs.Directives.InlineFile { + Hash = hashProp, + Size = sizeProp, + SourceDataID = sourcedataidProp, + To = toProp, + }; + } + public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.Directives.InlineFile value, JsonSerializerOptions options) { + writer.WriteStartObject(); + writer.WriteString("$type", "InlineFile"); + writer.WritePropertyName("Hash"); + JsonSerializer.Serialize(writer, value.Hash, options); + writer.WritePropertyName("Size"); + JsonSerializer.Serialize(writer, value.Size, options); + writer.WritePropertyName("SourceDataID"); + JsonSerializer.Serialize(writer, value.SourceDataID, options); + writer.WritePropertyName("To"); + JsonSerializer.Serialize(writer, value.To, options); + writer.WriteEndObject(); + } + } + public class Wabbajack_DTOs_Directives_MergedPatchConverter : JsonConverter { + public override Wabbajack.DTOs.Directives.MergedPatch Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + Wabbajack.Hashing.xxHash64.Hash hashProp = default; + Wabbajack.Paths.RelativePath patchidProp = default; + System.Int64 sizeProp = default; + Wabbajack.DTOs.Directives.SourcePatch[] sourcesProp = default; + Wabbajack.Paths.RelativePath toProp = default; + while (true) { + reader.Read(); + if (reader.TokenType == JsonTokenType.EndObject) { + reader.Read(); + break; + } + var prop = reader.GetString(); + reader.Read(); + switch (prop) { + case "Hash": + hashProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "PatchID": + patchidProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Size": + sizeProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Sources": + sourcesProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "To": + toProp = JsonSerializer.Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + return new Wabbajack.DTOs.Directives.MergedPatch { + Hash = hashProp, + PatchID = patchidProp, + Size = sizeProp, + Sources = sourcesProp, + To = toProp, + }; + } + public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.Directives.MergedPatch value, JsonSerializerOptions options) { + writer.WriteStartObject(); + writer.WriteString("$type", "MergedPatch, Wabbajack.Lib"); + writer.WritePropertyName("Hash"); + JsonSerializer.Serialize(writer, value.Hash, options); + writer.WritePropertyName("PatchID"); + JsonSerializer.Serialize(writer, value.PatchID, options); + writer.WritePropertyName("Size"); + JsonSerializer.Serialize(writer, value.Size, options); + writer.WritePropertyName("Sources"); + JsonSerializer.Serialize(writer, value.Sources, options); + writer.WritePropertyName("To"); + JsonSerializer.Serialize(writer, value.To, options); + writer.WriteEndObject(); + } + } + public class Wabbajack_DTOs_Directives_NoMatchConverter : JsonConverter { + public override Wabbajack.DTOs.Directives.NoMatch Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + Wabbajack.Hashing.xxHash64.Hash hashProp = default; + System.Int64 sizeProp = default; + Wabbajack.Paths.RelativePath toProp = default; + while (true) { + reader.Read(); + if (reader.TokenType == JsonTokenType.EndObject) { + reader.Read(); + break; + } + var prop = reader.GetString(); + reader.Read(); + switch (prop) { + case "Hash": + hashProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Size": + sizeProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "To": + toProp = JsonSerializer.Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + return new Wabbajack.DTOs.Directives.NoMatch { + Hash = hashProp, + Size = sizeProp, + To = toProp, + }; + } + public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.Directives.NoMatch value, JsonSerializerOptions options) { + writer.WriteStartObject(); + writer.WriteString("$type", "NoMatch"); + writer.WritePropertyName("Hash"); + JsonSerializer.Serialize(writer, value.Hash, options); + writer.WritePropertyName("Size"); + JsonSerializer.Serialize(writer, value.Size, options); + writer.WritePropertyName("To"); + JsonSerializer.Serialize(writer, value.To, options); + writer.WriteEndObject(); + } + } + public class Wabbajack_DTOs_Directives_PatchedFromArchiveConverter : JsonConverter { + public override Wabbajack.DTOs.Directives.PatchedFromArchive Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + Wabbajack.Hashing.xxHash64.HashRelativePath archivehashpathProp = default; + Wabbajack.Hashing.xxHash64.Hash fromhashProp = default; + Wabbajack.Hashing.xxHash64.Hash hashProp = default; + Wabbajack.Paths.RelativePath patchidProp = default; + System.Int64 sizeProp = default; + Wabbajack.Paths.RelativePath toProp = default; + while (true) { + reader.Read(); + if (reader.TokenType == JsonTokenType.EndObject) { + reader.Read(); + break; + } + var prop = reader.GetString(); + reader.Read(); + switch (prop) { + case "ArchiveHashPath": + archivehashpathProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "FromHash": + fromhashProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Hash": + hashProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "PatchID": + patchidProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Size": + sizeProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "To": + toProp = JsonSerializer.Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + return new Wabbajack.DTOs.Directives.PatchedFromArchive { + ArchiveHashPath = archivehashpathProp, + FromHash = fromhashProp, + Hash = hashProp, + PatchID = patchidProp, + Size = sizeProp, + To = toProp, + }; + } + public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.Directives.PatchedFromArchive value, JsonSerializerOptions options) { + writer.WriteStartObject(); + writer.WriteString("$type", "PatchedFromArchive"); + writer.WritePropertyName("ArchiveHashPath"); + JsonSerializer.Serialize(writer, value.ArchiveHashPath, options); + writer.WritePropertyName("FromHash"); + JsonSerializer.Serialize(writer, value.FromHash, options); + writer.WritePropertyName("Hash"); + JsonSerializer.Serialize(writer, value.Hash, options); + writer.WritePropertyName("PatchID"); + JsonSerializer.Serialize(writer, value.PatchID, options); + writer.WritePropertyName("Size"); + JsonSerializer.Serialize(writer, value.Size, options); + writer.WritePropertyName("To"); + JsonSerializer.Serialize(writer, value.To, options); + writer.WriteEndObject(); + } + } + public class Wabbajack_DTOs_Directives_PropertyFileConverter : JsonConverter { + public override Wabbajack.DTOs.Directives.PropertyFile Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + Wabbajack.Hashing.xxHash64.Hash hashProp = default; + System.Int64 sizeProp = default; + Wabbajack.Paths.RelativePath sourcedataidProp = default; + Wabbajack.Paths.RelativePath toProp = default; + while (true) { + reader.Read(); + if (reader.TokenType == JsonTokenType.EndObject) { + reader.Read(); + break; + } + var prop = reader.GetString(); + reader.Read(); + switch (prop) { + case "Hash": + hashProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Size": + sizeProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "SourceDataID": + sourcedataidProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "To": + toProp = JsonSerializer.Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + return new Wabbajack.DTOs.Directives.PropertyFile { + Hash = hashProp, + Size = sizeProp, + SourceDataID = sourcedataidProp, + To = toProp, + }; + } + public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.Directives.PropertyFile value, JsonSerializerOptions options) { + writer.WriteStartObject(); + writer.WriteString("$type", "PropertyFile"); + writer.WritePropertyName("Hash"); + JsonSerializer.Serialize(writer, value.Hash, options); + writer.WritePropertyName("Size"); + JsonSerializer.Serialize(writer, value.Size, options); + writer.WritePropertyName("SourceDataID"); + JsonSerializer.Serialize(writer, value.SourceDataID, options); + writer.WritePropertyName("To"); + JsonSerializer.Serialize(writer, value.To, options); + writer.WriteEndObject(); + } + } + public class Wabbajack_DTOs_Directives_RemappedInlineFileConverter : JsonConverter { + public override Wabbajack.DTOs.Directives.RemappedInlineFile Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + Wabbajack.Hashing.xxHash64.Hash hashProp = default; + System.Int64 sizeProp = default; + Wabbajack.Paths.RelativePath sourcedataidProp = default; + Wabbajack.Paths.RelativePath toProp = default; + while (true) { + reader.Read(); + if (reader.TokenType == JsonTokenType.EndObject) { + reader.Read(); + break; + } + var prop = reader.GetString(); + reader.Read(); + switch (prop) { + case "Hash": + hashProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Size": + sizeProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "SourceDataID": + sourcedataidProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "To": + toProp = JsonSerializer.Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + return new Wabbajack.DTOs.Directives.RemappedInlineFile { + Hash = hashProp, + Size = sizeProp, + SourceDataID = sourcedataidProp, + To = toProp, + }; + } + public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.Directives.RemappedInlineFile value, JsonSerializerOptions options) { + writer.WriteStartObject(); + writer.WriteString("$type", "RemappedInlineFile"); + writer.WritePropertyName("Hash"); + JsonSerializer.Serialize(writer, value.Hash, options); + writer.WritePropertyName("Size"); + JsonSerializer.Serialize(writer, value.Size, options); + writer.WritePropertyName("SourceDataID"); + JsonSerializer.Serialize(writer, value.SourceDataID, options); + writer.WritePropertyName("To"); + JsonSerializer.Serialize(writer, value.To, options); + writer.WriteEndObject(); + } + } + public class Wabbajack_DTOs_Directives_TransformedTextureConverter : JsonConverter { + public override Wabbajack.DTOs.Directives.TransformedTexture Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + Wabbajack.Hashing.xxHash64.HashRelativePath archivehashpathProp = default; + Wabbajack.Hashing.xxHash64.Hash hashProp = default; + Wabbajack.DTOs.Texture.ImageState imagestateProp = default; + System.Int64 sizeProp = default; + Wabbajack.Paths.RelativePath toProp = default; + while (true) { + reader.Read(); + if (reader.TokenType == JsonTokenType.EndObject) { + reader.Read(); + break; + } + var prop = reader.GetString(); + reader.Read(); + switch (prop) { + case "ArchiveHashPath": + archivehashpathProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Hash": + hashProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "ImageState": + imagestateProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Size": + sizeProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "To": + toProp = JsonSerializer.Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + return new Wabbajack.DTOs.Directives.TransformedTexture { + ArchiveHashPath = archivehashpathProp, + Hash = hashProp, + ImageState = imagestateProp, + Size = sizeProp, + To = toProp, + }; + } + public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.Directives.TransformedTexture value, JsonSerializerOptions options) { + writer.WriteStartObject(); + writer.WriteString("$type", "TransformedTexture"); + writer.WritePropertyName("ArchiveHashPath"); + JsonSerializer.Serialize(writer, value.ArchiveHashPath, options); + writer.WritePropertyName("Hash"); + JsonSerializer.Serialize(writer, value.Hash, options); + writer.WritePropertyName("ImageState"); + JsonSerializer.Serialize(writer, value.ImageState, options); + writer.WritePropertyName("Size"); + JsonSerializer.Serialize(writer, value.Size, options); + writer.WritePropertyName("To"); + JsonSerializer.Serialize(writer, value.To, options); + writer.WriteEndObject(); + } + } + public class Wabbajack_DTOs_BSA_FileStates_AFileConverter : JsonConverter { + public static void ConfigureServices(IServiceCollection services) { + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + } + public override Wabbajack.DTOs.BSA.FileStates.AFile Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + var cReader = reader; + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + cReader.Read(); + if (cReader.GetString() != "$type") + throw new JsonException(); + cReader.Read(); + var type = cReader.GetString(); + switch(type) { + case "BA2DX10Entry": + return JsonSerializer.Deserialize(ref reader, options)!; + case "BA2DX10Entry, Compression.BSA": + return JsonSerializer.Deserialize(ref reader, options)!; + case "BA2File": + return JsonSerializer.Deserialize(ref reader, options)!; + case "BA2FileEntryState, Compression.BSA": + return JsonSerializer.Deserialize(ref reader, options)!; + case "BSAFileState, Compression.BSA": + return JsonSerializer.Deserialize(ref reader, options)!; + case "BSAFile": + return JsonSerializer.Deserialize(ref reader, options)!; + case "TES3File": + return JsonSerializer.Deserialize(ref reader, options)!; + default: + throw new JsonException($"No Type dispatch for {type}"); + } + } + public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.BSA.FileStates.AFile value, JsonSerializerOptions options) { + switch (value) { + case Wabbajack.DTOs.BSA.FileStates.BA2DX10File v0: + JsonSerializer.Serialize(writer, v0, options); + return; + case Wabbajack.DTOs.BSA.FileStates.BA2File v1: + JsonSerializer.Serialize(writer, v1, options); + return; + case Wabbajack.DTOs.BSA.FileStates.BSAFile v2: + JsonSerializer.Serialize(writer, v2, options); + return; + case Wabbajack.DTOs.BSA.FileStates.TES3File v3: + JsonSerializer.Serialize(writer, v3, options); + return; + } + } + } + public class Wabbajack_DTOs_BSA_FileStates_BA2DX10FileConverter : JsonConverter { + public override Wabbajack.DTOs.BSA.FileStates.BA2DX10File Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + System.UInt16 chunkhdrlenProp = default; + Wabbajack.DTOs.BSA.FileStates.BA2Chunk[] chunksProp = default; + System.UInt32 dirhashProp = default; + System.String extensionProp = default; + System.UInt16 heightProp = default; + System.Int32 indexProp = default; + System.Byte iscubemapProp = default; + System.UInt32 namehashProp = default; + System.Byte nummipsProp = default; + Wabbajack.Paths.RelativePath pathProp = default; + System.Byte pixelformatProp = default; + System.Byte tilemodeProp = default; + System.Byte unk8Prop = default; + System.UInt16 widthProp = default; + while (true) { + reader.Read(); + if (reader.TokenType == JsonTokenType.EndObject) { + reader.Read(); + break; + } + var prop = reader.GetString(); + reader.Read(); + switch (prop) { + case "ChunkHdrLen": + chunkhdrlenProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Chunks": + chunksProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "DirHash": + dirhashProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Extension": + extensionProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Height": + heightProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Index": + indexProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "IsCubeMap": + iscubemapProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "NameHash": + namehashProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "NumMips": + nummipsProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Path": + pathProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "PixelFormat": + pixelformatProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "TileMode": + tilemodeProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Unk8": + unk8Prop = JsonSerializer.Deserialize(ref reader, options); + break; + case "Width": + widthProp = JsonSerializer.Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + return new Wabbajack.DTOs.BSA.FileStates.BA2DX10File { + ChunkHdrLen = chunkhdrlenProp, + Chunks = chunksProp, + DirHash = dirhashProp, + Extension = extensionProp, + Height = heightProp, + Index = indexProp, + IsCubeMap = iscubemapProp, + NameHash = namehashProp, + NumMips = nummipsProp, + Path = pathProp, + PixelFormat = pixelformatProp, + TileMode = tilemodeProp, + Unk8 = unk8Prop, + Width = widthProp, + }; + } + public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.BSA.FileStates.BA2DX10File value, JsonSerializerOptions options) { + writer.WriteStartObject(); + writer.WriteString("$type", "BA2DX10Entry"); + writer.WritePropertyName("ChunkHdrLen"); + JsonSerializer.Serialize(writer, value.ChunkHdrLen, options); + writer.WritePropertyName("Chunks"); + JsonSerializer.Serialize(writer, value.Chunks, options); + writer.WritePropertyName("DirHash"); + JsonSerializer.Serialize(writer, value.DirHash, options); + writer.WritePropertyName("Extension"); + JsonSerializer.Serialize(writer, value.Extension, options); + writer.WritePropertyName("Height"); + JsonSerializer.Serialize(writer, value.Height, options); + writer.WritePropertyName("Index"); + JsonSerializer.Serialize(writer, value.Index, options); + writer.WritePropertyName("IsCubeMap"); + JsonSerializer.Serialize(writer, value.IsCubeMap, options); + writer.WritePropertyName("NameHash"); + JsonSerializer.Serialize(writer, value.NameHash, options); + writer.WritePropertyName("NumMips"); + JsonSerializer.Serialize(writer, value.NumMips, options); + writer.WritePropertyName("Path"); + JsonSerializer.Serialize(writer, value.Path, options); + writer.WritePropertyName("PixelFormat"); + JsonSerializer.Serialize(writer, value.PixelFormat, options); + writer.WritePropertyName("TileMode"); + JsonSerializer.Serialize(writer, value.TileMode, options); + writer.WritePropertyName("Unk8"); + JsonSerializer.Serialize(writer, value.Unk8, options); + writer.WritePropertyName("Width"); + JsonSerializer.Serialize(writer, value.Width, options); + writer.WriteEndObject(); + } + } + public class Wabbajack_DTOs_BSA_FileStates_BA2FileConverter : JsonConverter { + public override Wabbajack.DTOs.BSA.FileStates.BA2File Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + System.UInt32 alignProp = default; + System.Boolean compressedProp = default; + System.UInt32 dirhashProp = default; + System.String extensionProp = default; + System.UInt32 flagsProp = default; + System.Int32 indexProp = default; + System.UInt32 namehashProp = default; + Wabbajack.Paths.RelativePath pathProp = default; + while (true) { + reader.Read(); + if (reader.TokenType == JsonTokenType.EndObject) { + reader.Read(); + break; + } + var prop = reader.GetString(); + reader.Read(); + switch (prop) { + case "Align": + alignProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Compressed": + compressedProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "DirHash": + dirhashProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Extension": + extensionProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Flags": + flagsProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Index": + indexProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "NameHash": + namehashProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Path": + pathProp = JsonSerializer.Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + return new Wabbajack.DTOs.BSA.FileStates.BA2File { + Align = alignProp, + Compressed = compressedProp, + DirHash = dirhashProp, + Extension = extensionProp, + Flags = flagsProp, + Index = indexProp, + NameHash = namehashProp, + Path = pathProp, + }; + } + public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.BSA.FileStates.BA2File value, JsonSerializerOptions options) { + writer.WriteStartObject(); + writer.WriteString("$type", "BA2File"); + writer.WritePropertyName("Align"); + JsonSerializer.Serialize(writer, value.Align, options); + writer.WritePropertyName("Compressed"); + JsonSerializer.Serialize(writer, value.Compressed, options); + writer.WritePropertyName("DirHash"); + JsonSerializer.Serialize(writer, value.DirHash, options); + writer.WritePropertyName("Extension"); + JsonSerializer.Serialize(writer, value.Extension, options); + writer.WritePropertyName("Flags"); + JsonSerializer.Serialize(writer, value.Flags, options); + writer.WritePropertyName("Index"); + JsonSerializer.Serialize(writer, value.Index, options); + writer.WritePropertyName("NameHash"); + JsonSerializer.Serialize(writer, value.NameHash, options); + writer.WritePropertyName("Path"); + JsonSerializer.Serialize(writer, value.Path, options); + writer.WriteEndObject(); + } + } + public class Wabbajack_DTOs_BSA_FileStates_BSAFileConverter : JsonConverter { + public override Wabbajack.DTOs.BSA.FileStates.BSAFile Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + System.Boolean flipcompressionProp = default; + System.Int32 indexProp = default; + Wabbajack.Paths.RelativePath pathProp = default; + while (true) { + reader.Read(); + if (reader.TokenType == JsonTokenType.EndObject) { + reader.Read(); + break; + } + var prop = reader.GetString(); + reader.Read(); + switch (prop) { + case "FlipCompression": + flipcompressionProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Index": + indexProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Path": + pathProp = JsonSerializer.Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + return new Wabbajack.DTOs.BSA.FileStates.BSAFile { + FlipCompression = flipcompressionProp, + Index = indexProp, + Path = pathProp, + }; + } + public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.BSA.FileStates.BSAFile value, JsonSerializerOptions options) { + writer.WriteStartObject(); + writer.WriteString("$type", "BSAFileState, Compression.BSA"); + writer.WritePropertyName("FlipCompression"); + JsonSerializer.Serialize(writer, value.FlipCompression, options); + writer.WritePropertyName("Index"); + JsonSerializer.Serialize(writer, value.Index, options); + writer.WritePropertyName("Path"); + JsonSerializer.Serialize(writer, value.Path, options); + writer.WriteEndObject(); + } + } + public class Wabbajack_DTOs_BSA_FileStates_TES3FileConverter : JsonConverter { + public override Wabbajack.DTOs.BSA.FileStates.TES3File Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException(); + System.UInt32 hash1Prop = default; + System.UInt32 hash2Prop = default; + System.Int32 indexProp = default; + System.UInt32 nameoffsetProp = default; + System.UInt32 offsetProp = default; + Wabbajack.Paths.RelativePath pathProp = default; + System.UInt32 sizeProp = default; + while (true) { + reader.Read(); + if (reader.TokenType == JsonTokenType.EndObject) { + reader.Read(); + break; + } + var prop = reader.GetString(); + reader.Read(); + switch (prop) { + case "Hash1": + hash1Prop = JsonSerializer.Deserialize(ref reader, options); + break; + case "Hash2": + hash2Prop = JsonSerializer.Deserialize(ref reader, options); + break; + case "Index": + indexProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "NameOffset": + nameoffsetProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Offset": + offsetProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Path": + pathProp = JsonSerializer.Deserialize(ref reader, options); + break; + case "Size": + sizeProp = JsonSerializer.Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + return new Wabbajack.DTOs.BSA.FileStates.TES3File { + Hash1 = hash1Prop, + Hash2 = hash2Prop, + Index = indexProp, + NameOffset = nameoffsetProp, + Offset = offsetProp, + Path = pathProp, + Size = sizeProp, + }; + } + public override void Write(Utf8JsonWriter writer, Wabbajack.DTOs.BSA.FileStates.TES3File value, JsonSerializerOptions options) { + writer.WriteStartObject(); + writer.WriteString("$type", "TES3File"); + writer.WritePropertyName("Hash1"); + JsonSerializer.Serialize(writer, value.Hash1, options); + writer.WritePropertyName("Hash2"); + JsonSerializer.Serialize(writer, value.Hash2, options); + writer.WritePropertyName("Index"); + JsonSerializer.Serialize(writer, value.Index, options); + writer.WritePropertyName("NameOffset"); + JsonSerializer.Serialize(writer, value.NameOffset, options); + writer.WritePropertyName("Offset"); + JsonSerializer.Serialize(writer, value.Offset, options); + writer.WritePropertyName("Path"); + JsonSerializer.Serialize(writer, value.Path, options); + writer.WritePropertyName("Size"); + JsonSerializer.Serialize(writer, value.Size, options); + writer.WriteEndObject(); + } + } diff --git a/Wabbajack.DTOs/Texture/ImageState.cs b/Wabbajack.DTOs/Texture/ImageState.cs index e182606d..4c727ca5 100644 --- a/Wabbajack.DTOs/Texture/ImageState.cs +++ b/Wabbajack.DTOs/Texture/ImageState.cs @@ -7,8 +7,10 @@ public class ImageState public DXGI_FORMAT Format { get; set; } public PHash PerceptualHash { get; set; } + public int MipLevels { get; set; } + public override string ToString() { - return $"ImageState<{Width}, {Height}, {Format}>"; + return $"ImageState<{Width}, {Height}, {Format}, {MipLevels} levels>"; } } \ No newline at end of file diff --git a/Wabbajack.Hashing.PHash.Test/FileLoadingTests.cs b/Wabbajack.Hashing.PHash.Test/FileLoadingTests.cs index 1db34a5e..e8e21e97 100644 --- a/Wabbajack.Hashing.PHash.Test/FileLoadingTests.cs +++ b/Wabbajack.Hashing.PHash.Test/FileLoadingTests.cs @@ -78,7 +78,7 @@ public class FileLoadingTests : IAsyncDisposable using var ms = new MemoryStream(); await using var ins = path.Open(FileMode.Open, FileAccess.Read, FileShare.Read); - await imageLoader.Recompress(ins, 128, 128, DXGI_FORMAT.BC1_UNORM, ms, CancellationToken.None, leaveOpen:true); + await imageLoader.Recompress(ins, 128, 128, baseState.MipLevels, DXGI_FORMAT.BC1_UNORM, ms, CancellationToken.None, leaveOpen:true); ms.Length.Should().Be(ins.Length); } } diff --git a/Wabbajack.Hashing.PHash/CrossPlatformImageLoader.cs b/Wabbajack.Hashing.PHash/CrossPlatformImageLoader.cs index eb6cae99..71a042f4 100644 --- a/Wabbajack.Hashing.PHash/CrossPlatformImageLoader.cs +++ b/Wabbajack.Hashing.PHash/CrossPlatformImageLoader.cs @@ -43,6 +43,7 @@ public class CrossPlatformImageLoader : IImageLoader { Width = data.Width, Height = data.Height, + MipLevels = (int)ddsFile.header.dwMipMapCount, Format = (DXGI_FORMAT) format }; @@ -60,16 +61,16 @@ public class CrossPlatformImageLoader : IImageLoader new Digest {Coefficients = b.Data}); } - public async Task Recompress(AbsolutePath input, int width, int height, DXGI_FORMAT format, + public async Task Recompress(AbsolutePath input, int width, int height, int mipMaps, DXGI_FORMAT format, AbsolutePath output, CancellationToken token) { var inData = await input.ReadAllBytesAsync(token); await using var outStream = output.Open(FileMode.Create, FileAccess.Write); - await Recompress(new MemoryStream(inData), width, height, format, outStream, token); + await Recompress(new MemoryStream(inData), width, height, mipMaps, format, outStream, token); } - public async Task Recompress(Stream input, int width, int height, DXGI_FORMAT format, Stream output, + public async Task Recompress(Stream input, int width, int height, int mipMaps, DXGI_FORMAT format, Stream output, CancellationToken token, bool leaveOpen = false) { var decoder = new BcDecoder(); @@ -99,7 +100,8 @@ public class CrossPlatformImageLoader : IImageLoader Quality = CompressionQuality.Balanced, GenerateMipMaps = true, Format = ToCompressionFormat(format), - FileFormat = OutputFileFormat.Dds + FileFormat = OutputFileFormat.Dds, + MaxMipMapLevel = mipMaps } }; diff --git a/Wabbajack.Hashing.PHash/IImageLoader.cs b/Wabbajack.Hashing.PHash/IImageLoader.cs index 93898e43..5e233768 100644 --- a/Wabbajack.Hashing.PHash/IImageLoader.cs +++ b/Wabbajack.Hashing.PHash/IImageLoader.cs @@ -18,10 +18,10 @@ public interface IImageLoader new Digest {Coefficients = b.Data}); } - public Task Recompress(AbsolutePath input, int width, int height, DXGI_FORMAT format, + public Task Recompress(AbsolutePath input, int width, int height, int mipMaps, DXGI_FORMAT format, AbsolutePath output, CancellationToken token); - public Task Recompress(Stream input, int width, int height, DXGI_FORMAT format, Stream output, + public Task Recompress(Stream input, int width, int height, int mipMaps, DXGI_FORMAT format, Stream output, CancellationToken token, bool leaveOpen = false); } \ No newline at end of file diff --git a/Wabbajack.Hashing.PHash/TexConvImageLoader.cs b/Wabbajack.Hashing.PHash/TexConvImageLoader.cs index a80069ab..40fdefbe 100644 --- a/Wabbajack.Hashing.PHash/TexConvImageLoader.cs +++ b/Wabbajack.Hashing.PHash/TexConvImageLoader.cs @@ -57,16 +57,16 @@ public class TexConvImageLoader : IImageLoader return ext; } - public async Task Recompress(AbsolutePath input, int width, int height, DXGI_FORMAT format, AbsolutePath output, + public async Task Recompress(AbsolutePath input, int width, int height, int mipMaps, DXGI_FORMAT format, AbsolutePath output, CancellationToken token) { var outFolder = _tempManager.CreateFolder(); var outFile = input.FileName.RelativeTo(outFolder.Path); - await ConvertImage(input, outFolder.Path, width, height, format, input.Extension); + await ConvertImage(input, outFolder.Path, width, height, mipMaps, format, input.Extension); await outFile.MoveToAsync(output, token: token, overwrite:true); } - public async Task Recompress(Stream input, int width, int height, DXGI_FORMAT format, Stream output, CancellationToken token, + public async Task Recompress(Stream input, int width, int height, int mipMaps, DXGI_FORMAT format, Stream output, CancellationToken token, bool leaveOpen = false) { var type = await DetermineType(input); @@ -75,19 +75,19 @@ public class TexConvImageLoader : IImageLoader await input.CopyToAsync(fromFile.Path, token); var toFile = fromFile.Path.FileName.RelativeTo(toFolder); - await ConvertImage(fromFile.Path, toFolder.Path, width, height, format, type); + await ConvertImage(fromFile.Path, toFolder.Path, width, height, mipMaps, format, type); await using var fs = toFile.Open(FileMode.Open, FileAccess.Read, FileShare.Read); await fs.CopyToAsync(output, token); } - public async Task ConvertImage(AbsolutePath from, AbsolutePath toFolder, int w, int h, DXGI_FORMAT format, Extension fileFormat) + public async Task ConvertImage(AbsolutePath from, AbsolutePath toFolder, int w, int h, int mipMaps, DXGI_FORMAT format, Extension fileFormat) { // User isn't renaming the file, so we don't have to create a temporary folder var ph = new ProcessHelper { Path = @"Tools\texconv.exe".ToRelativePath().RelativeTo(KnownFolders.EntryPoint), - Arguments = new object[] {from, "-ft", fileFormat.ToString()[1..], "-f", format, "-o", toFolder, "-w", w, "-h", h, "-if", "CUBIC", "-singleproc"}, + Arguments = new object[] {from, "-ft", fileFormat.ToString()[1..], "-f", format, "-o", toFolder, "-w", w, "-h", h, "-m", mipMaps, "-if", "CUBIC", "-singleproc"}, ThrowOnNonZeroExitCode = true, LogError = true }; @@ -100,7 +100,7 @@ public class TexConvImageLoader : IImageLoader await using var tmpFile = _tempManager.CreateFolder(); var inFile = to.FileName.RelativeTo(tmpFile.Path); await inFile.WriteAllAsync(from, CancellationToken.None); - await ConvertImage(inFile, to.Parent, state.Width, state.Height, state.Format, ext); + await ConvertImage(inFile, to.Parent, state.Width, state.Height, state.MipLevels, state.Format, ext); } // Internals @@ -133,7 +133,8 @@ public class TexConvImageLoader : IImageLoader Width = int.Parse(data["width"]), Height = int.Parse(data["height"]), Format = Enum.Parse(data["format"]), - PerceptualHash = await GetPHash(path) + PerceptualHash = await GetPHash(path), + MipLevels = byte.Parse(data["mipLevels"]) }; } catch (Exception ex) @@ -149,7 +150,7 @@ public class TexConvImageLoader : IImageLoader throw new FileNotFoundException($"Can't hash non-existent file {path}"); await using var tmp = _tempManager.CreateFolder(); - await ConvertImage(path, tmp.Path, 512, 512, DXGI_FORMAT.R8G8B8A8_UNORM, Ext.Png); + await ConvertImage(path, tmp.Path, 512, 512, 1, DXGI_FORMAT.R8G8B8A8_UNORM, Ext.Png); using var img = await Image.LoadAsync(path.FileName.RelativeTo(tmp.Path).ReplaceExtension(Ext.Png).ToString()); img.Mutate(x => x.Resize(512, 512, KnownResamplers.Welch).Grayscale(GrayscaleMode.Bt601)); diff --git a/Wabbajack.Installer/AInstaller.cs b/Wabbajack.Installer/AInstaller.cs index 85ba5ee7..de25e352 100644 --- a/Wabbajack.Installer/AInstaller.cs +++ b/Wabbajack.Installer/AInstaller.cs @@ -261,7 +261,7 @@ public abstract class AInstaller await using var s = await sf.GetStream(); await using var of = destPath.Open(FileMode.Create, FileAccess.Write); _logger.LogInformation("Recompressing {Filename}", tt.To.FileName); - await ImageLoader.Recompress(s, tt.ImageState.Width, tt.ImageState.Height, tt.ImageState.Format, + await ImageLoader.Recompress(s, tt.ImageState.Width, tt.ImageState.Height, tt.ImageState.MipLevels, tt.ImageState.Format, of, token); } break; diff --git a/Wabbajack.Services.OSIntegrated/ServiceExtensions.cs b/Wabbajack.Services.OSIntegrated/ServiceExtensions.cs index 9ce4dfee..764910e2 100644 --- a/Wabbajack.Services.OSIntegrated/ServiceExtensions.cs +++ b/Wabbajack.Services.OSIntegrated/ServiceExtensions.cs @@ -64,7 +64,7 @@ public static class ServiceExtensions { var diskCache = options.UseLocalCache ? new VFSDiskCache(s.GetService()!.CreateFile().Path) - : new VFSDiskCache(KnownFolders.WabbajackAppLocal.Combine("GlobalVFSCache3.sqlite")); + : new VFSDiskCache(KnownFolders.WabbajackAppLocal.Combine("GlobalVFSCache4.sqlite")); var cesiCache = new CesiVFSCache(s.GetRequiredService>(), s.GetRequiredService()); return new FallthroughVFSCache(new IVfsCache[] {diskCache}); diff --git a/Wabbajack.VFS/Context.cs b/Wabbajack.VFS/Context.cs index 8facf752..bef24a5d 100644 --- a/Wabbajack.VFS/Context.cs +++ b/Wabbajack.VFS/Context.cs @@ -136,13 +136,13 @@ public class Context token, fileNames.Keys.ToHashSet()); } - catch (Exception) + catch (Exception ex) { await using var stream = await sfn.GetStream(); var hash = await stream.HashingCopy(Stream.Null, token); if (hash != file.Hash) throw new Exception( - $"File {file.FullPath} is corrupt, please delete it and retry the installation"); + $"File {file.FullPath} is corrupt, please delete it and retry the installation, {ex.Message}", ex); throw; } } diff --git a/Wabbajack.VFS/IndexedVirtualFileExtensions.cs b/Wabbajack.VFS/IndexedVirtualFileExtensions.cs index adf9ca84..063116de 100644 --- a/Wabbajack.VFS/IndexedVirtualFileExtensions.cs +++ b/Wabbajack.VFS/IndexedVirtualFileExtensions.cs @@ -36,6 +36,7 @@ public static class IndexedVirtualFileExtensions { bw.Write((ushort) state.Width); bw.Write((ushort) state.Height); + bw.Write((byte)state.MipLevels); bw.Write((byte) state.Format); state.PerceptualHash.Write(bw); } @@ -46,6 +47,7 @@ public static class IndexedVirtualFileExtensions { Width = br.ReadUInt16(), Height = br.ReadUInt16(), + MipLevels = br.ReadByte(), Format = (DXGI_FORMAT) br.ReadByte(), PerceptualHash = PHash.Read(br) };