mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 06:00:46 +00:00
Misc code review
This commit is contained in:
@@ -32,6 +32,7 @@ using System.Linq;
|
|||||||
namespace ArchiSteamFarm {
|
namespace ArchiSteamFarm {
|
||||||
[SuppressMessage("ReSharper", "ClassCannotBeInstantiated")]
|
[SuppressMessage("ReSharper", "ClassCannotBeInstantiated")]
|
||||||
[SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")]
|
[SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")]
|
||||||
|
[SuppressMessage("ReSharper", "ConvertToConstant.Local")]
|
||||||
[SuppressMessage("ReSharper", "ConvertToConstant.Global")]
|
[SuppressMessage("ReSharper", "ConvertToConstant.Global")]
|
||||||
internal sealed class BotConfig {
|
internal sealed class BotConfig {
|
||||||
internal enum EFarmingOrder : byte {
|
internal enum EFarmingOrder : byte {
|
||||||
@@ -58,10 +59,6 @@ namespace ArchiSteamFarm {
|
|||||||
[JsonProperty]
|
[JsonProperty]
|
||||||
internal string SteamPassword { get; set; }
|
internal string SteamPassword { get; set; }
|
||||||
|
|
||||||
[JsonProperty(Required = Required.DisallowNull)]
|
|
||||||
[SuppressMessage("ReSharper", "ConvertToConstant.Local")]
|
|
||||||
private readonly CryptoHelper.ECryptoMethod PasswordFormat = CryptoHelper.ECryptoMethod.PlainText;
|
|
||||||
|
|
||||||
[JsonProperty]
|
[JsonProperty]
|
||||||
internal string SteamParentalPIN { get; set; } = "0";
|
internal string SteamParentalPIN { get; set; } = "0";
|
||||||
|
|
||||||
@@ -128,6 +125,9 @@ namespace ArchiSteamFarm {
|
|||||||
[JsonProperty(Required = Required.DisallowNull)]
|
[JsonProperty(Required = Required.DisallowNull)]
|
||||||
internal readonly HashSet<uint> GamesPlayedWhileIdle = new HashSet<uint>();
|
internal readonly HashSet<uint> GamesPlayedWhileIdle = new HashSet<uint>();
|
||||||
|
|
||||||
|
[JsonProperty(Required = Required.DisallowNull)]
|
||||||
|
private readonly CryptoHelper.ECryptoMethod PasswordFormat = CryptoHelper.ECryptoMethod.PlainText;
|
||||||
|
|
||||||
internal static BotConfig Load(string filePath) {
|
internal static BotConfig Load(string filePath) {
|
||||||
if (string.IsNullOrEmpty(filePath)) {
|
if (string.IsNullOrEmpty(filePath)) {
|
||||||
Logging.LogNullError(nameof(filePath));
|
Logging.LogNullError(nameof(filePath));
|
||||||
|
|||||||
@@ -25,12 +25,11 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
namespace ArchiSteamFarm {
|
namespace ArchiSteamFarm {
|
||||||
internal sealed class GlobalDatabase {
|
internal sealed class GlobalDatabase : IDisposable {
|
||||||
private static readonly JsonSerializerSettings CustomSerializerSettings = new JsonSerializerSettings {
|
private static readonly JsonSerializerSettings CustomSerializerSettings = new JsonSerializerSettings {
|
||||||
Converters = new List<JsonConverter>(2) {
|
Converters = new List<JsonConverter>(2) {
|
||||||
new IPAddressConverter(),
|
new IPAddressConverter(),
|
||||||
@@ -56,7 +55,6 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[JsonProperty(Required = Required.DisallowNull)]
|
[JsonProperty(Required = Required.DisallowNull)]
|
||||||
[SuppressMessage("ReSharper", "AutoPropertyCanBeMadeGetOnly.Local")]
|
|
||||||
internal readonly InMemoryServerListProvider ServerListProvider = new InMemoryServerListProvider();
|
internal readonly InMemoryServerListProvider ServerListProvider = new InMemoryServerListProvider();
|
||||||
|
|
||||||
private readonly object FileLock = new object();
|
private readonly object FileLock = new object();
|
||||||
@@ -91,7 +89,7 @@ namespace ArchiSteamFarm {
|
|||||||
return globalDatabase;
|
return globalDatabase;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnServerListUpdated(object sender, EventArgs e) => Save();
|
public void Dispose() => ServerListProvider.Dispose();
|
||||||
|
|
||||||
// This constructor is used when creating new database
|
// This constructor is used when creating new database
|
||||||
private GlobalDatabase(string filePath) : this() {
|
private GlobalDatabase(string filePath) : this() {
|
||||||
@@ -104,11 +102,12 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This constructor is used only by deserializer
|
// This constructor is used only by deserializer
|
||||||
[SuppressMessage("ReSharper", "UnusedMember.Local")]
|
|
||||||
private GlobalDatabase() {
|
private GlobalDatabase() {
|
||||||
ServerListProvider.ServerListUpdated += OnServerListUpdated;
|
ServerListProvider.ServerListUpdated += OnServerListUpdated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnServerListUpdated(object sender, EventArgs e) => Save();
|
||||||
|
|
||||||
private void Save() {
|
private void Save() {
|
||||||
string json = JsonConvert.SerializeObject(this, CustomSerializerSettings);
|
string json = JsonConvert.SerializeObject(this, CustomSerializerSettings);
|
||||||
if (string.IsNullOrEmpty(json)) {
|
if (string.IsNullOrEmpty(json)) {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ using Newtonsoft.Json;
|
|||||||
using SteamKit2.Discovery;
|
using SteamKit2.Discovery;
|
||||||
|
|
||||||
namespace ArchiSteamFarm {
|
namespace ArchiSteamFarm {
|
||||||
internal sealed class InMemoryServerListProvider : IServerListProvider {
|
internal sealed class InMemoryServerListProvider : IDisposable, IServerListProvider {
|
||||||
[JsonProperty(Required = Required.DisallowNull)]
|
[JsonProperty(Required = Required.DisallowNull)]
|
||||||
private readonly ConcurrentHashSet<IPEndPoint> Servers = new ConcurrentHashSet<IPEndPoint>();
|
private readonly ConcurrentHashSet<IPEndPoint> Servers = new ConcurrentHashSet<IPEndPoint>();
|
||||||
|
|
||||||
@@ -53,5 +53,7 @@ namespace ArchiSteamFarm {
|
|||||||
ServerListUpdated(this, EventArgs.Empty);
|
ServerListUpdated(this, EventArgs.Empty);
|
||||||
return Task.Delay(0);
|
return Task.Delay(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Dispose() => Servers.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ using Newtonsoft.Json;
|
|||||||
namespace ArchiSteamFarm.JSON {
|
namespace ArchiSteamFarm.JSON {
|
||||||
internal static class GitHub {
|
internal static class GitHub {
|
||||||
[SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")]
|
[SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")]
|
||||||
[SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Local")]
|
|
||||||
internal sealed class ReleaseResponse {
|
internal sealed class ReleaseResponse {
|
||||||
#pragma warning disable 649
|
#pragma warning disable 649
|
||||||
internal sealed class Asset {
|
internal sealed class Asset {
|
||||||
|
|||||||
@@ -343,7 +343,6 @@ namespace ArchiSteamFarm.JSON {
|
|||||||
|
|
||||||
[SuppressMessage("ReSharper", "ClassCannotBeInstantiated")]
|
[SuppressMessage("ReSharper", "ClassCannotBeInstantiated")]
|
||||||
[SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")]
|
[SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")]
|
||||||
[SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Local")]
|
|
||||||
internal sealed class ConfirmationResponse { // Deserialized from JSON
|
internal sealed class ConfirmationResponse { // Deserialized from JSON
|
||||||
#pragma warning disable 649
|
#pragma warning disable 649
|
||||||
[JsonProperty(PropertyName = "success", Required = Required.Always)]
|
[JsonProperty(PropertyName = "success", Required = Required.Always)]
|
||||||
@@ -355,7 +354,6 @@ namespace ArchiSteamFarm.JSON {
|
|||||||
|
|
||||||
[SuppressMessage("ReSharper", "ClassCannotBeInstantiated")]
|
[SuppressMessage("ReSharper", "ClassCannotBeInstantiated")]
|
||||||
[SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")]
|
[SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")]
|
||||||
[SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Local")]
|
|
||||||
internal sealed class ConfirmationDetails { // Deserialized from JSON
|
internal sealed class ConfirmationDetails { // Deserialized from JSON
|
||||||
internal enum EType : byte {
|
internal enum EType : byte {
|
||||||
Unknown,
|
Unknown,
|
||||||
|
|||||||
@@ -81,9 +81,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
private Bot Bot;
|
private Bot Bot;
|
||||||
|
|
||||||
private MobileAuthenticator() {
|
private MobileAuthenticator() { }
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void Init(Bot bot) {
|
internal void Init(Bot bot) {
|
||||||
if (bot == null) {
|
if (bot == null) {
|
||||||
|
|||||||
@@ -26,10 +26,12 @@ using System;
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace ArchiSteamFarm {
|
namespace ArchiSteamFarm {
|
||||||
internal static class Utilities {
|
internal static class Utilities {
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
[SuppressMessage("ReSharper", "UnusedParameter.Global")]
|
[SuppressMessage("ReSharper", "UnusedParameter.Global")]
|
||||||
internal static void Forget(this Task task) { }
|
internal static void Forget(this Task task) { }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user