Skip to content

Commit 45a8564

Browse files
committed
2 parents 41cb132 + 195869b commit 45a8564

25 files changed

+181
-216
lines changed

src/BD.SteamClient.UnitTest/BD.SteamClient.UnitTest.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424
<Compile Include="..\ImplicitUsings.MessagePack.cs">
2525
<LinkBase>Properties</LinkBase>
2626
</Compile>
27-
</ItemGroup>
28-
29-
<ItemGroup>
3027
<Compile Include="..\ImplicitUsings.UnitTest.cs">
3128
<LinkBase>Properties</LinkBase>
3229
</Compile>
30+
<Compile Include="..\BD.SteamClient\Properties\ImplicitUsings.cs">
31+
<LinkBase>Properties</LinkBase>
32+
</Compile>
3333
</ItemGroup>
3434

3535
<ItemGroup>

src/BD.SteamClient.UnitTest/SteamServiceTest.cs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
using BD.SteamClient.Services;
2-
using BD.SteamClient.Services.Implementation;
3-
using BD.SteamClient.Services.Mvvm;
4-
using Microsoft.Extensions.Logging.Abstractions;
5-
61
namespace BD.SteamClient.UnitTest;
72

83
public sealed class SteamServiceTest
@@ -51,12 +46,10 @@ public TestSteamServiceImpl(ILoggerFactory loggerFactory) : base(loggerFactory)
5146

5247
public override ISteamConnectService Conn => throw new NotImplementedException();
5348

54-
protected override string AppResources_SaveEditedAppInfo_SaveFailed => throw new NotImplementedException();
55-
56-
protected override string? SteamSettings_StratParameter => throw new NotImplementedException();
49+
protected override string? StratSteamDefaultParameter => default;
5750

58-
protected override bool SteamSettings_IsRunSteamAdministrator => throw new NotImplementedException();
51+
protected override bool IsRunSteamAdministrator => default;
5952

60-
protected override Dictionary<uint, string?> GameLibrarySettings_HideGameList => throw new NotImplementedException();
53+
protected override Dictionary<uint, string?>? HideGameList => default;
6154
}
6255
}

src/BD.SteamClient/Constants/SteamApiUrls.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,24 @@ public static class SteamApiUrls
5050
public const string STEAM_USERINFO_XML_URL = "https://steamcommunity.com/profiles/{0}?xml=1";
5151

5252
public const string STEAMCN_USERINFO_XML_URL = "https://my.steamchina.com/profiles/76561198289531723?xml=1";
53+
54+
public const string STEAM_COMMUNITY_URL = "https://steamcommunity.com";
55+
public const string STEAM_STORE_URL = "https://store.steampowered.com";
56+
57+
public const string GetRSAkeyUrl = $"{STEAM_STORE_URL}/login/getrsakey/";
58+
public const string DologinUrl = $"{STEAM_STORE_URL}/login/dologin?l=schinese";
59+
public const string SteamLoginUrl = $"{STEAM_STORE_URL}/login?oldauth=1";
60+
61+
public const string OpenIdloginUrl = $"{STEAM_COMMUNITY_URL}/openid/login";
62+
63+
public const string CaptchaImageUrl = $"{STEAM_STORE_URL}/login/rendercaptcha/?gid=";
64+
65+
public const string SteamStoreRedeemWalletCodelUrl = $"{STEAM_STORE_URL}/account/ajaxredeemwalletcode?l=schinese";
66+
67+
public const string SteamStoreAccountlUrl = $"{STEAM_STORE_URL}/account?l=schinese";
68+
public const string SteamStoreAccountHistoryDetailUrl = $"{STEAM_STORE_URL}/account/history?l=schinese";
69+
public const string SteamStoreAccountHistoryAjaxlUrl = $"{STEAM_STORE_URL}/AjaxLoadMoreHistory?l=schinese";
70+
71+
public const string SteamStoreAccountSetCountryUrl = $"{STEAM_STORE_URL}/account/setcountry";
72+
public const string SteamStoreAddFundsUrl = $"{STEAM_STORE_URL}/steamaccount/addfunds?l=schinese";
5373
}

src/BD.SteamClient/Enums/ImageChannelType.cs

Lines changed: 0 additions & 71 deletions
This file was deleted.

