Exemplo n.º 1
0
        private static IEnumerable <CollectionOperation <T> > Enumerate([NotNull] ICollectionResetOperation <T> reset)
        {
            yield return(CollectionOperation <T> .OnClear());

            if (reset.Items != null)
            {
                foreach (var item in reset.Items)
                {
                    yield return(CollectionOperation <T> .OnAdd(item));
                }
            }
        }
Exemplo n.º 2
0
        public void Add(IDictionary other, CollectionOperation op, bool filterResult = true)
        {
            IDictionaryEnumerator ide = other.GetEnumerator();

            while (ide.MoveNext())
            {
                if (EvaluateFilter(ide.Key, filterResult))
                {
                    AddObject(ide.Key, op);
                }
            }
        }
Exemplo n.º 3
0
        internal override void ExecuteInternal(QueryContext queryContext, CollectionOperation mergeType)
        {
            AttributeIndex index = queryContext.Index;
            IIndexStore    store = ((MemberFunction)functor).GetStore(index);

            if (store != null)
            {
                members = queryContext.AttributeValues[((MemberFunction)functor).MemberName] as ArrayList;
                if (members == null)
                {
                    if (queryContext.AttributeValues.Count > 0)
                    {
                        members = new ArrayList();
                        members.Add(queryContext.AttributeValues[((MemberFunction)functor).MemberName]);
                    }
                    else
                    {
                        throw new Exception("Value(s) not specified for indexed attribute " + ((MemberFunction)functor).MemberName + ".");
                    }
                }

                IQueryResult tempResult = queryContext.InternalQueryResult;
                queryContext.InternalQueryResult = new Common.Queries.HashedQueryResult();


                if (!Inverse)
                {
                    for (int i = 0; i < members.Count; i++)
                    {
                        store.GetData(members[i], ComparisonType.EQUALS, queryContext.InternalQueryResult, CollectionOperation.Union);
                    }
                }
                else
                {
                    store.GetData(members[0], ComparisonType.NOT_EQUALS, queryContext.InternalQueryResult, CollectionOperation.Union);
                    if (queryContext.InternalQueryResult != null)
                    {
                        if (queryContext.InternalQueryResult.Count > 0)
                        {
                            for (int i = 1; i < members.Count; i++)
                            {
                                store.GetData(members[i], ComparisonType.EQUALS, queryContext.InternalQueryResult, CollectionOperation.Subtract);
                            }
                        }
                    }
                }
                queryContext.InternalQueryResult.Merge(tempResult, mergeType);
            }
            else
            {
                throw new AttributeIndexNotDefined("Index is not defined for attribute '" + ((MemberFunction)functor).MemberName + "'");
            }
        }
Exemplo n.º 4
0
        internal void ProcessAck(OperationAction action, Guid objectId)
        {
            CollectionOperation firstOp = this.LocalOperations[0];

            if (firstOp.Action == action && firstOp.ObjectId == objectId)
            {
                this.LocalOperations.RemoveAt(0);
            }
            else
            {
                Debug.Assert(false, "Received ack for unknown or out of order operation");
            }
        }
Exemplo n.º 5
0
        public void AddObject(object obj, CollectionOperation op)
        {
            if (_excludeResults != null && _excludeResults.ContainsKey(obj))
            {
                return;
            }

            if (!(_resultKeys.ContainsKey(obj)))
            {
                _resultKeys[obj] = null;
                _wrappedResult.AddObject(obj, op);
            }
        }
Exemplo n.º 6
0
        private void ApplyTransform(OrderedCollectionEntry collection, ref CollectionOperation incoming)
        {
            List <CollectionOperation> updatedOperations = new List <CollectionOperation>();

            foreach (var operation in collection.LocalOperations)
            {
                CollectionOperation newOperation;
                CollectionOperation.ApplyTransform(operation, ref incoming, out newOperation);
                updatedOperations.Add(newOperation);
            }

            // Replace local operations with updated, transformed versions
            collection.LocalOperations = updatedOperations;
        }
