From c1e660487648c623e130e22ec53fce7dde9ce472 Mon Sep 17 00:00:00 2001 From: JustArchi Date: Thu, 16 Nov 2017 22:30:34 +0100 Subject: [PATCH] Code cleanup --- ArchiSteamFarm/Bot.cs | 3 ++- ArchiSteamFarm/Utilities.cs | 23 ----------------------- 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs index f0feb21ce..a34289a58 100755 --- a/ArchiSteamFarm/Bot.cs +++ b/ArchiSteamFarm/Bot.cs @@ -25,6 +25,7 @@ using System; using System.Collections.Concurrent; using System.Collections.Generic; +using System.Collections.Immutable; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; @@ -1806,7 +1807,7 @@ namespace ArchiSteamFarm { if (OwnedPackageIDs.Count > 0) { if (!BotConfig.IdleRefundableGames || (BotConfig.FarmingOrder == BotConfig.EFarmingOrder.RedeemDateTimesAscending) || (BotConfig.FarmingOrder == BotConfig.EFarmingOrder.RedeemDateTimesDescending)) { - Program.GlobalDatabase.RefreshPackageIDs(this, OwnedPackageIDs.Keys.AsReadOnlyCollection()).Forget(); + Program.GlobalDatabase.RefreshPackageIDs(this, OwnedPackageIDs.Keys.ToImmutableHashSet()).Forget(); } } diff --git a/ArchiSteamFarm/Utilities.cs b/ArchiSteamFarm/Utilities.cs index 554047b00..d3057b8a9 100644 --- a/ArchiSteamFarm/Utilities.cs +++ b/ArchiSteamFarm/Utilities.cs @@ -23,7 +23,6 @@ */ using System; -using System.Collections; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Globalization; @@ -39,16 +38,6 @@ namespace ArchiSteamFarm { internal static class Utilities { private static readonly Random Random = new Random(); - internal static IReadOnlyCollection AsReadOnlyCollection(this ICollection source) { - if (source == null) { - ASF.ArchiLogger.LogNullError(nameof(source)); - return null; - } - - IReadOnlyCollection result = source as IReadOnlyCollection ?? new ReadOnlyCollectionAdapter(source); - return result; - } - [SuppressMessage("ReSharper", "UnusedParameter.Global")] [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void Forget(this object obj) { } @@ -184,17 +173,5 @@ namespace ArchiSteamFarm { return result; } - - private sealed class ReadOnlyCollectionAdapter : IReadOnlyCollection { - public int Count => Source.Count; - - private readonly ICollection Source; - - internal ReadOnlyCollectionAdapter(ICollection source) => Source = source ?? throw new ArgumentNullException(nameof(source)); - - public IEnumerator GetEnumerator() => Source.GetEnumerator(); - - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); - } } } \ No newline at end of file