示例#1
0
            private void DestroyCurrent()
            {
                if (_current != null)
                {
                    _current.Destroy();
                }

                _current = null;
            }
示例#2
0
            public bool MoveNext()
            {
                // The caller may have stashed a reference to the "view" away somewhere, so we need
                // to allocate a new view object.
                // The common use for this at the moment will be where T is a COM RCW class; and as
                // such one would expect construction / destruction of T to dwarf the 24 or 32 bytes
                // of GC overhead per element when iterating. (Particularly given that view objects
                // should be short lived and stay on ephemeral GC generations)
                // If GC profiling shows that DisposableEnumerableView objects are a lot of GC overhead,
                // one may need to replace this wrapper with something that sacrifices some amount of
                // safety for perf.

                this.DestroyCurrent();
                if (_backingEnumerator.MoveNext())
                {
                    _current = new DisposableEnumerableView <T>(_backingEnumerator.Current);
                    return(true);
                }

                return(false);
            }