forked from BeyondDimension/SteamTools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImageChannelType.cs
More file actions
77 lines (68 loc) · 2.18 KB
/
ImageChannelType.cs
File metadata and controls
77 lines (68 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using System.Application;
using System.Application.Services;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
namespace System.Application
{
/// <summary>
/// 图片下载渠道类型
/// </summary>
public enum ImageChannelType
{
/// <summary>
/// Steam 头像图片
/// </summary>
SteamAvatars,
/// <summary>
/// Steam 游戏图片
/// </summary>
SteamGames,
/// <summary>
/// Steam 市场物品图片
/// </summary>
SteamEconomys,
/// <summary>
/// Steam 成就图标
/// </summary>
SteamAchievementIcon,
/// <summary>
/// Steam 加速项目图标
/// </summary>
AccelerateGroup,
/// <summary>
/// 脚本图标
/// </summary>
ScriptIcon,
/// <summary>
/// 验证码图片
/// </summary>
CodeImage,
}
}
namespace System
{
public static class ImageChannelTypeEnumExtensions
{
/// <inheritdoc cref="IHttpService.GetImageAsync(string, string, CancellationToken)"/>
public static Task<string?> GetImageAsync(this IHttpService httpService,
string? requestUri,
ImageChannelType channelType,
CancellationToken cancellationToken = default)
{
if (string.IsNullOrWhiteSpace(requestUri)) return Task.FromResult((string?)null);
var channelType_ = channelType.ToString();
return httpService.GetImageAsync(requestUri, channelType_, cancellationToken);
}
/// <inheritdoc cref="IHttpService.GetImageStreamAsync(string, string, CancellationToken)"/>
public static Task<Stream?> GetImageStreamAsync(this IHttpService httpService,
string? requestUri,
ImageChannelType channelType,
CancellationToken cancellationToken = default)
{
if (string.IsNullOrWhiteSpace(requestUri)) return Task.FromResult((Stream?)null);
var channelType_ = channelType.ToString();
return httpService.GetImageStreamAsync(requestUri, channelType_, cancellationToken);
}
}
}