Beispiel #1
0
        /// <summary>Add a statement, inspecting the statement name and adding it to a statement group or the default group, if none. </summary>
        /// <param name="stmtName">name to inspect</param>
        /// <returns>handle for statement</returns>
        public StatementMetricHandle AddStatement(String stmtName)
        {
            // determine group
            int countGroups = 1;
            int groupNumber = -1;

            foreach (var entry in _specification.StatementGroups)
            {
                IList <Pair <StringPatternSet, bool> > patterns = entry.Value.Patterns;
                bool result = StringPatternSetUtil.Evaluate(entry.Value.IsDefaultInclude, patterns, stmtName);

                if (result)
                {
                    groupNumber = countGroups;
                    break;
                }
                countGroups++;
            }

            // assign to default group if none other apply
            if (groupNumber == -1)
            {
                groupNumber = 0;
            }

            int index = _groupMetrics[groupNumber].AddStatementGetIndex(stmtName);

            _statementGroups.Put(stmtName, groupNumber);

            return(new StatementMetricHandle(groupNumber, index));
        }
        /// <summary>
        ///     Add a statement, inspecting the statement name and adding it to a statement group or the default group, if none.
        /// </summary>
        /// <param name="statement">name to inspect</param>
        /// <returns>handle for statement</returns>
        public StatementMetricHandle AddStatement(DeploymentIdNamePair statement)
        {
            // determine group
            var countGroups = 1;
            var groupNumber = -1;
            foreach (var entry in specification.StatementGroups) {
                var patterns = entry.Value.Patterns;
                var result = StringPatternSetUtil.Evaluate(entry.Value.IsDefaultInclude, patterns, statement.Name);

                if (result) {
                    groupNumber = countGroups;
                    break;
                }

                countGroups++;
            }

            // assign to default group if none other apply
            if (groupNumber == -1) {
                groupNumber = 0;
            }

            var index = groupMetrics[groupNumber].AddStatementGetIndex(statement);

            statementGroups.Put(statement, groupNumber);

            return new StatementMetricHandle(groupNumber, index);
        }