diff --git a/ASFItemDropper.sln b/ASFItemDropper.sln index daa9042..b173fa2 100644 --- a/ASFItemDropper.sln +++ b/ASFItemDropper.sln @@ -1,12 +1,18 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26124.0 +# Visual Studio Version 17 +VisualStudioVersion = 17.9.34728.123 MinimumVisualStudioVersion = 15.0.26124.0 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASFItemDropper", "ASFItemDropper\ASFItemDropper.csproj", "{D0352FDB-487E-488A-9B07-2D4F19425A39}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ArchiSteamFarm", "ArchiSteamFarm\ArchiSteamFarm\ArchiSteamFarm.csproj", "{930573F9-3DA0-41E8-8E4E-C0476BA8F99C}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "解决方案项", "解决方案项", "{C7B0D013-87A1-4295-93B7-821B18927381}" + ProjectSection(SolutionItems) = preProject + Directory.Build.props = Directory.Build.props + Directory.Packages.props = Directory.Packages.props + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/ASFItemDropper/ASFItemDropper.csproj b/ASFItemDropper/ASFItemDropper.csproj index 0a030c8..09492e4 100644 --- a/ASFItemDropper/ASFItemDropper.csproj +++ b/ASFItemDropper/ASFItemDropper.csproj @@ -9,8 +9,7 @@ - - + diff --git a/ASFItemDropper/ItemList.cs b/ASFItemDropper/ItemList.cs index f895167..0ed3c22 100644 --- a/ASFItemDropper/ItemList.cs +++ b/ASFItemDropper/ItemList.cs @@ -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(json, Converter.Settings) ?? Array.Empty(); - } - } + [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(json, Converter.Settings) ?? Array.Empty(); } +} - 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(reader); + if (long.TryParse(value, out var l)) { - if (reader.TokenType == JsonToken.Null) return null; - var value = serializer.Deserialize(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(); } diff --git a/Directory.Build.props b/Directory.Build.props index b906350..4193599 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -26,7 +26,7 @@ LatestMajor linux-arm;linux-arm64;linux-x64;osx-arm64;osx-x64;win-arm64;win-x64 true - net7.0 + net8.0