ComponentArgumentsEnumerator
using System.Collections;
using System.Collections.Generic;
namespace Castle.MicroKernel.Context
{
public class ComponentArgumentsEnumerator : IDictionaryEnumerator, IEnumerator
{
private readonly IList<IArgumentsStore> stores;
private int currentStoreIndex;
private IEnumerator<KeyValuePair<object, object>> currentEnumerator;
public object Current => Entry;
public object Key {
get {
if (currentEnumerator == null)
return null;
return currentEnumerator.Current.Key;
}
}
public object Value {
get {
if (currentEnumerator == null)
return null;
return currentEnumerator.Current.Value;
}
}
public DictionaryEntry Entry => new DictionaryEntry(Key, Value);
public ComponentArgumentsEnumerator(IList<IArgumentsStore> stores)
{
this.stores = stores;
currentStoreIndex = -1;
}
public bool MoveNext()
{
if (currentEnumerator != null) {
bool flag = currentEnumerator.MoveNext();
if (!flag) {
currentEnumerator = null;
return MoveNext();
}
return flag;
}
currentStoreIndex++;
if (currentStoreIndex < stores.Count) {
currentEnumerator = stores[currentStoreIndex].GetEnumerator();
return MoveNext();
}
return false;
}
public void Reset()
{
currentEnumerator.Reset();
currentEnumerator = null;
currentStoreIndex = -1;
}
}
}