//-----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation.
//
//-----------------------------------------------------------------------
namespace Microsoft.Isam.Esent.Interop
{
using System.Collections;
using System.Collections.Generic;
///
/// IEnumerable class that takes a delegate to create the enumerator it returns.
///
/// The type returned by the enumerator.
internal class GenericEnumerable : IEnumerable
{
///
/// The delegate used to create the enumerator.
///
private readonly CreateEnumerator enumeratorCreator;
///
/// Initializes a new instance of the class.
///
///
/// The enumerator creator.
///
public GenericEnumerable(CreateEnumerator enumeratorCreator)
{
this.enumeratorCreator = enumeratorCreator;
}
///
/// IEnumerator creating delegate.
///
/// A new enumerator.
public delegate IEnumerator CreateEnumerator();
///
/// Returns an enumerator that iterates through the collection.
///
///
/// A
/// that can be used to iterate through the collection.
///
public IEnumerator GetEnumerator()
{
return this.enumeratorCreator();
}
///
/// Returns an enumerator that iterates through a collection.
///
///
/// A
/// object that can be used to iterate through the collection.
///
IEnumerator IEnumerable.GetEnumerator()
{
return this.GetEnumerator();
}
}
}