Exemplo n.º 7
0
        internal override void ExecuteInternal(QueryContext queryContext, CollectionOperation mergeType)
        {
            AttributeIndex index = queryContext.Index;
            IIndexStore    store = ((MemberFunction)functor).GetStore(index);

            if (store != null)
            {
                var values = GetComparibleValues(queryContext);

                IQueryResult tempResult = queryContext.InternalQueryResult;
                queryContext.InternalQueryResult = new Common.Queries.HashedQueryResult(queryContext.KeyFilter, queryContext.CompoundFilter);


                if (!Inverse)
                {
                    for (int i = 0; i < values.Count; i++)
                    {
                        if (queryContext.CancellationToken != null && queryContext.CancellationToken.IsCancellationRequested)
                        {
                            throw new OperationCanceledException(ExceptionsResource.OperationFailed);
                        }

                        store.GetData(values[i], ComparisonType.EQUALS, queryContext.InternalQueryResult, CollectionOperation.Union, queryContext.CancellationToken);
                    }
                }
                else
                {
                    store.GetData(values[0], ComparisonType.NOT_EQUALS, queryContext.InternalQueryResult, CollectionOperation.Union, queryContext.CancellationToken);
                    if (queryContext.InternalQueryResult != null)
                    {
                        if (queryContext.InternalQueryResult.Count > 0)
                        {
                            for (int i = 1; i < values.Count; i++)
                            {
                                if (queryContext.CancellationToken != null && queryContext.CancellationToken.IsCancellationRequested)
                                {
                                    throw new OperationCanceledException(ExceptionsResource.OperationFailed);
                                }
                                store.GetData(values[i], ComparisonType.EQUALS, queryContext.InternalQueryResult, CollectionOperation.Subtract, queryContext.CancellationToken);
                            }
                        }
                    }
                }
                queryContext.InternalQueryResult.Merge(tempResult, mergeType);
            }
            else
            {
                throw new AttributeIndexNotDefined("Index is not defined for attribute '" + ((MemberFunction)functor).MemberName + "'");
            }
        }
Exemplo n.º 8
0
        public async Task <ActionResult> AcceptCollection(int id)
        {
            var collection = await _db.Collections.Include(c => c.Operations).Include(c => c.Provider)
                             .Include(c => c.Collector)
                             .FirstOrDefaultAsync(c => c.CollectionId == id);

            if (collection == null)
            {
                return(PartialView("Error", new [] { "Инкассация не найдена" }));
            }

            var acceptedOperation = collection.Operations
                                    .OrderByDescending(o => o.OperationDateTime).Take(1)
                                    .FirstOrDefault();

            if (acceptedOperation == null || acceptedOperation.OperationTypeId == CollectionOperationType.COType.Accepted)
            {
                return(RedirectToAction("IncomingCollections"));
            }

            var collectionAmount = collection.Amount;

            if (collection.Provider != null)
            {
                collection.Provider.Balance -= collectionAmount;
            }

            collection.Collector.Balance += collectionAmount;

            var operation = new CollectionOperation
            {
                Collection        = collection,
                OperationDateTime = DateTime.Now,
                OperationTypeId   = CollectionOperationType.COType.Accepted
            };

            var user = await _userManager.FindByIdAsync(_userManager.GetUserId(User));

            using (var transaction = await _db.Database.BeginTransactionAsync())
            {
                _db.CollectionOperations.Add(operation);
                _db.SetUserContext(user.Id);
                await _db.SaveChangesAsync();

                transaction.Commit();
            }

            return(RedirectToAction("IncomingCollections"));
        }
Exemplo n.º 9
0
        public void Add(IDictionary other, CollectionOperation op)
        {
            switch (op)
            {
            case CollectionOperation.Union:
                _resultKeys.AddRange(other.Keys);
                break;

            case CollectionOperation.Intersection:
                throw new NotImplementedException();

            case CollectionOperation.Subtract:
                throw new NotImplementedException();
            }
        }
Exemplo n.º 10
0
        public void AddObject(object obj, CollectionOperation op)
        {
            switch (op)
            {
            case CollectionOperation.Union:
                _resultKeys.Add(obj);
                break;

            case CollectionOperation.Intersection:
                throw new NotImplementedException();

            case CollectionOperation.Subtract:
                throw new NotImplementedException();
            }
        }
