|
@@ -1,5 +1,6 @@ |
|
|
using System.Collections; |
|
|
using System.Collections; |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
|
|
|
using System.Diagnostics; |
|
|
using System.Linq; |
|
|
using System.Linq; |
|
|
|
|
|
|
|
|
namespace Discord.Extensions |
|
|
namespace Discord.Extensions |
|
@@ -11,7 +12,8 @@ namespace Discord.Extensions |
|
|
public static IReadOnlyCollection<TValue> ToReadOnlyCollection<TValue, TSource>(this IEnumerable<TValue> query, IReadOnlyCollection<TSource> source) |
|
|
public static IReadOnlyCollection<TValue> ToReadOnlyCollection<TValue, TSource>(this IEnumerable<TValue> query, IReadOnlyCollection<TSource> source) |
|
|
=> new ConcurrentDictionaryWrapper<TValue, TSource>(source, query); |
|
|
=> new ConcurrentDictionaryWrapper<TValue, TSource>(source, query); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[DebuggerDisplay(@"{DebuggerDisplay,nq}")] |
|
|
internal struct ConcurrentDictionaryWrapper<TValue, TSource> : IReadOnlyCollection<TValue> |
|
|
internal struct ConcurrentDictionaryWrapper<TValue, TSource> : IReadOnlyCollection<TValue> |
|
|
{ |
|
|
{ |
|
|
private readonly IReadOnlyCollection<TSource> _source; |
|
|
private readonly IReadOnlyCollection<TSource> _source; |
|
@@ -26,6 +28,8 @@ namespace Discord.Extensions |
|
|
_query = query; |
|
|
_query = query; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private string DebuggerDisplay => $"Count = {Count}"; |
|
|
|
|
|
|
|
|
public IEnumerator<TValue> GetEnumerator() => _query.GetEnumerator(); |
|
|
public IEnumerator<TValue> GetEnumerator() => _query.GetEnumerator(); |
|
|
IEnumerator IEnumerable.GetEnumerator() => _query.GetEnumerator(); |
|
|
IEnumerator IEnumerable.GetEnumerator() => _query.GetEnumerator(); |
|
|
} |
|
|
} |
|
|