Code cleanup

This commit is contained in:
JustArchi
2017-11-16 22:30:34 +01:00
parent 9b508fbf41
commit c1e6604876
2 changed files with 2 additions and 24 deletions

View File

@@ -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<T> AsReadOnlyCollection<T>(this ICollection<T> source) {
if (source == null) {
ASF.ArchiLogger.LogNullError(nameof(source));
return null;
}
IReadOnlyCollection<T> result = source as IReadOnlyCollection<T> ?? new ReadOnlyCollectionAdapter<T>(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<T> : IReadOnlyCollection<T> {
public int Count => Source.Count;
private readonly ICollection<T> Source;
internal ReadOnlyCollectionAdapter(ICollection<T> source) => Source = source ?? throw new ArgumentNullException(nameof(source));
public IEnumerator<T> GetEnumerator() => Source.GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
}
}