Exemplo n.º 11
0
        public void Mark(CollectionOperation mergeType)
        {
            switch (mergeType)
            {
            case CollectionOperation.Union:
                break;

            case CollectionOperation.Intersection:
                _resultKeys = _temp;
                _temp       = new HashVector();
                break;

            case CollectionOperation.Subtract:
                break;
            }
        }
Exemplo n.º 12
0
        internal override void Execute(QueryContext queryContext, Predicate nextPredicate)
        {
            for (int i = 0; i < members.Count; i++)
            {
                Predicate predicate         = (Predicate)members[i];
                bool      isOfTypePredicate = predicate is IsOfTypePredicate;

                if (isOfTypePredicate)
                {
                    predicate.Execute(queryContext, (Predicate)members[++i]);
                }
                else
                {
                    CollectionOperation mergeType = (Inverse == true || (queryContext.InternalQueryResult.Count == 0 & i == 0)) ? CollectionOperation.Union : CollectionOperation.Intersection;
                    predicate.ExecuteInternal(queryContext, mergeType);
                }
            }
        }
Exemplo n.º 13
0
        public void Add(IDictionary other, CollectionOperation mergeType, bool filterResult = true)
        {
            IDictionaryEnumerator ide = other.GetEnumerator();

            switch (mergeType)
            {
            case CollectionOperation.Union:
            {
                while (ide.MoveNext())
                {
                    if (EvaluateFilter(ide.Key, filterResult))
                    {
                        _resultKeys[ide.Key] = null;
                    }
                }
            }
            break;

            case CollectionOperation.Intersection:
                while (ide.MoveNext())
                {
                    if (EvaluateFilter(ide.Key, filterResult))
                    {
                        if (_resultKeys.Contains(ide.Key))
                        {
                            _temp[ide.Key] = null;
                        }
                    }
                }
                break;

            case CollectionOperation.Subtract:
                while (ide.MoveNext())
                {
                    if (EvaluateFilter(ide.Key, filterResult))
                    {
                        _resultKeys.Remove(ide.Key);
                    }
                }
                break;
            }
        }
Exemplo n.º 14
0
        public void AddObject(object obj, CollectionOperation op)
        {
            switch (op)
            {
            case CollectionOperation.Union:
                _resultKeys[obj] = null;
                break;

            case CollectionOperation.Intersection:
                if (_resultKeys.Contains(obj))
                {
                    _temp[obj] = null;
                }
                break;

            case CollectionOperation.Subtract:
                _resultKeys.Remove(obj);
                break;
            }
        }
Exemplo n.º 15
0
        private void MergeInternal(HashSet <object> other, CollectionOperation op)
        {
            switch (op)
            {
            case CollectionOperation.Union:
                this._resultKeys.UnionWith(other);
                break;

            case CollectionOperation.Intersection:
                this._resultKeys.IntersectWith(other);
                break;

            case CollectionOperation.Subtract:
                foreach (object obj in other)
                {
                    this._resultKeys.Remove(obj);
                }
                break;
            }
        }
Exemplo n.º 16
0
        public async Task <ActionResult> CreateCollection(CreateCollectionModel model)
        {
            var collection = new Collection
            {
                Amount      = model.Amount,
                PaymentType = model.PaymentType,
                ProviderId  = model.ProviderId,
                CollectorId = model.SelectedCollector,
                Comment     = model.Comment
            };

            var operation = new CollectionOperation
            {
                Collection        = collection,
                OperationDateTime = DateTime.Now,
                OperationTypeId   = CollectionOperationType.COType.New
            };

            _db.CollectionOperations.Add(operation);
            await _db.SaveChangesAsync();

            return(RedirectToAction(model.RedirectAction));
        }
Exemplo n.º 17
0
        internal override void ExecuteInternal(QueryContext queryContext, CollectionOperation mergeType)
        {
            AttributeIndex index = queryContext.Index;
            IIndexStore    store = ((MemberFunction)functor).GetStore(index);

            if (store != null)
            {
                ClusteredArrayList keyList = null;

                if (Inverse)
                {
                    store.GetData(generator.Evaluate(((MemberFunction)functor).MemberName, queryContext.AttributeValues), ComparisonType.NOT_EQUALS, queryContext.InternalQueryResult, mergeType);
                }
                else
                {
                    store.GetData(generator.Evaluate(((MemberFunction)functor).MemberName, queryContext.AttributeValues), ComparisonType.EQUALS, queryContext.InternalQueryResult, mergeType);
                }
            }
            else
            {
                throw new AttributeIndexNotDefined("Index is not defined for attribute '" + ((MemberFunction)functor).MemberName + "'");
            }
        }
