mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2025-12-17 15:00:29 +00:00
Code review
This commit is contained in:
@@ -58,8 +58,6 @@ namespace ArchiSteamFarm {
|
||||
|
||||
if (!string.IsNullOrEmpty(apiKey) && !apiKey.Equals("null")) {
|
||||
ApiKey = apiKey;
|
||||
} else {
|
||||
ApiKey = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,13 +48,16 @@ namespace ArchiSteamFarm {
|
||||
return 0;
|
||||
}
|
||||
|
||||
ulong result = ulong.Parse(resultString, CultureInfo.InvariantCulture);
|
||||
return result;
|
||||
return ulong.Parse(resultString, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
internal static async Task<HttpResponseMessage> UrlToHttpResponse(string websiteAddress, Dictionary<string, string> cookieVariables = null) {
|
||||
if (string.IsNullOrEmpty(websiteAddress)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
HttpResponseMessage result = null;
|
||||
if (!string.IsNullOrEmpty(websiteAddress)) {
|
||||
|
||||
try {
|
||||
using (HttpClientHandler clientHandler = new HttpClientHandler { UseCookies = false }) {
|
||||
using (HttpClient client = new HttpClient(clientHandler)) {
|
||||
@@ -74,9 +77,10 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logging.LogGenericException("Utilities", e);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -85,8 +89,12 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
|
||||
internal static async Task<HtmlDocument> UrlToHtmlDocument(string websiteAddress, Dictionary<string, string> cookieVariables = null) {
|
||||
if (string.IsNullOrEmpty(websiteAddress)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
HtmlDocument result = null;
|
||||
if (!string.IsNullOrEmpty(websiteAddress)) {
|
||||
|
||||
try {
|
||||
HttpResponseMessage responseMessage = await UrlToHttpResponse(websiteAddress, cookieVariables).ConfigureAwait(false);
|
||||
if (responseMessage != null) {
|
||||
@@ -97,15 +105,20 @@ namespace ArchiSteamFarm {
|
||||
result.LoadHtml(source);
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logging.LogGenericException("Utilities", e);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static async Task<bool> UrlPostRequest(string request, Dictionary<string, string> postData, Dictionary<string, string> cookieVariables = null, string referer = null) {
|
||||
if (string.IsNullOrEmpty(request) || postData == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool result = false;
|
||||
if (!string.IsNullOrEmpty(request)) {
|
||||
|
||||
try {
|
||||
using (HttpClientHandler clientHandler = new HttpClientHandler { UseCookies = false }) {
|
||||
using (HttpClient client = new HttpClient(clientHandler)) {
|
||||
@@ -128,15 +141,20 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logging.LogGenericException("Utilities", e);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static async Task<HttpResponseMessage> UrlPostRequestWithResponse(string request, Dictionary<string, string> postData, Dictionary<string, string> cookieVariables = null, string referer = null) {
|
||||
if (string.IsNullOrEmpty(request) || postData == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
HttpResponseMessage result = null;
|
||||
if (!string.IsNullOrEmpty(request)) {
|
||||
|
||||
try {
|
||||
using (HttpClientHandler clientHandler = new HttpClientHandler { UseCookies = false }) {
|
||||
using (HttpClient client = new HttpClient(clientHandler)) {
|
||||
@@ -159,9 +177,10 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logging.LogGenericException("Utilities", e);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user