mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-06 17:10:13 +00:00
Code review
This commit is contained in:
@@ -203,21 +203,12 @@ namespace ArchiSteamFarm {
|
||||
throw new ArgumentNullException(nameof(botName) + " || " + nameof(botConfig) + " || " + nameof(botDatabase));
|
||||
}
|
||||
|
||||
if (Bots.ContainsKey(botName)) {
|
||||
throw new ArgumentException(string.Format(Strings.ErrorIsInvalid, nameof(botName)));
|
||||
}
|
||||
|
||||
BotName = botName;
|
||||
BotConfig = botConfig;
|
||||
BotDatabase = botDatabase;
|
||||
|
||||
ArchiLogger = new ArchiLogger(botName);
|
||||
|
||||
// Register bot as available for ASF
|
||||
if (!Bots.TryAdd(botName, this)) {
|
||||
throw new ArgumentException(string.Format(Strings.ErrorIsInvalid, nameof(botName)));
|
||||
}
|
||||
|
||||
if (HasMobileAuthenticator) {
|
||||
BotDatabase.MobileAuthenticator.Init(this);
|
||||
}
|
||||
@@ -1080,6 +1071,7 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
|
||||
Bot bot;
|
||||
|
||||
await BotsSemaphore.WaitAsync().ConfigureAwait(false);
|
||||
|
||||
try {
|
||||
@@ -1088,6 +1080,13 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
|
||||
bot = new Bot(botName, botConfig, botDatabase);
|
||||
|
||||
if (!Bots.TryAdd(botName, bot)) {
|
||||
ASF.ArchiLogger.LogNullError(nameof(bot));
|
||||
bot.Dispose();
|
||||
|
||||
return;
|
||||
}
|
||||
} finally {
|
||||
BotsSemaphore.Release();
|
||||
}
|
||||
|
||||
@@ -42,7 +42,11 @@ namespace ArchiSteamFarm.Collections {
|
||||
Enumerator = collection.GetEnumerator();
|
||||
}
|
||||
|
||||
public void Dispose() => Lock.Dispose();
|
||||
public void Dispose() {
|
||||
Enumerator.Dispose();
|
||||
Lock.Dispose();
|
||||
}
|
||||
|
||||
public bool MoveNext() => Enumerator.MoveNext();
|
||||
public void Reset() => Enumerator.Reset();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user