Exemplo n.º 1
0
        /// <summary>
        /// Evaluate the target User-Agent again, but this time
        /// </summary>
        /// <param name="state"></param>
        private static void EvaluateNumeric(MatchState state)
        {
            state.ResetNextCharacterPositionIndex();
            var existingNodeIndex = state.Nodes.Count - 1;

            while (state.NextCharacterPositionIndex > 0)
            {
                if (existingNodeIndex < 0 ||
                    state.Nodes[existingNodeIndex].Root.Position < state.NextCharacterPositionIndex)
                {
                    state.RootNodesEvaluated++;
                    var node = state.DataSet.RootNodes[state.NextCharacterPositionIndex].GetCompleteNumericNode(state);
                    // If there is a node and it doesn't overlap with an existing one then
                    // add it to the list.
                    if (node != null &&
                        node.GetIsOverlap(state) == false)
                    {
                        // Insert the node and update the existing index so that
                        // it's the node to the left of this one.
                        existingNodeIndex = state.InsertNode(node) - 1;

                        // Move to the position of the node found as
                        // we can't use the next node incase there's another
                        // not part of the same signatures closer.
                        state.NextCharacterPositionIndex = node.Position;
                    }
                    else
                    {
                        state.NextCharacterPositionIndex--;
                    }
                }
                else
                {
                    // The next position to evaluate should be to the left
                    // of the existing node already in the list.
                    state.NextCharacterPositionIndex = state.Nodes[existingNodeIndex].Position;

                    // Swap the existing node for the next one in the list.
                    existingNodeIndex--;
                }
            }
        }