public void ContainerCanSetDefaultsUsingTheConstructor() { Func <ILifetime> lifetimeFactory = () => new ContainerLifetime(); var compileMode = CompileMode.Dynamic; var index = new DirectIndex(); using (var container = new IocContainer(lifetimeFactory, compileMode, index)) { Assert.IsInstanceOfType(container.DefaultLifetimeFactory(), typeof(ContainerLifetime)); Assert.IsTrue(compileMode == container.DefaultCompileMode); Assert.AreSame(index, container.Index); } }
/// <summary> /// Updates the query results /// </summary> public void Update(Action <double> progress, CancellationToken cancellation) { // stop here if the log is empty if (_log.Count == 0) { _logger.Debug($"Evaluation canceled by empty log"); _mode = EvaluationMode.Aggregate; Reset(0); return; } // start timers for performance measurement var sw = Stopwatch.StartNew(); var sw2 = Stopwatch.StartNew(); // generate the raw index var indexVisitor = new IndexVisitor(_log); _tree.Accept(indexVisitor); // create an enumerator for the index var index = indexVisitor.Index; _mode = indexVisitor.Mode; // refine the index by evaluating log items IEnumerable <LogItem> items = null; Dictionary <string, Type> dynamicFields = null; if (_mode == EvaluationMode.Evaluate || _mode == EvaluationMode.Aggregate) { long progressTotal = 0; // build a parallel query for reading the log var rawItems = index .AsParallel() .AsOrdered() .WithCancellation(cancellation) .GroupBy(i => i.File + i.Member) .SelectMany(f => _log.Read(f, (step, total) => progress?.Invoke((Interlocked.Add(ref progressTotal, step) * 98.0) / total), cancellation)); // apply the query to the log var evaluateVisitor = new EvaluateVisitor(rawItems); _tree.Accept(evaluateVisitor); items = evaluateVisitor.Items; // store dynamic fields dynamicFields = evaluateVisitor.Fields; } // store the result as specified if (_mode == EvaluationMode.Aggregate) { _index = new DirectIndex(Enumerable.Empty <IndexItem>()); Reset(items); _logger.Info($"Evaluation completed in {sw2.ElapsedMilliseconds} ms"); } else if (_mode == EvaluationMode.Evaluate) { _index = new DirectIndex(items.Select(i => new IndexItem(i.File, i.Member, i.Position, i.Line))); Reset(_index.Count); _logger.Info($"Evaluation and reindexing completed after {sw2.ElapsedMilliseconds} ms"); } else { _index = new DirectIndex(index); Reset(_index.Count); _logger.Info($"Indexing completed after {sw2.ElapsedMilliseconds} ms"); } // generate the dynamic columns if (_dynamicColumns != null) { _dynamicColumns.Clear(); foreach (var kvp in dynamicFields) { _dynamicColumns.Add(kvp.Key, kvp.Value); } } sw.Stop(); _logger.Info($"Execution completed in {sw.ElapsedMilliseconds} ms"); }