In that case, there is no need for IValueEnumerator — it is the same as IEnumerator except that it is IDisposable. Does it really need to be disposable?
The important part is IValueEnumerable
. But I would call it simply IEnumerable
and define it like this:
public interface IEnumerable<T, TEnumerator>
where TEnumerator : IEnumerator<T>, IDisposable {
TEnumerator GetEnumerator();
}
But you will have a problem in case someone implements a class X
that implements both IEnumerable<T>
and IEnumerable<T, TEnumerator>
. The compiler will say that an extension method like x.Select(e=>e)
is ambiguous between System.Linq.Enumerable.Select
and NetFabric.Hyperlinq.Enumerable.Select
. To avoid this problem, it needs to be derived from IEnumerable<T>
:
public interface IEnumerable<T, TEnumerator> : IEnumerable<T>
where TEnumerator : IEnumerator<T>, IDisposable {
TEnumerator GetEnumerator();
}
I think something like Hyperlinq should be part of my Loyc Core Libraries…