Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MetricInfo" /> class.
        /// Creates metric info for given sources.
        /// </summary>
        /// <param name="resolveOccurances">
        /// Determine whether evidences of occurrences in sources code should be stored.
        /// </param>
        /// <param name="parser">Syntax parser of source code.</param>
        private MetricInfo(bool resolveOccurances, SyntaxParser parser)
        {
            if (!parser.IsParsed)
            {
                // We need content in parser to be parsed
                parser.Parse();
            }

            indicatorBatch = ProcessingServices.ProcessIndicators(resolveOccurances, parser);
            ratingBatch    = ProcessingServices.ProcessRatings(resolveOccurances, parser);
            quantityBatch  = ProcessingServices.ProcessQuantities(resolveOccurances, parser);

            HasResolvedOccurrences = resolveOccurances;
            IncludeParsers(parser);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create new metric info by merging this info with given other info.
        /// </summary>
        /// <param name="other">The other <see cref="MetricInfo" /> object.</param>
        /// <returns><see cref="MetricInfo" /> merged from two other objects.</returns>
        public MetricInfo Merge(MetricInfo other)
        {
            var commonFiles = includedFiles.Keys.Intersect(other.includedFiles.Keys);

            if (commonFiles.Count() > 0)
            {
                var notIncludedParsers = new Queue <SyntaxParser>();
                var notInlcudedFiles   = other.includedFiles.Keys.Except(commonFiles);
                foreach (var file in notInlcudedFiles)
                {
                    notIncludedParsers.Enqueue(other.includedFiles[file]);
                }

                other = FromParsers(other.HasResolvedOccurrences, notIncludedParsers.ToArray());
            }

            var resultIndicators = ProcessingServices.MergeIndicators(indicatorBatch, other.indicatorBatch);
            var resultRatings    = ProcessingServices.MergeRatings(ratingBatch, other.ratingBatch);
            var resultQuantities = ProcessingServices.MergeQuantities(quantityBatch, other.quantityBatch);
            var includedParsers  = includedFiles.Values.Union(other.includedFiles.Values);

            return(new MetricInfo(resultIndicators, resultRatings, resultQuantities, includedParsers,
                                  HasResolvedOccurrences && other.HasResolvedOccurrences));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Writes all mass spectra to the result database file.
        /// </summary>
        /// <param name="massSpectrumItems">The mass spectra to persist.</param>
        private void PersistMassSpectra(IEnumerable <MassSpectrumItem> massSpectrumItems)
        {
            var unionEntityDataPersistenceService = ProcessingServices.Get <IUnionEntityDataPersistenceService>();

            unionEntityDataPersistenceService.InsertItems(massSpectrumItems);
        }