src/BD.SteamClient/Extensions/BinaryReaderExtensions.SteamAppProperty.cs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,25 +79,34 @@ public static void Write(this BinaryWriter writer, SteamAppPropertyTable table)
7979
switch (property.PropertyType)
8080
{
8181
case SteamAppPropertyType.Table:
82-
writer.Write((SteamAppPropertyTable)property.Value);
82+
if (property.Value is SteamAppPropertyTable table1)
83+
writer.Write(table1);
8384
break;
8485
case SteamAppPropertyType.String:
85-
writer.WriteAppInfoString((string)property.Value);
86+
writer.WriteAppInfoString(property.Value?.ToString() ?? string.Empty);
8687
break;
8788
case SteamAppPropertyType.WString:
88-
writer.WriteAppInfoWideString((string)property.Value);
89+
writer.WriteAppInfoWideString(property.Value?.ToString() ?? string.Empty);
8990
break;
9091
case SteamAppPropertyType.Int32:
91-
writer.Write((int)property.Value);
92+
if (property.Value is not int int32)
93+
int32 = default;
94+
writer.Write(int32);
9295
break;
9396
case SteamAppPropertyType.Uint64:
94-
writer.Write((ulong)property.Value);
97+
if (property.Value is not ulong uint64)
98+
uint64 = default;
99+
writer.Write(uint64);
95100
break;
96101
case SteamAppPropertyType.Float:
97-
writer.Write((float)property.Value);
102+
if (property.Value is not float single)
103+
single = default;
104+
writer.Write(single);
98105
break;
99106
case SteamAppPropertyType.Color:
100-
writer.Write((Color)property.Value);
107+
if (property.Value is not Color color)
108+
color = default;
109+
writer.Write(color);
101110
break;
102111
default:
103112
throw new NotImplementedException("The value type " + property.PropertyType.ToString() + " has not been implemented.");

src/BD.SteamClient/Extensions/HttpClientExtensions.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ namespace System;
66

77
static class HttpClientExtensions
88
{
9-
static async Task<T?> SendAsync<T>(
9+
[RequiresUnreferencedCode("Calls System.Xml.Serialization.XmlSerializer.XmlSerializer(Type)")]
10+
static async Task<T?> SendAsync<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] T>(
1011
this HttpClient client,
1112
ILogger logger,
1213
JsonSerializer? jsonSerializer,
@@ -119,7 +120,7 @@ static class HttpClientExtensions
119120
var knownType = e.GetKnownType();
120121
if (knownType == ExceptionKnownType.Unknown)
121122
{
122-
logger.LogError(e, "SendAsync fail, requestUri: {0}", requestUri);
123+
logger.LogError(e, "SendAsync fail, requestUri: {requestUri}", requestUri);
123124
}
124125
}
125126
finally
@@ -133,8 +134,9 @@ static class HttpClientExtensions
133134
return default;
134135
}
135136

137+
[RequiresUnreferencedCode("Calls System.Xml.Serialization.XmlSerializer.XmlSerializer(Type)")]
136138
[MethodImpl(MethodImplOptions.AggressiveInlining)]
137-
public static Task<T?> SendAsync<T>(
139+
public static Task<T?> SendAsync<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] T>(
138140
this HttpClient client,
139141
ILogger logger,
140142
JsonSerializer? jsonSerializer,
@@ -159,8 +161,9 @@ static class HttpClientExtensions
159161
handlerResponseByIsNotSuccessStatusCode);
160162
}
161163

