forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEnumeratorAdapter.cs
48 lines (41 loc) · 874 Bytes
/
EnumeratorAdapter.cs
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
45
46
47
48
using System;
using System.Collections;
using System.Collections.Generic;
namespace NHibernate.Util
{
/// <summary>
/// Wrap a non-generic IEnumerator to provide the generic <see cref="IEnumerator{T}" />
/// interface.
/// </summary>
/// <typeparam name="T">The type of the enumerated elements.</typeparam>
public class EnumeratorAdapter<T> : IEnumerator<T>
{
private readonly IEnumerator _wrapped;
public EnumeratorAdapter(IEnumerator wrapped)
{
_wrapped = wrapped;
}
public void Dispose()
{
var disposable = _wrapped as IDisposable;
if (disposable != null)
disposable.Dispose();
}
public bool MoveNext()
{
return _wrapped.MoveNext();
}
public void Reset()
{
_wrapped.Reset();
}
public T Current
{
get { return (T)_wrapped.Current; }
}
object IEnumerator.Current
{
get { return Current; }
}
}
}