当前位置: 首页>>代码示例>>C#>>正文


C# List.ToEmptyIfNull方法代码示例

本文整理汇总了C#中Model.List.ToEmptyIfNull方法的典型用法代码示例。如果您正苦于以下问题:C# List.ToEmptyIfNull方法的具体用法?C# List.ToEmptyIfNull怎么用?C# List.ToEmptyIfNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Model.List的用法示例。


在下文中一共展示了List.ToEmptyIfNull方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Run

        public async Task<MutationSessionChoices> Run(MethodIdentifier singleMethodToMutate = null, List<string> testAssemblies = null, bool auto = false)
        {
            _sessionCreationWindowShowTime = DateTime.Now;

            SessionCreator sessionCreator = _sessionCreatorFactory.Create();

            Task<List<CciModuleSource>> assembliesTask = _sessionConfiguration.LoadAssemblies();

        
          //  Task<List<MethodIdentifier>> coveringTask = sessionCreator.FindCoveringTests(assembliesTask, matcher);

            Task<TestsRootNode> testsTask = _sessionConfiguration.LoadTests();


            ITestsSelectStrategy testsSelector;
            bool constrainedMutation = false;
            ICodePartsMatcher matcher;
            if (singleMethodToMutate != null)
            {
                matcher = new CciMethodMatcher(singleMethodToMutate);
                testsSelector = new CoveringTestsSelectStrategy(assembliesTask, matcher, testsTask);
                constrainedMutation = true;
            }
            else
            {
                testsSelector = new AllTestsSelectStrategy(testsTask);
                matcher = new AllMatcher();
            }
            _log.Info("Selecting tests in assemblies: "+ testAssemblies.MakeString());
            var testsSelecting = testsSelector.SelectTests(testAssemblies);

            var t1 = sessionCreator.GetOperators();

            var t2 = sessionCreator.BuildAssemblyTree(assembliesTask, constrainedMutation, matcher);

            var t11 = t1.ContinueWith(task =>
            {
                _viewModel.MutationsTree.MutationPackages
                    = new ReadOnlyCollection<PackageNode>(task.Result.Packages);
            },CancellationToken.None, TaskContinuationOptions.NotOnFaulted, _execute.GuiScheduler);

            var t22 = t2.ContinueWith(task =>
            {
                if (_typesManager.IsAssemblyLoadError)
                {
                    _svc.Logging.ShowWarning(UserMessages.WarningAssemblyNotLoaded());
                }
                var assembliesToMutate = task.Result.Where(a => !testAssemblies.ToEmptyIfNull().Contains(a.AssemblyPath.Path)).ToList();
                //assembliesToMutate = ClassCoverage.UnmarkNotCovered(assembliesToMutate,testAssemblies);
                _viewModel.TypesTreeMutate.Assemblies = new ReadOnlyCollection<AssemblyNode>(assembliesToMutate);
                _whiteSource = assembliesTask.Result;
            }, CancellationToken.None, TaskContinuationOptions.NotOnFaulted, _execute.GuiScheduler);

            var t33 = testsSelecting.ContinueWith(task =>
            {
                _viewModel.TypesTreeToTest.TestAssemblies
                                = new ReadOnlyCollection<TestNodeAssembly>(task.Result);

                if (_options.UseCodeCoverage)
                {
                    ClassCoverage.UnmarkNotCovered(_viewModel.TypesTreeMutate.Assemblies, _viewModel.TypesTreeToTest.TestAssemblies);
                }

               
            }, CancellationToken.None, TaskContinuationOptions.NotOnFaulted, _execute.GuiScheduler);

              
            try
            {
                var mainTask = Task.WhenAll(t1, t2, testsSelecting, t11, t22, t33).ContinueWith(t =>
                {
                    
                    if (t.Exception != null)
                    {
                        ShowError(t.Exception);
                        _viewModel.Close();
                        tcs.TrySetCanceled();
                    }
                }, _execute.GuiScheduler);
               
                var wrappedTask = Task.WhenAll(tcs.Task, mainTask);

                if (_sessionConfiguration.AssemblyLoadProblem)
                {
                    new TaskFactory(_dispatcher.GuiScheduler)
                        .StartNew(() =>
                        _svc.Logging.ShowWarning(UserMessages.WarningAssemblyNotLoaded()));
                }
                return await WaitForResult(auto, wrappedTask);
            }
            catch (Exception e)
            {
                _log.Error(e);
                throw;
            }
        }
开发者ID:Refresh06,项目名称:visualmutator,代码行数:96,代码来源:AutoCreationController.cs


注:本文中的Model.List.ToEmptyIfNull方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。