Ejemplo n.º 1
0
        public void ForEachStructEnumeratorExplicitMembers()
        {
            var counters           = new [] { new Counter(), new Counter(), new Counter() };
            var enumerable_counter = new StructEnumerableCounterExplicitMembers(counters);

            var ec   = Expression.Parameter(typeof(StructEnumerableCounterExplicitMembers), "ec");
            var item = Expression.Variable(typeof(Counter), "c");

            var hitcounter = Expression.Lambda <Action <StructEnumerableCounterExplicitMembers> > (
                CustomExpression.ForEach(
                    item,
                    ec,
                    Expression.Call(item, "Hit", Type.EmptyTypes)),
                ec).Compile();

            hitcounter(enumerable_counter);

            foreach (var counter in counters)
            {
                Assert.AreEqual(1, counter.Count);
                Assert.IsTrue(counter.Disposed);
            }
        }
Ejemplo n.º 2
0
 public Enumerator(StructEnumerableCounterExplicitMembers owner)
     : this()
 {
     this.owner   = owner;
     this.current = -1;
 }