Skip to content
This repository has been archived by the owner on Sep 13, 2024. It is now read-only.

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
chr233 committed Jun 14, 2024
1 parent 7ce2f14 commit 74dcc20
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 75 deletions.
10 changes: 8 additions & 2 deletions ASFItemDropper.sln
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 1 addition & 2 deletions ASFItemDropper/ASFItemDropper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" IncludeAssets="compile" />
<PackageReference Include="System.Composition.AttributedModel" />
<PackageReference Include="System.Composition.AttributedModel" />
<PackageReference Include="SteamKit2" IncludeAssets="compile" />
</ItemGroup>

Expand Down
139 changes: 69 additions & 70 deletions ASFItemDropper/ItemList.cs
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();
}
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<RollForward>LatestMajor</RollForward>
<RuntimeIdentifiers>linux-arm;linux-arm64;linux-x64;osx-arm64;osx-x64;win-arm64;win-x64</RuntimeIdentifiers>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Debug'">
Expand Down

0 comments on commit 74dcc20

Please sign in to comment.