Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 42 lines (36 sloc) 0.946 kb
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace sones.Plugins.Index.Helper
{
    public class CloseableEnumerable<T> : ICloseableEnumerable<T>
    {
        IEnumerable<T> _Enumerable;
        Action _Close = null;

        public CloseableEnumerable(IEnumerable<T> myEnumerable, Action myClose = null)
        {
            _Enumerable = myEnumerable;
            _Close = myClose;
        }

        public virtual void Close()
        {
            if (_Close != null)
            {
                _Close();
            }
        }

        public IEnumerator<T> GetEnumerator()
        {
            return _Enumerable.GetEnumerator();
        }

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            return _Enumerable.GetEnumerator();
        }

        public virtual void Dispose()
        {
            Close();
        }
    }
}
Something went wrong with that request. Please try again.