Skip to content

Commit db849d2

Browse files
committed
refactoring
1 parent 77b481c commit db849d2

File tree

9 files changed

+20
-20
lines changed

9 files changed

+20
-20
lines changed

MojangAPI/Cache/SessionFileCacheManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public SessionFileCacheManager(string filepath) : base (filepath)
1212

1313
public override Session GetDefaultObject()
1414
{
15-
return new Session()
15+
return new Session
1616
{
1717
ClientToken = Guid.NewGuid().ToString()
1818
};

MojangAPI/HttpAction/HttpQueryCollection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace HttpAction
66
{
77
public class HttpQueryCollection : IEnumerable<string>
88
{
9-
private Dictionary<string, List<string>> Queries = new Dictionary<string, List<string>>();
9+
private readonly Dictionary<string, List<string>> Queries = new Dictionary<string, List<string>>();
1010

1111
public void Add(string key, string value)
1212
{

MojangAPI/HttpAction/HttpResponseHandlers.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace HttpAction
99
{
10-
public class HttpResponseHandlers
10+
public static class HttpResponseHandlers
1111
{
1212
public static Func<HttpResponseMessage, Task<T>> GetDefaultResponseHandler<T>()
1313
{
@@ -60,7 +60,7 @@ public static Func<HttpResponseMessage, Task<T>> GetSuccessCodeResponseHandler<T
6060
if (response.IsSuccessStatusCode)
6161
return Task.FromResult(returnObj);
6262
else
63-
throw new Exception();
63+
throw new HttpRequestException();
6464
};
6565

6666
private static readonly JsonSerializerOptions jsonSerializerOptions = new JsonSerializerOptions

MojangAPI/Model/PlayerUUID.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ public class PlayerUUID
1414
public string? CurrentUsername { get; set; }
1515

1616
[JsonPropertyName("legacy")]
17-
public bool IsLegacy { get; set; } = false;
17+
public bool IsLegacy { get; set; }
1818

1919
[JsonPropertyName("demo")]
20-
public bool IsDemo { get; set; } = false;
20+
public bool IsDemo { get; set; }
2121
}
2222
}

MojangAPI/Mojang.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ namespace MojangAPI
1212
{
1313
public class Mojang
1414
{
15-
internal static Lazy<HttpClient> DefaultClient = new Lazy<HttpClient>(() => new HttpClient());
15+
internal static readonly Lazy<HttpClient> DefaultClient = new Lazy<HttpClient>(() => new HttpClient());
1616

17-
private HttpClient client;
17+
private readonly HttpClient client;
1818

1919
public Mojang()
2020
{
@@ -326,13 +326,13 @@ public Task UploadSkin(string accessToken, SkinType skinType, Stream skinStream,
326326
{ "Authorization", "Bearer " + accessToken }
327327
},
328328

329-
Content = new MultipartFormDataContent()
329+
Content = new MultipartFormDataContent
330330
{
331331
{ new StringContent(skinType.GetModelType()), "\"variant\"" },
332332
{ CreateStreamContent(skinStream, "image/png"), "\"file\"", filename }
333333
},
334334

335-
CheckValidation = (h) =>
335+
CheckValidation = _ =>
336336
{
337337
if (skinStream == null) return nameof(skinStream);
338338
else if (string.IsNullOrEmpty(accessToken)) return nameof(accessToken);
@@ -363,7 +363,7 @@ public Task ResetSkin(string uuid, string accessToken) =>
363363
{ "Authorization", "Bearer " + accessToken }
364364
},
365365

366-
CheckValidation = (h) =>
366+
CheckValidation = _ =>
367367
{
368368
if (string.IsNullOrEmpty(uuid)) return nameof(uuid);
369369
else if (string.IsNullOrEmpty(accessToken)) return nameof(accessToken);

MojangAPI/MojangAuth.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ namespace MojangAPI
1010
{
1111
public class MojangAuth
1212
{
13-
private HttpClient client;
14-
private ICacheManager<Session>? cacheManager;
13+
private readonly HttpClient client;
14+
private readonly ICacheManager<Session>? cacheManager;
1515

1616
public MojangAuth() : this(null) { }
1717

@@ -133,8 +133,8 @@ public Task<MojangAuthResponse> Authenticate(string email, string password, stri
133133
version = 1
134134
},
135135
username = email,
136-
password = password,
137-
clientToken = clientToken
136+
password,
137+
clientToken
138138
}),
139139

140140
CheckValidation = (h) =>
@@ -233,8 +233,8 @@ public Task<MojangAuthResponse> Validate(string accessToken, string? clientToken
233233

234234
Content = new JsonHttpContent(new
235235
{
236-
accessToken = accessToken,
237-
clientToken = clientToken
236+
accessToken,
237+
clientToken
238238
}),
239239

240240
CheckValidation = (h) =>

MojangAPI/SecurityQuestion/QuestionFlow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace MojangAPI.SecurityQuestion
1313
{
1414
public class QuestionFlow
1515
{
16-
private HttpClient client;
16+
private-readonly HttpClient client;
1717

1818
public QuestionFlow()
1919
{

MojangAPI/SecurityQuestion/QuestionList.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ internal QuestionList(Question[] q)
1818
public Question this[int index] => questions[index];
1919
public int Count => questions.Count;
2020

21-
List<Question> questions;
21+
private readonly List<Question> questions;
2222

2323
public Question GetQuestion(int index) => this[index];
2424

MojangAPI/Util.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace MojangAPI
77
{
8-
class Util
8+
static class Util
99
{
1010
internal static string ReplaceInvalidChars(string filename)
1111
{

0 commit comments

Comments
 (0)