mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-16 08:25:28 +00:00
R# code improvements
This commit is contained in:
@@ -74,9 +74,7 @@ namespace ArchiSteamFarm.IPC.Controllers.Api {
|
||||
}
|
||||
|
||||
if ((ASF.GlobalConfig.AdditionalProperties != null) && (ASF.GlobalConfig.AdditionalProperties.Count > 0)) {
|
||||
if (request.GlobalConfig.AdditionalProperties == null) {
|
||||
request.GlobalConfig.AdditionalProperties = new Dictionary<string, JToken>(ASF.GlobalConfig.AdditionalProperties.Count, ASF.GlobalConfig.AdditionalProperties.Comparer);
|
||||
}
|
||||
request.GlobalConfig.AdditionalProperties ??= new Dictionary<string, JToken>(ASF.GlobalConfig.AdditionalProperties.Count, ASF.GlobalConfig.AdditionalProperties.Comparer);
|
||||
|
||||
foreach ((string key, JToken value) in ASF.GlobalConfig.AdditionalProperties.Where(property => !request.GlobalConfig.AdditionalProperties.ContainsKey(property.Key))) {
|
||||
request.GlobalConfig.AdditionalProperties.Add(key, value);
|
||||
|
||||
@@ -122,9 +122,7 @@ namespace ArchiSteamFarm.IPC.Controllers.Api {
|
||||
}
|
||||
|
||||
if ((bot.BotConfig.AdditionalProperties != null) && (bot.BotConfig.AdditionalProperties.Count > 0)) {
|
||||
if (request.BotConfig.AdditionalProperties == null) {
|
||||
request.BotConfig.AdditionalProperties = new Dictionary<string, JToken>(bot.BotConfig.AdditionalProperties.Count, bot.BotConfig.AdditionalProperties.Comparer);
|
||||
}
|
||||
request.BotConfig.AdditionalProperties ??= new Dictionary<string, JToken>(bot.BotConfig.AdditionalProperties.Count, bot.BotConfig.AdditionalProperties.Comparer);
|
||||
|
||||
foreach ((string key, JToken value) in bot.BotConfig.AdditionalProperties.Where(property => !request.BotConfig.AdditionalProperties.ContainsKey(property.Key))) {
|
||||
request.BotConfig.AdditionalProperties.Add(key, value);
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace ArchiSteamFarm.IPC.Controllers.Api {
|
||||
}
|
||||
}
|
||||
|
||||
foreach (PropertyInfo property in targetType.GetProperties(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).Where(property => property.CanRead && !property.GetMethod.IsPrivate)) {
|
||||
foreach (PropertyInfo property in targetType.GetProperties(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).Where(property => property.CanRead && (property.GetMethod?.IsPrivate == false))) {
|
||||
JsonPropertyAttribute jsonProperty = property.GetCustomAttribute<JsonPropertyAttribute>();
|
||||
|
||||
if (jsonProperty != null) {
|
||||
@@ -81,7 +81,15 @@ namespace ArchiSteamFarm.IPC.Controllers.Api {
|
||||
underlyingType = enumType.GetUnifiedName();
|
||||
|
||||
foreach (object value in Enum.GetValues(targetType)) {
|
||||
body[value.ToString()] = Convert.ChangeType(value, enumType).ToString();
|
||||
string valueText = value.ToString();
|
||||
|
||||
if (string.IsNullOrEmpty(valueText)) {
|
||||
ASF.ArchiLogger.LogNullError(nameof(valueText));
|
||||
|
||||
return BadRequest(new GenericResponse(false, string.Format(Strings.ErrorObjectIsNull, nameof(valueText))));
|
||||
}
|
||||
|
||||
body[valueText] = Convert.ChangeType(value, enumType).ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user