Skip to content

Commit

Permalink
Fix spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
Citrinate committed Dec 5, 2024
1 parent dca84ec commit 1321c73
Showing 1 changed file with 106 additions and 106 deletions.
212 changes: 106 additions & 106 deletions FreePackages/Json.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint> OwnedPackages { get; private init; } = new();

[JsonInclude]
[JsonPropertyName("rgOwnedApps")]
[JsonRequired]
internal HashSet<uint> OwnedApps { get; private init; } = new();

[JsonInclude]
[JsonPropertyName("rgIgnoredApps")]
[JsonRequired]
[JsonConverter(typeof(EmptyArrayOrDictionaryConverter))]
internal Dictionary<uint, uint> IgnoredApps { get; private init; } = new();

[JsonInclude]
[JsonPropertyName("rgExcludedTags")]
[JsonRequired]
internal List<Tag> ExcludedTags { get; private init; } = new();

[JsonInclude]
[JsonPropertyName("rgExcludedContentDescriptorIDs")]
[JsonRequired]
internal HashSet<uint> ExcludedContentDescriptorIDs { get; private init; } = new();

[JsonInclude]
[JsonPropertyName("rgWishlist")]
[JsonRequired]
internal HashSet<uint> WishlistedApps { get; private init; } = new();

[JsonInclude]
[JsonPropertyName("rgFollowedApps")]
[JsonRequired]
internal HashSet<uint> FollowedApps { get; private init; } = new();

[JsonExtensionData]
[JsonInclude]
internal Dictionary<string, JsonElement> 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<Dictionary<uint, uint>> {
public override Dictionary<uint, uint> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) {
if (reader.TokenType == JsonTokenType.StartObject) {
var dictionary = JsonSerializer.Deserialize<Dictionary<uint, uint>>(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<uint, uint>();
}
}

throw new JsonException();
}

public override void Write(Utf8JsonWriter writer, Dictionary<uint, uint> 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<uint> OwnedPackages { get; private init; } = new();

[JsonInclude]
[JsonPropertyName("rgOwnedApps")]
[JsonRequired]
internal HashSet<uint> OwnedApps { get; private init; } = new();

[JsonInclude]
[JsonPropertyName("rgIgnoredApps")]
[JsonRequired]
[JsonConverter(typeof(EmptyArrayOrDictionaryConverter))]
internal Dictionary<uint, uint> IgnoredApps { get; private init; } = new();

[JsonInclude]
[JsonPropertyName("rgExcludedTags")]
[JsonRequired]
internal List<Tag> ExcludedTags { get; private init; } = new();

[JsonInclude]
[JsonPropertyName("rgExcludedContentDescriptorIDs")]
[JsonRequired]
internal HashSet<uint> ExcludedContentDescriptorIDs { get; private init; } = new();

[JsonInclude]
[JsonPropertyName("rgWishlist")]
[JsonRequired]
internal HashSet<uint> WishlistedApps { get; private init; } = new();

[JsonInclude]
[JsonPropertyName("rgFollowedApps")]
[JsonRequired]
internal HashSet<uint> FollowedApps { get; private init; } = new();

[JsonExtensionData]
[JsonInclude]
internal Dictionary<string, JsonElement> 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<Dictionary<uint, uint>> {
public override Dictionary<uint, uint> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) {
if (reader.TokenType == JsonTokenType.StartObject) {
var dictionary = JsonSerializer.Deserialize<Dictionary<uint, uint>>(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<uint, uint>();
}
}

throw new JsonException();
}

public override void Write(Utf8JsonWriter writer, Dictionary<uint, uint> value, JsonSerializerOptions options) {
throw new NotImplementedException();
}
}
}
}

0 comments on commit 1321c73

Please sign in to comment.