mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2025-12-19 15:58:39 +00:00
Code review
This commit is contained in:
@@ -90,10 +90,7 @@
|
|||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.ServiceModel" />
|
<Reference Include="System.ServiceModel" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
<Reference Include="System.Data" />
|
|
||||||
<Reference Include="System.Net.Http" />
|
<Reference Include="System.Net.Http" />
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ namespace ArchiSteamFarm {
|
|||||||
private readonly SteamUser SteamUser;
|
private readonly SteamUser SteamUser;
|
||||||
private readonly Trading Trading;
|
private readonly Trading Trading;
|
||||||
|
|
||||||
internal bool KeepRunning { get; private set; } = false;
|
internal bool KeepRunning { get; private set; }
|
||||||
|
|
||||||
private bool InvalidPassword, LoggedInElsewhere;
|
private bool InvalidPassword, LoggedInElsewhere;
|
||||||
private string AuthCode, TwoFactorAuth;
|
private string AuthCode, TwoFactorAuth;
|
||||||
@@ -249,7 +249,6 @@ namespace ArchiSteamFarm {
|
|||||||
Logging.LogGenericWarning("If issue persists, consider removing and readding ASF 2FA", BotName);
|
Logging.LogGenericWarning("If issue persists, consider removing and readding ASF 2FA", BotName);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logging.LogGenericException(e, BotName);
|
Logging.LogGenericException(e, BotName);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,8 +40,7 @@ namespace ArchiSteamFarm {
|
|||||||
private const byte DefaultFarmingDelay = 5;
|
private const byte DefaultFarmingDelay = 5;
|
||||||
private const byte DefaultHttpTimeout = 60;
|
private const byte DefaultHttpTimeout = 60;
|
||||||
private const ushort DefaultWCFPort = 1242;
|
private const ushort DefaultWCFPort = 1242;
|
||||||
|
private const ProtocolType DefaultSteamProtocol = ProtocolType.Tcp;
|
||||||
private static readonly ProtocolType DefaultSteamProtocol = ProtocolType.Tcp;
|
|
||||||
|
|
||||||
// This is hardcoded blacklist which should not be possible to change
|
// This is hardcoded blacklist which should not be possible to change
|
||||||
internal static readonly HashSet<uint> GlobalBlacklist = new HashSet<uint> { 267420, 303700, 335590, 368020, 425280 };
|
internal static readonly HashSet<uint> GlobalBlacklist = new HashSet<uint> { 267420, 303700, 335590, 368020, 425280 };
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[JsonProperty(Required = Required.DisallowNull)]
|
[JsonProperty(Required = Required.DisallowNull)]
|
||||||
private uint _CellID = 0;
|
private uint _CellID;
|
||||||
|
|
||||||
internal static GlobalDatabase Load() {
|
internal static GlobalDatabase Load() {
|
||||||
if (!File.Exists(FilePath)) {
|
if (!File.Exists(FilePath)) {
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace ArchiSteamFarm {
|
|||||||
internal static class Logging {
|
internal static class Logging {
|
||||||
private static readonly object FileLock = new object();
|
private static readonly object FileLock = new object();
|
||||||
|
|
||||||
private static bool LogToFile = false;
|
private static bool LogToFile;
|
||||||
|
|
||||||
internal static void Init() {
|
internal static void Init() {
|
||||||
LogToFile = Program.GlobalConfig.LogToFile;
|
LogToFile = Program.GlobalConfig.LogToFile;
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ namespace ArchiSteamFarm {
|
|||||||
private readonly Bot Bot;
|
private readonly Bot Bot;
|
||||||
private readonly SemaphoreSlim TradesSemaphore = new SemaphoreSlim(1);
|
private readonly SemaphoreSlim TradesSemaphore = new SemaphoreSlim(1);
|
||||||
|
|
||||||
private byte ParsingTasks = 0;
|
private byte ParsingTasks;
|
||||||
|
|
||||||
internal static async Task LimitInventoryRequestsAsync() {
|
internal static async Task LimitInventoryRequestsAsync() {
|
||||||
await InventorySemaphore.WaitAsync().ConfigureAwait(false);
|
await InventorySemaphore.WaitAsync().ConfigureAwait(false);
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ using System.IO;
|
|||||||
|
|
||||||
namespace ConfigGenerator {
|
namespace ConfigGenerator {
|
||||||
internal class ASFConfig {
|
internal class ASFConfig {
|
||||||
internal static HashSet<ASFConfig> ASFConfigs = new HashSet<ASFConfig>();
|
internal static readonly HashSet<ASFConfig> ASFConfigs = new HashSet<ASFConfig>();
|
||||||
|
|
||||||
internal string FilePath { get; set; }
|
internal string FilePath { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ namespace ConfigGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This constructor is used only by deserializer
|
// This constructor is used only by deserializer
|
||||||
private BotConfig() : base() { }
|
private BotConfig() { }
|
||||||
|
|
||||||
private BotConfig(string filePath) : base(filePath) {
|
private BotConfig(string filePath) : base(filePath) {
|
||||||
FilePath = filePath;
|
FilePath = filePath;
|
||||||
|
|||||||
@@ -44,14 +44,8 @@
|
|||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
|
||||||
<Reference Include="Microsoft.CSharp" />
|
|
||||||
<Reference Include="System.Data" />
|
|
||||||
<Reference Include="System.Drawing" />
|
<Reference Include="System.Drawing" />
|
||||||
<Reference Include="System.Net.Http" />
|
|
||||||
<Reference Include="System.Windows.Forms" />
|
<Reference Include="System.Windows.Forms" />
|
||||||
<Reference Include="System.Xml" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="ASFConfig.cs" />
|
<Compile Include="ASFConfig.cs" />
|
||||||
|
|||||||
@@ -27,12 +27,9 @@ using System.Windows.Forms;
|
|||||||
|
|
||||||
namespace ConfigGenerator {
|
namespace ConfigGenerator {
|
||||||
internal class ConfigPage : TabPage {
|
internal class ConfigPage : TabPage {
|
||||||
|
|
||||||
internal readonly ASFConfig ASFConfig;
|
internal readonly ASFConfig ASFConfig;
|
||||||
|
|
||||||
private EnhancedPropertyGrid EnhancedPropertyGrid;
|
internal ConfigPage(ASFConfig config) {
|
||||||
|
|
||||||
internal ConfigPage(ASFConfig config) : base() {
|
|
||||||
if (config == null) {
|
if (config == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -41,17 +38,12 @@ namespace ConfigGenerator {
|
|||||||
|
|
||||||
RefreshText();
|
RefreshText();
|
||||||
|
|
||||||
EnhancedPropertyGrid = new EnhancedPropertyGrid(config);
|
EnhancedPropertyGrid enhancedPropertyGrid = new EnhancedPropertyGrid(config);
|
||||||
Controls.Add(EnhancedPropertyGrid);
|
Controls.Add(enhancedPropertyGrid);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void RefreshText() {
|
internal void RefreshText() {
|
||||||
Text = Path.GetFileNameWithoutExtension(ASFConfig.FilePath);
|
Text = Path.GetFileNameWithoutExtension(ASFConfig.FilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeComponent() {
|
|
||||||
SuspendLayout();
|
|
||||||
ResumeLayout(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,9 +26,9 @@ using System.Windows.Forms;
|
|||||||
|
|
||||||
namespace ConfigGenerator {
|
namespace ConfigGenerator {
|
||||||
internal sealed class EnhancedPropertyGrid : PropertyGrid {
|
internal sealed class EnhancedPropertyGrid : PropertyGrid {
|
||||||
private ASFConfig ASFConfig;
|
private readonly ASFConfig ASFConfig;
|
||||||
|
|
||||||
internal EnhancedPropertyGrid(ASFConfig config) : base() {
|
internal EnhancedPropertyGrid(ASFConfig config) {
|
||||||
if (config == null) {
|
if (config == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -66,7 +66,6 @@ namespace ConfigGenerator {
|
|||||||
if (globalConfig.SteamOwnerID != 0) {
|
if (globalConfig.SteamOwnerID != 0) {
|
||||||
Tutorial.OnAction(Tutorial.EPhase.GlobalConfigReady);
|
Tutorial.OnAction(Tutorial.EPhase.GlobalConfigReady);
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,8 +40,7 @@ namespace ConfigGenerator {
|
|||||||
private const byte DefaultFarmingDelay = 5;
|
private const byte DefaultFarmingDelay = 5;
|
||||||
private const byte DefaultHttpTimeout = 60;
|
private const byte DefaultHttpTimeout = 60;
|
||||||
private const ushort DefaultWCFPort = 1242;
|
private const ushort DefaultWCFPort = 1242;
|
||||||
|
private const ProtocolType DefaultSteamProtocol = ProtocolType.Tcp;
|
||||||
private static readonly ProtocolType DefaultSteamProtocol = ProtocolType.Tcp;
|
|
||||||
|
|
||||||
// This is hardcoded blacklist which should not be possible to change
|
// This is hardcoded blacklist which should not be possible to change
|
||||||
internal static readonly HashSet<uint> GlobalBlacklist = new HashSet<uint> { 267420, 303700, 335590, 368020, 425280 };
|
internal static readonly HashSet<uint> GlobalBlacklist = new HashSet<uint> { 267420, 303700, 335590, 368020, 425280 };
|
||||||
@@ -161,7 +160,7 @@ namespace ConfigGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This constructor is used only by deserializer
|
// This constructor is used only by deserializer
|
||||||
private GlobalConfig() : base() { }
|
private GlobalConfig() { }
|
||||||
|
|
||||||
private GlobalConfig(string filePath) : base(filePath) {
|
private GlobalConfig(string filePath) : base(filePath) {
|
||||||
FilePath = filePath;
|
FilePath = filePath;
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
@@ -31,20 +32,11 @@ namespace ConfigGenerator {
|
|||||||
public partial class MainForm : Form {
|
public partial class MainForm : Form {
|
||||||
private const byte ReservedTabs = 3;
|
private const byte ReservedTabs = 3;
|
||||||
|
|
||||||
|
private readonly TabPage NewTab = new TabPage { Text = "+" };
|
||||||
|
private readonly TabPage RemoveTab = new TabPage { Text = "-" };
|
||||||
|
private readonly TabPage RenameTab = new TabPage { Text = "~" };
|
||||||
|
|
||||||
private ConfigPage ASFTab;
|
private ConfigPage ASFTab;
|
||||||
|
|
||||||
private TabPage RemoveTab = new TabPage() {
|
|
||||||
Text = "-",
|
|
||||||
};
|
|
||||||
|
|
||||||
private TabPage RenameTab = new TabPage() {
|
|
||||||
Text = "~",
|
|
||||||
};
|
|
||||||
|
|
||||||
private TabPage NewTab = new TabPage() {
|
|
||||||
Text = "+",
|
|
||||||
};
|
|
||||||
|
|
||||||
private TabPage OldTab;
|
private TabPage OldTab;
|
||||||
|
|
||||||
public MainForm() {
|
public MainForm() {
|
||||||
@@ -73,7 +65,7 @@ namespace ConfigGenerator {
|
|||||||
Tutorial.Enabled = false;
|
Tutorial.Enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
MainTab.TabPages.AddRange(new TabPage[] { RemoveTab, RenameTab, NewTab });
|
MainTab.TabPages.AddRange(new[] { RemoveTab, RenameTab, NewTab });
|
||||||
Tutorial.OnAction(Tutorial.EPhase.Start);
|
Tutorial.OnAction(Tutorial.EPhase.Start);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,7 +178,7 @@ namespace ConfigGenerator {
|
|||||||
Tutorial.OnAction(Tutorial.EPhase.Shown);
|
Tutorial.OnAction(Tutorial.EPhase.Shown);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MainForm_HelpButtonClicked(object sender, System.ComponentModel.CancelEventArgs e) {
|
private void MainForm_HelpButtonClicked(object sender, CancelEventArgs e) {
|
||||||
if (sender == null || e == null) {
|
if (sender == null || e == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,10 +36,7 @@ namespace ConfigGenerator {
|
|||||||
|
|
||||||
private const string ASFDirectory = "ArchiSteamFarm";
|
private const string ASFDirectory = "ArchiSteamFarm";
|
||||||
|
|
||||||
private static readonly Assembly Assembly = Assembly.GetExecutingAssembly();
|
private static readonly string ExecutableDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||||
private static readonly string ExecutableFile = Assembly.Location;
|
|
||||||
private static readonly string ExecutableName = Path.GetFileName(ExecutableFile);
|
|
||||||
private static readonly string ExecutableDirectory = Path.GetDirectoryName(ExecutableFile);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The main entry point for the application.
|
/// The main entry point for the application.
|
||||||
|
|||||||
Reference in New Issue
Block a user