forked from libgit2/libgit2sharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDisposableEnumerable.cs
More file actions
39 lines (33 loc) · 848 Bytes
/
Copy pathDisposableEnumerable.cs
File metadata and controls
39 lines (33 loc) · 848 Bytes
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
using System;
using System.Collections;
using System.Collections.Generic;
namespace LibGit2Sharp.Core
{
internal class DisposableEnumerable<T> : IEnumerable<T>, IDisposable where T : IDisposable
{
private readonly IList<T> enumerable;
public DisposableEnumerable(IList<T> enumerable)
{
this.enumerable = enumerable;
}
public int Count
{
get { return enumerable.Count; }
}
public IEnumerator<T> GetEnumerator()
{
return enumerable.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
public void Dispose()
{
foreach (var entry in enumerable)
{
entry.Dispose();
}
}
}
}