Exemplo n.º 18
0
        override internal void OnObjectInserted(ObjectInsertedPayload data)
        {
            Debug.Assert(this.IsConnected == false || this.OperationSequence == 0 || data.OperationSequence == this.OperationSequence + 1);
            this.OperationSequence = data.OperationSequence;

            // Check if this is a locally pending insert, if so remove the insert from the list of LocalOperations
            if (data.ClientId == this.client.ClientId)
            {
                this.ProcessAck(OperationAction.Insert, data.ObjectId);
                return;
            }

            // Apply transformation, update index
            CollectionOperation operation = new CollectionOperation(data);

            this.ApplyTransform(this, ref operation);
            data.Parent.Index = operation.ObjectIndex;

            if (operation.ApplyOperation)
            {
                BaseOnObjectInserted(data);
            }
        }
Exemplo n.º 19
0
        internal override void Execute(QueryContext queryContext, Predicate nextPredicate)
        {
            for (int i = 0; i < members.Count; i++)
            {
                if (queryContext.CancellationToken != null && queryContext.CancellationToken.IsCancellationRequested)
                {
                    throw new OperationCanceledException(ExceptionsResource.OperationFailed);
                }

                Predicate predicate         = (Predicate)members[i];
                bool      isOfTypePredicate = predicate is IsOfTypePredicate;

                if (isOfTypePredicate)
                {
                    predicate.Execute(queryContext, (Predicate)members[++i]);
                }
                else
                {
                    CollectionOperation mergeType = (Inverse == true || (queryContext.InternalQueryResult.Count == 0 & i == 0)) ? CollectionOperation.Union : CollectionOperation.Intersection;
                    predicate.ExecuteInternal(queryContext, mergeType);
                }
            }
        }
Exemplo n.º 20
0
        internal override void ExecuteInternal(QueryContext queryContext, CollectionOperation mergeType)
        {
            bool sortAscending      = true;
            ClusteredArrayList keys = new ClusteredArrayList();

            if (Inverse)
            {
                sortAscending = false;
            }

            SortedList tmpList = new SortedList(new QueryResultComparer(sortAscending));

            IQueryResult temp = queryContext.InternalQueryResult;

            queryContext.InternalQueryResult = new Common.Queries.HashedQueryResult(queryContext.KeyFilter, queryContext.CompoundFilter);

            for (int i = 0; i < members.Count; i++)
            {
                Predicate           predicate  = (Predicate)members[i];
                CollectionOperation mergeTypeX = (Inverse == true || (queryContext.InternalQueryResult.Count == 0 & i == 0)) ? CollectionOperation.Union : CollectionOperation.Intersection;
                predicate.ExecuteInternal(queryContext, mergeTypeX);
            }
            queryContext.InternalQueryResult.Merge(temp, mergeType);
        }
Exemplo n.º 21
0
    public QueryContext RunOperation()
    {
        var context  = CollectionOperation.RunOperation();
        var fContext = ForeignCollectionOperation.RunOperation();

        var mergedContext = new QueryContext
        {
            IncludedTables  = context.IncludedTables.Concat(fContext.IncludedTables).ToArray(),
            EntryCollection = new EntryCollection
            {
                CollectionAlias =
                    $"{context.EntryCollection.CollectionAlias}.{fContext.EntryCollection.CollectionAlias}",
                Keys    = context.EntryCollection.Keys.Concat(fContext.EntryCollection.Keys).ToArray(),
                Entries = null
            }
        };

        var joinedEntries = new List <Entry>();

        foreach (var entry in context.EntryCollection.Entries)
        {
            foreach (var fEntry in fContext.EntryCollection.Entries)
            {
                var joinedEntry = MergeEntries(entry, fEntry);

                if (Condition.IsTrue(mergedContext, joinedEntry))
                {
                    joinedEntries.Add(joinedEntry);
                }
            }
        }

        mergedContext.EntryCollection.Entries = joinedEntries.ToList();

        return(mergedContext);
    }
Exemplo n.º 22
0
 private static ItemOrEnumerable <CollectionOperation <T> > OnRemove([NotNull] ICollectionRemoveOperation <T> remove) =>
 new ItemOrEnumerable <CollectionOperation <T> >(CollectionOperation <T> .OnRemove(remove.Item));
Exemplo n.º 23
0
 public void Merge(IQueryResult other, CollectionOperation op)
 {
     _wrappedResult.Merge(other, op);
 }
Exemplo n.º 24
0
 public void Mark(CollectionOperation op)
 {
     _wrappedResult.Mark(op);
 }
Exemplo n.º 25
0
        private static IEnumerable <CollectionOperation <T> > Enumerate([NotNull] ICollectionReplaceOperation <T> replace)
        {
            yield return(CollectionOperation <T> .OnRemove(replace.ReplacedItem));

            yield return(CollectionOperation <T> .OnAdd(replace.Item));
        }
Exemplo n.º 26
0
 internal override void ExecuteInternal(QueryContext queryContext, CollectionOperation mergeType)
 {
     throw new ParserException("Incorrect query format. \'" + this.ToString() + "\' not supported.");
 }
 private void NotifyCollectionOperation(T item, TCollectionOperation operation)
 {
     CollectionOperation?.Invoke(this, new CollectionOperationEventArgs <T>(item, operation));
 }
Exemplo n.º 28
0
 internal ArangoCollectionOperation(CollectionOperation collectionOperation)
 {
     _collectionOperation = collectionOperation;
 }
Exemplo n.º 29
0
        public void GetData(object key, ComparisonType comparisonType, IQueryResult result, CollectionOperation op, CancellationToken token)
        {
            IComparable keyToCompare = key as IComparable;

            if (_store != null)
            {
                switch (comparisonType)
                {
                case ComparisonType.EQUALS:
                    if (_store.Contains(key))
                    {
                        result.AddObject(_store[key], op);
                    }
                    break;

                case ComparisonType.NOT_EQUALS:
                    foreach (object storedKey in _store.Keys)
                    {
                        if (token != null && token.IsCancellationRequested)
                        {
                            throw new OperationCanceledException(ExceptionsResource.OperationFailed);
                        }
                        if (((IComparable)storedKey).CompareTo(keyToCompare) != 0)
                        {
                            result.AddObject(_store[storedKey], op);
                        }
                    }
                    break;

                case ComparisonType.LESS_THAN:
                    foreach (object storedKey in _store.Keys)
                    {
                        if (token != null && token.IsCancellationRequested)
                        {
                            throw new OperationCanceledException(ExceptionsResource.OperationFailed);
                        }
                        if (((IComparable)storedKey).CompareTo(keyToCompare) < 0)
                        {
                            result.AddObject(_store[storedKey], op);
                        }
                    }
                    break;

                case ComparisonType.GREATER_THAN:
                    foreach (object storedKey in _store.Keys)
                    {
                        if (token != null && token.IsCancellationRequested)
                        {
                            throw new OperationCanceledException(ExceptionsResource.OperationFailed);
                        }
                        if (((IComparable)storedKey).CompareTo(keyToCompare) > 0)
                        {
                            result.AddObject(_store[storedKey], op);
                        }
                    }
                    break;

                case ComparisonType.LESS_THAN_EQUALS:
                    foreach (object storedKey in _store.Keys)
                    {
                        if (token != null && token.IsCancellationRequested)
                        {
                            throw new OperationCanceledException(ExceptionsResource.OperationFailed);
                        }
                        if (((IComparable)storedKey).CompareTo(keyToCompare) <= 0)
                        {
                            result.AddObject(_store[storedKey], op);
                        }
                    }
                    break;

                case ComparisonType.GREATER_THAN_EQUALS:
                    foreach (object storedKey in _store.Keys)
                    {
                        if (token != null && token.IsCancellationRequested)
                        {
                            throw new OperationCanceledException(ExceptionsResource.OperationFailed);
                        }
                        if (((IComparable)storedKey).CompareTo(keyToCompare) >= 0)
                        {
                            result.AddObject(_store[storedKey], op);
                        }
                    }
                    break;

                case ComparisonType.LIKE:
                    foreach (object storedKey in _store.Keys)
                    {
                        if (token != null && token.IsCancellationRequested)
                        {
                            throw new OperationCanceledException(ExceptionsResource.OperationFailed);
                        }
                        string pattern             = key as string;
                        WildcardEnabledRegex regex = new WildcardEnabledRegex(pattern);

                        if (storedKey is string)
                        {
                            if (regex.IsMatch((string)storedKey))
                            {
                                result.AddObject(_store[storedKey], op);
                            }
                        }
                    }

                    break;

                case ComparisonType.NOT_LIKE:
                    foreach (object storedKey in _store.Keys)
                    {
                        if (token != null && token.IsCancellationRequested)
                        {
                            throw new OperationCanceledException(ExceptionsResource.OperationFailed);
                        }
                        string pattern             = key as string;
                        WildcardEnabledRegex regex = new WildcardEnabledRegex(pattern);

                        if (storedKey is string)
                        {
                            if (!regex.IsMatch((string)storedKey))
                            {
                                result.AddObject(_store[storedKey], op);
                            }
                        }
                    }

                    break;
                }
                result.Mark(op);
            }
        }
Exemplo n.º 30
0
        ///<summary>
        /// GetData
        /// Gets the data object associated with the specified key
        ///<summary>
        public void GetData(T key, COMPARE compareType, IQueryResult resultKeys, CollectionOperation mergeType, CancellationToken token)
        {
            int result;

            ClusteredArrayList    keyList  = new ClusteredArrayList();
            RedBlackNode <T>      treeNode = rbTree; // begin at root
            IDictionaryEnumerator en       = null;
            string pattern;
            WildcardEnabledRegex regex;
            HashVector           skippedKeys = null;
            bool isStringValue = false;

            if (key is string)
            {
                isStringValue = true;
            }
            //lock (_mutex)
            try
            {
                rwLock.AcquireReaderLock(Timeout.Infinite);
                switch (compareType)
                {
                case COMPARE.EQ:
                    // traverse tree until node is found
                    while (treeNode != _sentinelNode)
                    {
                        if (token != null && token.IsCancellationRequested)
                        {
                            throw new OperationCanceledException(ExceptionsResource.OperationFailed);
                        }

                        if (isStringValue && treeNode.Key is string)
                        {
                            //result = string.Compare(treeNode.Key , key , true);
                            result = treeNode.Key.ToString().ToLower().CompareTo(key.ToString().ToLower());
                        }
                        else
                        {
                            result = treeNode.Key.CompareTo(key);
                        }
                        if (result == 0)
                        {
                            lastNodeFound = treeNode;
                            resultKeys.Add(treeNode.Data, mergeType);
                            break;
                        }
                        if (result > 0)     //treenode is Greater then the one we are looking. Move to Left branch
                        {
                            treeNode = treeNode.Left;
                        }
                        else
                        {
                            treeNode = treeNode.Right;     //treenode is Less then the one we are looking. Move to Right branch.
                        }
                    }
                    break;

                case COMPARE.NE:

                    // traverse tree until node is found
                    resultKeys = GetWrappedResult(resultKeys, key, true);

                    en = GetEnumerator();

                    while (en.MoveNext())
                    {
                        if (token != null && token.IsCancellationRequested)
                        {
                            throw new OperationCanceledException(ExceptionsResource.OperationFailed);
                        }

                        if (isStringValue && en.Key is string)
                        {
                            result = en.Key.ToString().ToLower().CompareTo(key.ToString().ToLower());
                        }
                        else
                        {
                            result = ((IComparable)en.Key).CompareTo(key);
                        }

                        if (result != 0)
                        {
                            HashVector tmp = en.Value as HashVector;
                            resultKeys.Add(tmp, mergeType);
                        }
                    }
                    break;

                case COMPARE.GT:

                    resultKeys = GetWrappedResult(resultKeys, key, false);

                    en = GetEnumerator(false);
                    while (en.MoveNext())
                    {
                        if (token != null && token.IsCancellationRequested)
                        {
                            throw new OperationCanceledException(ExceptionsResource.OperationFailed);
                        }

                        if (isStringValue && en.Key is string)
                        {
                            result = en.Key.ToString().ToLower().CompareTo(key.ToString().ToLower());
                        }
                        else
                        {
                            result = ((IComparable)en.Key).CompareTo(key);
                        }

                        if (result > 0)
                        {
                            HashVector tmp = en.Value as HashVector;
                            resultKeys.Add(tmp, mergeType);
                        }
                        else
                        {
                            break;
                        }
                    }
                    break;

                case COMPARE.LT:

                    resultKeys = GetWrappedResult(resultKeys, key, false);

                    en = GetEnumerator(true);
                    while (en.MoveNext())
                    {
                        if (token != null && token.IsCancellationRequested)
                        {
                            throw new OperationCanceledException(ExceptionsResource.OperationFailed);
                        }

                        if (isStringValue && en.Key is string)
                        {
                            result = en.Key.ToString().ToLower().CompareTo(key.ToString().ToLower());
                        }
                        else
                        {
                            result = ((IComparable)en.Key).CompareTo(key);
                        }

                        if (result < 0)
                        {
                            HashVector tmp = en.Value as HashVector;
                            resultKeys.Add(tmp, mergeType);
                        }
                        else
                        {
                            break;
                        }
                    }
                    break;

                case COMPARE.GTEQ:
                    resultKeys = GetWrappedResult(resultKeys, key, false);
                    en         = this.GetEnumerator(false);
                    while (en.MoveNext())
                    {
                        if (token != null && token.IsCancellationRequested)
                        {
                            throw new OperationCanceledException(ExceptionsResource.OperationFailed);
                        }

                        if (isStringValue && en.Key is string)
                        {
                            result = en.Key.ToString().ToLower().CompareTo(key.ToString().ToLower());
                        }
                        else
                        {
                            result = ((IComparable)en.Key).CompareTo(key);
                        }

                        if (result >= 0)
                        {
                            HashVector tmp = en.Value as HashVector;
                            resultKeys.Add(tmp, mergeType);
                        }
                        else
                        {
                            break;
                        }
                    }
                    break;

                case COMPARE.LTEQ:
                    resultKeys = GetWrappedResult(resultKeys, key, false);
                    en         = this.GetEnumerator();
                    while (en.MoveNext())
                    {
                        if (token != null && token.IsCancellationRequested)
                        {
                            throw new OperationCanceledException(ExceptionsResource.OperationFailed);
                        }

                        if (isStringValue && en.Key is string)
                        {
                            result = en.Key.ToString().ToLower().CompareTo(key.ToString().ToLower());
                        }
                        else
                        {
                            result = ((IComparable)en.Key).CompareTo(key);
                        }

                        if (result <= 0)
                        {
                            HashVector tmp = en.Value as HashVector;
                            resultKeys.Add(tmp, mergeType);
                        }
                        else
                        {
                            break;
                        }
                    }
                    break;

                case COMPARE.REGEX:
                    resultKeys = GetWrappedResult(resultKeys, key, false);
                    en         = this.GetEnumerator();
                    pattern    = key as string;
                    regex      = new WildcardEnabledRegex(pattern);
                    while (en.MoveNext())
                    {
                        if (token != null && token.IsCancellationRequested)
                        {
                            throw new OperationCanceledException(ExceptionsResource.OperationFailed);
                        }

                        if (en.Key is string)
                        {
                            if (regex.IsMatch(en.Key.ToString().ToLower()))
                            {
                                HashVector tmp = en.Value as HashVector;
                                resultKeys.Add(tmp, mergeType);
                            }
                        }
                    }

                    break;

                case COMPARE.IREGEX:
                    resultKeys = GetWrappedResult(resultKeys, key, true);
                    en         = this.GetEnumerator();
                    pattern    = key as string;
                    regex      = new WildcardEnabledRegex(pattern);
                    while (en.MoveNext())
                    {
                        if (token != null && token.IsCancellationRequested)
                        {
                            throw new OperationCanceledException(ExceptionsResource.OperationFailed);
                        }

                        if (en.Key is string)
                        {
                            if (!regex.IsMatch(en.Key.ToString().ToLower()))
                            {
                                HashVector tmp = en.Value as HashVector;
                                resultKeys.Add(tmp, mergeType);
                            }
                        }
                    }
                    break;
                }

                resultKeys.Mark(mergeType);
            }
            finally
            {
                rwLock.ReleaseReaderLock();
            }
        }