164+
[RequiresUnreferencedCode("Calls System.Xml.Serialization.XmlSerializer.XmlSerializer(Type)")]
162165
[MethodImpl(MethodImplOptions.AggressiveInlining)]
163-
public static Task<T?> GetAsync<T>(
166+
public static Task<T?> GetAsync<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] T>(
164167
this HttpClient client,
165168
ILogger logger,
166169
string requestUri,

src/BD.SteamClient/Helpers/VdfHelper.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,20 @@ public static class VdfHelper
1616
/// </summary>
1717
/// <param name="filePath"></param>
1818
/// <returns></returns>
19+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
1920
public static KVObject Read(string filePath)
2021
{
2122
var kv = KVSerializer.Create(KVSerializationFormat.KeyValues1Text);
2223
var data = kv.Deserialize(IOPath.OpenRead(filePath));
2324
return data;
2425
}
2526

27+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
2628
public static void Write(string filePath, KVObject content)
2729
{
2830
try
2931
{
30-
using var stream = File.OpenWrite(filePath);
32+
using var stream = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite | FileShare.Delete);
3133
var kv = KVSerializer.Create(KVSerializationFormat.KeyValues1Text);
3234
kv.Serialize(stream, content);
3335
}

src/BD.SteamClient/Models/AchievementInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public bool IsChecked
4444
// STEAMAPP_ICON_URL,
4545
// AppId, IconLocked), ImageChannelType.SteamAchievementIcon);
4646

47-
public Task<string?> IconStream => ImageChannelType.SteamAchievementIcon.GetImageAsync(IconUrl);
47+
public Task<ImageSource.ClipStream?> IconStream => ImageSource.GetAsync(IconUrl);
4848

4949
public int Permission { get; set; }
5050

src/BD.SteamClient/Models/SteamApp.cs

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ public ObservableCollection<SteamAppSaveFile>? SaveFiles
440440

441441
#if (WINDOWS || MACCATALYST || MACOS || LINUX) && !(IOS || ANDROID)
442442

443-
public Task<string> LibraryGridStream => ISteamService.Instance.GetAppImageAsync(this, LibCacheType.Library_Grid);
443+
public Task<ImageSource.ClipStream?> LibraryGridStream => ISteamService.Instance.GetAppImageAsync(this, LibCacheType.Library_Grid);
444444

445445
#endif
446446

@@ -456,7 +456,7 @@ public Stream? EditLibraryGridStream
456456

457457
#if (WINDOWS || MACCATALYST || MACOS || LINUX) && !(IOS || ANDROID)
458458

459-
public Task<string> LibraryHeroStream => ISteamService.Instance.GetAppImageAsync(this, LibCacheType.Library_Hero);
459+
public Task<ImageSource.ClipStream?> LibraryHeroStream => ISteamService.Instance.GetAppImageAsync(this, LibCacheType.Library_Hero);
460460

461461
#endif
462462

@@ -472,15 +472,15 @@ public Stream? EditLibraryHeroStream
472472

473473
#if (WINDOWS || MACCATALYST || MACOS || LINUX) && !(IOS || ANDROID)
474474

475-
public Task<string> LibraryHeroBlurStream => ISteamService.Instance.GetAppImageAsync(this, LibCacheType.Library_Hero_Blur);
475+
public Task<ImageSource.ClipStream?> LibraryHeroBlurStream => ISteamService.Instance.GetAppImageAsync(this, LibCacheType.Library_Hero_Blur);
476476

477477
#endif
478478

479479
public string LibraryLogoUrl => string.Format(STEAMAPP_LIBRARYLOGO_URL, AppId);
480480

481481
#if (WINDOWS || MACCATALYST || MACOS || LINUX) && !(IOS || ANDROID)
482482

483-
public Task<string> LibraryLogoStream => ISteamService.Instance.GetAppImageAsync(this, LibCacheType.Logo);
483+
public Task<ImageSource.ClipStream?> LibraryLogoStream => ISteamService.Instance.GetAppImageAsync(this, LibCacheType.Logo);
484484

485485
#endif
486486

@@ -496,7 +496,7 @@ public Stream? EditLibraryLogoStream
496496

497497
#if (WINDOWS || MACCATALYST || MACOS || LINUX) && !(IOS || ANDROID)
498498

499-
public Task<string> HeaderLogoStream => ISteamService.Instance.GetAppImageAsync(this, LibCacheType.Header);
499+
public Task<ImageSource.ClipStream?> HeaderLogoStream => ISteamService.Instance.GetAppImageAsync(this, LibCacheType.Header);
500500

501501
#endif
502502

@@ -920,12 +920,22 @@ public static bool CheckDownloading(int appState)
920920
*/
921921
}
922922

923+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
924+
static async Task<Stream?> GetStreamAsync(Task<ImageSource.ClipStream?> task)
925+
{
926+
if (task != null)
927+
{
928+
return (await task)?.Stream;
929+
}
930+
return null;
931+
}
932+
923933
public async void RefreshEditImage()
924934
{
925-
EditLibraryGridStream = IOPath.OpenRead(await LibraryGridStream);
926-
EditLibraryHeroStream = IOPath.OpenRead(await LibraryHeroStream);
927-
EditLibraryLogoStream = IOPath.OpenRead(await LibraryLogoStream);
928-
EditHeaderLogoStream = IOPath.OpenRead(await HeaderLogoStream);
935+
EditLibraryGridStream = await GetStreamAsync(LibraryGridStream);
936+
EditLibraryHeroStream = await GetStreamAsync(LibraryHeroStream);
937+
EditLibraryLogoStream = await GetStreamAsync(LibraryLogoStream);
938+
EditHeaderLogoStream = await GetStreamAsync(HeaderLogoStream);
929939
}
930940

931941
#endif

0 commit comments

Comments
 (0)