From 1321c738b16661ac57d995396d8ef6d0f8572ab4 Mon Sep 17 00:00:00 2001 From: Citrinate Date: Thu, 5 Dec 2024 16:43:45 -0500 Subject: [PATCH] Fix spacing --- FreePackages/Json.cs | 212 +++++++++++++++++++++---------------------- 1 file changed, 106 insertions(+), 106 deletions(-) diff --git a/FreePackages/Json.cs b/FreePackages/Json.cs index 5f00100..fc204a9 100644 --- a/FreePackages/Json.cs +++ b/FreePackages/Json.cs @@ -4,110 +4,110 @@ using System.Text.Json.Serialization; namespace FreePackages { - internal static class Steam { - internal sealed class PlaytestAccessResponse { - [JsonInclude] - [JsonPropertyName("granted")] - [JsonRequired] - internal int? Granted { get; private init; } = null; - - [JsonInclude] - [JsonPropertyName("success")] - [JsonRequired] - internal int Success { get; private init; } = 0; - - [JsonConstructor] - internal PlaytestAccessResponse() {} - } - - internal sealed class UserData { - [JsonInclude] - [JsonPropertyName("rgOwnedPackages")] - [JsonRequired] - internal HashSet OwnedPackages { get; private init; } = new(); - - [JsonInclude] - [JsonPropertyName("rgOwnedApps")] - [JsonRequired] - internal HashSet OwnedApps { get; private init; } = new(); - - [JsonInclude] - [JsonPropertyName("rgIgnoredApps")] - [JsonRequired] - [JsonConverter(typeof(EmptyArrayOrDictionaryConverter))] - internal Dictionary IgnoredApps { get; private init; } = new(); - - [JsonInclude] - [JsonPropertyName("rgExcludedTags")] - [JsonRequired] - internal List ExcludedTags { get; private init; } = new(); - - [JsonInclude] - [JsonPropertyName("rgExcludedContentDescriptorIDs")] - [JsonRequired] - internal HashSet ExcludedContentDescriptorIDs { get; private init; } = new(); - - [JsonInclude] - [JsonPropertyName("rgWishlist")] - [JsonRequired] - internal HashSet WishlistedApps { get; private init; } = new(); - - [JsonInclude] - [JsonPropertyName("rgFollowedApps")] - [JsonRequired] - internal HashSet FollowedApps { get; private init; } = new(); - - [JsonExtensionData] - [JsonInclude] - internal Dictionary AdditionalData { get; private init; } = new(); - - [JsonConstructor] - internal UserData() {} - } - - internal sealed class Tag { - [JsonInclude] - [JsonPropertyName("tagid")] - [JsonRequired] - internal uint TagID = 0; - - [JsonInclude] - [JsonPropertyName("name")] - [JsonRequired] - internal string Name = ""; - - [JsonInclude] - [JsonPropertyName("timestamp_added")] - [JsonRequired] - internal uint TimestampAdded = 0; - - [JsonConstructor] - internal Tag() {} - } - - // https://stackoverflow.com/questions/12221950/how-to-deserialize-object-that-can-be-an-array-or-a-dictionary-with-newtonsoft - public class EmptyArrayOrDictionaryConverter : JsonConverter> { - public override Dictionary Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - if (reader.TokenType == JsonTokenType.StartObject) { - var dictionary = JsonSerializer.Deserialize>(ref reader, options); - if (dictionary == null) { - throw new JsonException(); - } - - return dictionary; - } else if (reader.TokenType == JsonTokenType.StartArray) { - reader.Read(); - if (reader.TokenType == JsonTokenType.EndArray) { - return new Dictionary(); - } - } - - throw new JsonException(); - } - - public override void Write(Utf8JsonWriter writer, Dictionary value, JsonSerializerOptions options) { - throw new NotImplementedException(); - } - } - } + internal static class Steam { + internal sealed class PlaytestAccessResponse { + [JsonInclude] + [JsonPropertyName("granted")] + [JsonRequired] + internal int? Granted { get; private init; } = null; + + [JsonInclude] + [JsonPropertyName("success")] + [JsonRequired] + internal int Success { get; private init; } = 0; + + [JsonConstructor] + internal PlaytestAccessResponse() {} + } + + internal sealed class UserData { + [JsonInclude] + [JsonPropertyName("rgOwnedPackages")] + [JsonRequired] + internal HashSet OwnedPackages { get; private init; } = new(); + + [JsonInclude] + [JsonPropertyName("rgOwnedApps")] + [JsonRequired] + internal HashSet OwnedApps { get; private init; } = new(); + + [JsonInclude] + [JsonPropertyName("rgIgnoredApps")] + [JsonRequired] + [JsonConverter(typeof(EmptyArrayOrDictionaryConverter))] + internal Dictionary IgnoredApps { get; private init; } = new(); + + [JsonInclude] + [JsonPropertyName("rgExcludedTags")] + [JsonRequired] + internal List ExcludedTags { get; private init; } = new(); + + [JsonInclude] + [JsonPropertyName("rgExcludedContentDescriptorIDs")] + [JsonRequired] + internal HashSet ExcludedContentDescriptorIDs { get; private init; } = new(); + + [JsonInclude] + [JsonPropertyName("rgWishlist")] + [JsonRequired] + internal HashSet WishlistedApps { get; private init; } = new(); + + [JsonInclude] + [JsonPropertyName("rgFollowedApps")] + [JsonRequired] + internal HashSet FollowedApps { get; private init; } = new(); + + [JsonExtensionData] + [JsonInclude] + internal Dictionary AdditionalData { get; private init; } = new(); + + [JsonConstructor] + internal UserData() {} + } + + internal sealed class Tag { + [JsonInclude] + [JsonPropertyName("tagid")] + [JsonRequired] + internal uint TagID = 0; + + [JsonInclude] + [JsonPropertyName("name")] + [JsonRequired] + internal string Name = ""; + + [JsonInclude] + [JsonPropertyName("timestamp_added")] + [JsonRequired] + internal uint TimestampAdded = 0; + + [JsonConstructor] + internal Tag() {} + } + + // https://stackoverflow.com/questions/12221950/how-to-deserialize-object-that-can-be-an-array-or-a-dictionary-with-newtonsoft + public class EmptyArrayOrDictionaryConverter : JsonConverter> { + public override Dictionary Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType == JsonTokenType.StartObject) { + var dictionary = JsonSerializer.Deserialize>(ref reader, options); + if (dictionary == null) { + throw new JsonException(); + } + + return dictionary; + } else if (reader.TokenType == JsonTokenType.StartArray) { + reader.Read(); + if (reader.TokenType == JsonTokenType.EndArray) { + return new Dictionary(); + } + } + + throw new JsonException(); + } + + public override void Write(Utf8JsonWriter writer, Dictionary value, JsonSerializerOptions options) { + throw new NotImplementedException(); + } + } + } }