Skip to content

Commit 729565d

Browse files
author
Jonas Dellinger
committed
Code Cleanup
1 parent 5ccef6f commit 729565d

1 file changed

Lines changed: 17 additions & 13 deletions

File tree

SpotifyAPI/Local/RemoteHandler.cs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public RemoteHandler(SpotifyLocalAPIConfig config)
2626
_config = config;
2727
}
2828

29-
internal Boolean Init()
29+
internal bool Init()
3030
{
3131
OauthKey = GetOAuthKey();
3232
CfidKey = GetCfid();
@@ -35,30 +35,36 @@ internal Boolean Init()
3535

3636
internal async Task SendPauseRequest()
3737
{
38-
var @params = new NameValueCollection() { { "pause", "true" } };
38+
NameValueCollection @params = new NameValueCollection { { "pause", "true" } };
3939
await QueryAsync("remote/pause.json", true, true, -1, @params).ConfigureAwait(false);
4040
}
4141

4242
internal async Task SendPlayRequest()
4343
{
44-
var @params = new NameValueCollection() { { "pause", "false" } };
44+
NameValueCollection @params = new NameValueCollection { { "pause", "false" } };
4545
await QueryAsync("remote/pause.json", true, true, -1, @params).ConfigureAwait(false);
4646
}
4747

4848
internal async Task SendPlayRequest(string url, string context = "")
4949
{
5050

5151
// TODO: instead of having an empty context, one way to fix the bug with the playback time beyond the length of a song would be to provide a 1-song context, and it would be fixed.
52-
var @params = new NameValueCollection() { {"uri", url },
53-
{ "context", context} };
52+
NameValueCollection @params = new NameValueCollection
53+
{
54+
{"uri", url},
55+
{"context", context}
56+
};
5457
await QueryAsync($"remote/play.json", true, true, -1, @params).ConfigureAwait(false);
5558

5659
}
5760

5861
internal async Task SendQueueRequest(string url)
5962
{
60-
var @params = new NameValueCollection() { {"uri", url },
61-
{ "action", "queue"} };
63+
NameValueCollection @params = new NameValueCollection
64+
{
65+
{"uri", url},
66+
{"action", "queue"}
67+
};
6268
await QueryAsync("remote/play.json", true, true, -1, @params).ConfigureAwait(false);
6369

6470
}
@@ -67,9 +73,7 @@ internal StatusResponse GetNewStatus()
6773
{
6874
string response = Query("remote/status.json", true, true, -1);
6975
if (string.IsNullOrEmpty(response))
70-
{
7176
return null;
72-
}
7377
response = response.Replace("\\n", "");
7478
List<StatusResponse> raw = JsonConvert.DeserializeObject<List<StatusResponse>>(response);
7579
return raw[0];
@@ -104,7 +108,7 @@ internal string BuildQueryString(bool oauth, bool cfid, int wait, NameValueColle
104108
{
105109
@params = new NameValueCollection();
106110
}
107-
var queryParameter = HttpUtility.ParseQueryString(string.Empty);
111+
NameValueCollection queryParameter = HttpUtility.ParseQueryString(string.Empty);
108112
queryParameter.Add(@params);
109113
queryParameter.Add(new NameValueCollection() {
110114
{ "ref", string.Empty},
@@ -135,7 +139,7 @@ internal string Query(string baseUrl, bool oauth, bool cfid, int wait, NameValue
135139
string response = string.Empty;
136140
try
137141
{
138-
using (var wc = new ExtendedWebClient())
142+
using (ExtendedWebClient wc = new ExtendedWebClient())
139143
{
140144
if (SpotifyLocalAPI.IsSpotifyRunning())
141145
{
@@ -158,7 +162,7 @@ internal async Task<string> QueryAsync(string baseUrl, bool oauth, bool cfid, in
158162
string response = "";
159163
try
160164
{
161-
using (var wc = new ExtendedWebClient())
165+
using (ExtendedWebClient wc = new ExtendedWebClient())
162166
{
163167
if (SpotifyLocalAPI.IsSpotifyRunning())
164168
response = "[ " + await wc.DownloadStringTaskAsync(new Uri(address)).ConfigureAwait(false) + " ]";
@@ -178,7 +182,7 @@ internal int GetTimestamp()
178182

179183
internal WebClient GetWebClientWithUserAgentHeader()
180184
{
181-
var wc = new WebClient();
185+
WebClient wc = new WebClient();
182186

183187
wc.Headers.Add(HttpRequestHeader.UserAgent, "Spotify (1.0.50.41368.gbd68dbef)");
184188

0 commit comments

Comments
 (0)