blob: a44491d0bce42e20e8bac155b84df3525e229436 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
using System;
using System.Collections.Generic;
namespace Org.BouncyCastle.Utilities.Collections
{
internal abstract class ReadOnlyCollection<T>
: ICollection<T>
{
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
public bool IsReadOnly => true;
public void Add(T item) => throw new NotSupportedException();
public void Clear() => throw new NotSupportedException();
public bool Remove(T item) => throw new NotSupportedException();
public abstract bool Contains(T item);
public abstract int Count { get; }
public abstract void CopyTo(T[] array, int arrayIndex);
public abstract IEnumerator<T> GetEnumerator();
}
internal class ReadOnlyCollectionProxy<T>
: ReadOnlyCollection<T>
{
private readonly ICollection<T> m_target;
internal ReadOnlyCollectionProxy(ICollection<T> target)
{
if (target == null)
throw new ArgumentNullException(nameof(target));
m_target = target;
}
public override bool Contains(T item) => m_target.Contains(item);
public override int Count => m_target.Count;
public override void CopyTo(T[] array, int arrayIndex) => m_target.CopyTo(array, arrayIndex);
public override IEnumerator<T> GetEnumerator() => m_target.GetEnumerator();
}
}
|