This repository has been archived by the owner on Sep 13, 2024. It is now read-only.
forked from Sniper677/ASF_ItemDropper
-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
79 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,99 +1,98 @@ | ||
|
||
// Generated by https://quicktype.io | ||
using System; | ||
using System.Globalization; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace QuickType | ||
{ | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Converters; | ||
using System; | ||
using System.Globalization; | ||
namespace QuickType; | ||
|
||
public partial class ItemList | ||
{ | ||
[JsonProperty("accountid")] | ||
public string? Accountid { get; set; } | ||
|
||
[JsonProperty("itemid")] | ||
public string? Itemid { get; set; } | ||
public partial class ItemList | ||
{ | ||
[JsonPropertyName("accountid")] | ||
public string? Accountid { get; set; } | ||
|
||
[JsonProperty("quantity")] | ||
public long Quantity { get; set; } | ||
[JsonPropertyName("itemid")] | ||
public string? Itemid { get; set; } | ||
|
||
[JsonProperty("originalitemid")] | ||
public string? Originalitemid { get; set; } | ||
[JsonPropertyName("quantity")] | ||
public long Quantity { get; set; } | ||
|
||
[JsonProperty("itemdefid")] | ||
[JsonConverter(typeof(ParseStringConverter))] | ||
public long Itemdefid { get; set; } | ||
[JsonPropertyName("originalitemid")] | ||
public string? Originalitemid { get; set; } | ||
|
||
[JsonProperty("appid")] | ||
public long Appid { get; set; } | ||
[JsonPropertyName("itemdefid")] | ||
[JsonConverter(typeof(ParseStringConverter))] | ||
public long Itemdefid { get; set; } | ||
|
||
[JsonProperty("acquired")] | ||
public string? Acquired { get; set; } | ||
[JsonPropertyName("appid")] | ||
public long Appid { get; set; } | ||
|
||
[JsonProperty("state")] | ||
public string? State { get; set; } | ||
[JsonPropertyName("acquired")] | ||
public string? Acquired { get; set; } | ||
|
||
[JsonProperty("origin")] | ||
public string? Origin { get; set; } | ||
[JsonPropertyName("state")] | ||
public string? State { get; set; } | ||
|
||
[JsonProperty("state_changed_timestamp")] | ||
public string? StateChangedTimestamp { get; set; } | ||
} | ||
[JsonPropertyName("origin")] | ||
public string? Origin { get; set; } | ||
|
||
public partial class ItemList | ||
{ | ||
public static ItemList[] FromJson(string json) | ||
{ | ||
return JsonConvert.DeserializeObject<ItemList[]>(json, Converter.Settings) ?? Array.Empty<ItemList>(); | ||
} | ||
} | ||
[JsonPropertyName("state_changed_timestamp")] | ||
public string? StateChangedTimestamp { get; set; } | ||
} | ||
|
||
public static class Serialize | ||
public partial class ItemList | ||
{ | ||
public static ItemList[] FromJson(string json) | ||
{ | ||
public static string ToJson(this ItemList[] self) => JsonConvert.SerializeObject(self, QuickType.Converter.Settings); | ||
return JsonSerializer.Deserialize<ItemList[]>(json, Converter.Settings) ?? Array.Empty<ItemList>(); | ||
} | ||
} | ||
|
||
internal static class Converter | ||
{ | ||
public static readonly JsonSerializerSettings Settings = new() | ||
{ | ||
MetadataPropertyHandling = MetadataPropertyHandling.Ignore, | ||
DateParseHandling = DateParseHandling.None, | ||
Converters = { | ||
new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal } | ||
}, | ||
}; | ||
} | ||
public static class Serialize | ||
{ | ||
public static string ToJson(this ItemList[] self) => JsonSerializer.Serialize(self, QuickType.Converter.Settings); | ||
} | ||
|
||
internal class ParseStringConverter : JsonConverter | ||
internal static class Converter | ||
{ | ||
public static readonly JsonSerializerSettings Settings = new() | ||
{ | ||
public override bool CanConvert(Type t) => t == typeof(long) || t == typeof(long?); | ||
MetadataPropertyHandling = MetadataPropertyHandling.Ignore, | ||
DateParseHandling = DateParseHandling.None, | ||
Converters = { | ||
new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal } | ||
}, | ||
}; | ||
} | ||
|
||
internal class ParseStringConverter : JsonConverter | ||
{ | ||
public override bool CanConvert(Type t) => t == typeof(long) || t == typeof(long?); | ||
|
||
public override object? ReadJson(JsonReader reader, Type t, object? existingValue, JsonSerializer serializer) | ||
public override object? ReadJson(JsonReader reader, Type t, object? existingValue, JsonSerializer serializer) | ||
{ | ||
if (reader.TokenType == JsonToken.Null) return null; | ||
var value = serializer.Deserialize<string>(reader); | ||
if (long.TryParse(value, out var l)) | ||
{ | ||
if (reader.TokenType == JsonToken.Null) return null; | ||
var value = serializer.Deserialize<string>(reader); | ||
if (long.TryParse(value, out var l)) | ||
{ | ||
return l; | ||
} | ||
throw new Exception("Cannot unmarshal type long"); | ||
return l; | ||
} | ||
throw new Exception("Cannot unmarshal type long"); | ||
} | ||
|
||
public override void WriteJson(JsonWriter writer, object? untypedValue, JsonSerializer serializer) | ||
public override void WriteJson(JsonWriter writer, object? untypedValue, JsonSerializer serializer) | ||
{ | ||
if (untypedValue == null) | ||
{ | ||
if (untypedValue == null) | ||
{ | ||
serializer.Serialize(writer, null); | ||
return; | ||
} | ||
var value = (long)untypedValue; | ||
serializer.Serialize(writer, value.ToString()); | ||
serializer.Serialize(writer, null); | ||
return; | ||
} | ||
|
||
public static readonly ParseStringConverter Singleton = new(); | ||
var value = (long)untypedValue; | ||
serializer.Serialize(writer, value.ToString()); | ||
return; | ||
} | ||
|
||
public static readonly ParseStringConverter Singleton = new(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters