Example #1
0
        /// <summary>
        /// Add filter callback to an event evaluator, which could be either an index node or a set node.
        /// </summary>
        /// <param name="remainingParameters">The remaining parameters.</param>
        /// <param name="filterCallback">The filter callback.</param>
        /// <param name="eventEvaluator">to add the filterCallback to.</param>
        /// <param name="treePathInfo">is for holding the information on where the add occured</param>
        /// <param name="lockFactory">The lock factory.</param>
        /// <returns>
        /// bool indicating if the eventEvaluator was successfully added
        /// </returns>
        private static bool AddToEvaluator(
            ArrayDeque <FilterValueSetParam> remainingParameters,
            FilterHandle filterCallback,
            EventEvaluator eventEvaluator,
            ArrayDeque <EventTypeIndexBuilderIndexLookupablePair> treePathInfo,
            FilterServiceGranularLockFactory lockFactory)
        {
            if (eventEvaluator is FilterHandleSetNode)
            {
                var node = (FilterHandleSetNode)eventEvaluator;
                AddToNode(remainingParameters, filterCallback, node, treePathInfo, lockFactory);
                return(true);
            }

            // Check if the next index matches any of the remaining filterCallback parameters
            var nextIndex = (FilterParamIndexBase)eventEvaluator;

            var parameter = IndexHelper.FindParameter(remainingParameters, nextIndex);

            if (parameter != null)
            {
                remainingParameters.Remove(parameter);
                treePathInfo.Add(new EventTypeIndexBuilderIndexLookupablePair(nextIndex, parameter.FilterForValue));
                AddToIndex(remainingParameters, filterCallback, nextIndex, parameter.FilterForValue, treePathInfo, lockFactory);
                return(true);
            }

            // This eventEvaluator does not work with any of the remaining filter parameters
            return(false);
        }
Example #2
0
        /// <summary>
        /// Add filter callback to an event evaluator, which could be either an index node or a set node.
        /// </summary>
        /// <param name="remainingParameters">The remaining parameters.</param>
        /// <param name="filterCallback">The filter callback.</param>
        /// <param name="eventEvaluator">to add the filterCallback to.</param>
        /// <param name="treePathInfo">is for holding the information on where the add occured</param>
        /// <param name="lockFactory">The lock factory.</param>
        /// <returns>
        /// bool indicating if the eventEvaluator was successfully added
        /// </returns>
        private static bool AddToEvaluator(
            ArrayDeque <FilterValueSetParam> remainingParameters,
            FilterHandle filterCallback,
            EventEvaluator eventEvaluator,
            ArrayDeque <EventTypeIndexBuilderIndexLookupablePair> treePathInfo,
            FilterServiceGranularLockFactory lockFactory)
        {
            if (eventEvaluator is FilterHandleSetNode)
            {
                var node = (FilterHandleSetNode)eventEvaluator;
#if DEBUG && DIAGNOSTICS
                System.Diagnostics.Debug.WriteLine("{0}: AddToEvaluator: {1}", Thread.CurrentThread.ManagedThreadId, node);
#endif
                AddToNode(remainingParameters, filterCallback, node, treePathInfo, lockFactory);
                return(true);
            }

            // Check if the next index matches any of the remaining filterCallback parameters
            var nextIndex = (FilterParamIndexBase)eventEvaluator;

            var parameter = IndexHelper.FindParameter(remainingParameters, nextIndex);
            if (parameter != null)
            {
                remainingParameters.Remove(parameter);
                treePathInfo.Add(new EventTypeIndexBuilderIndexLookupablePair(nextIndex, parameter.FilterForValue));
#if DEBUG && DIAGNOSTICS
                System.Diagnostics.Debug.WriteLine("{0}: AddToEvaluator -> AddToIndex: {1}", Thread.CurrentThread.ManagedThreadId, nextIndex);
#endif
                AddToIndex(remainingParameters, filterCallback, nextIndex, parameter.FilterForValue, treePathInfo, lockFactory);
                return(true);
            }

            // This eventEvaluator does not work with any of the remaining filter parameters
            return(false);
        }
Example #3
0
        public void TestFindParameter()
        {
            FilterParamIndexBase indexOne = IndexFactory.CreateIndex(MakeLookupable("BoolPrimitive"), _lockFactory, FilterOperator.EQUAL);

            Assert.IsNull(IndexHelper.FindParameter(_parameters, indexOne));

            FilterParamIndexBase indexTwo = IndexFactory.CreateIndex(MakeLookupable("TheString"), _lockFactory, FilterOperator.EQUAL);

            Assert.AreEqual(_parameterThree, IndexHelper.FindParameter(_parameters, indexTwo));

            FilterParamIndexBase indexThree = IndexFactory.CreateIndex(MakeLookupable("IntPrimitive"), _lockFactory, FilterOperator.GREATER);

            Assert.AreEqual(_parameterOne, IndexHelper.FindParameter(_parameters, indexThree));
        }