IEnumerator <T> IEnumerable <T> .GetEnumerator()
        {
            lock (this.Session.SyncLock)
            {
                var index = new RecordIndex <TKey>(
                    this.Session,
                    this.RecordManager,
                    this.IndexName,
                    this.Session.SerializerResolver.SerializerFor <Node <TKey> >()
                    );
                var indexEnumerator = new IndexEntryEnumerator <T, TKey>(
                    this.Collection,
                    this.Session,
                    index,
                    this.IsDescending);

                indexEnumerator.SetRange(this.Range);

                foreach (var node in indexEnumerator)
                {
                    var record = RecordManager.GetRecord(node.Pointer);
                    var obj    = Serializer.Deserialize(record.Data);
                    yield return(obj);
                }
            }
        }
Ejemplo n.º 2
0
        IEnumerator <T> IEnumerable <T> .GetEnumerator()
        {
            //execute empty transaction, to apply any comitted but unapplied transactions
            this.Session.Transaction(() => { });
            lock (this.Session.SyncLock)
            {
                foreach (var range in this.Ranges)
                {
                    var index = new RecordIndex <TKey>(
                        this.Session,
                        this.RecordManager,
                        this.IndexName,
                        this.Session.SerializerResolver.SerializerFor <Node <TKey> >()
                        );
                    var indexEnumerator = new IndexEntryEnumerator <T, TKey>(
                        this.Collection,
                        this.Session,
                        index,
                        this.IsDescending);

                    indexEnumerator.SetRange(range);

                    foreach (var node in indexEnumerator)
                    {
                        if (this.ShouldYieldObjectWithAddress(node.Pointer))
                        {
                            var record = RecordManager.GetRecord(node.Pointer);
                            var obj    = Serializer.Deserialize(record.Data);
                            if (this.ShouldYieldObject(obj))
                            {
                                yield return(obj);
                            }
                        }
                    }
                }
            }
        }