Code review

This commit is contained in:
JustArchi
2019-08-25 19:25:28 +02:00
parent 3278703157
commit d74f13c567
2 changed files with 13 additions and 10 deletions

View File

@@ -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();
}

View File

@@ -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();
}