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


C# List.ForEach方法代码示例

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


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

示例1: Build

        internal static string Build(List<TestAttribute> Categories)
        {
            string source = "";

            var list = new List<string>();

            Categories
                .ToList()
                .ForEach(c => list.Add(c.GetName()));

            list.Sort();

            var catParams = new string[] {
                ExtentFlag.GetPlaceHolder("testCategory"),
                ExtentFlag.GetPlaceHolder("testCategoryU")
            };

            list.ForEach(c =>
            {
                var catValues = new string[] {
                    c,
                    c.ToLower().Replace(" ", "")
                };

                source += SourceBuilder.Build(CategoryFilterHtml.GetOptionSource(), catParams, catValues);
            });

            return source;
        }
开发者ID:karthikbhatnagar,项目名称:extentreports,代码行数:29,代码来源:CategoryOptionBuilder.cs

示例2: ProcessTagSet

        public static List<TagProcessResult> ProcessTagSet(List<TagSimple> tagSet)
        {
            var resultList = new List<TagProcessResult>();

             // Spellcheck
             tagSet.ForEach(t => resultList.Add(
            new TagProcessResult
            {
               TagId = t.TagId,
               TagValue = t.TagValue,
               WordProcessResultList = t.TagValue.Split(' ').ToList().Select(w => ProcessWord(w, t.TagId)).ToList()
            }));

             var correctlySpelledTagList = resultList.Where(t => t.WordProcessResultList.All(w => !w.Skip)).ToList();

             resultList.Where(t => t.WordProcessResultList.All(w => !w.Skip)).ToList().ForEach(tpr => CheckTagSetTest(correctlySpelledTagList, tpr));

             //// Check all tags that are 100% spelled correctly for a duplicate in provided set.
             //resultList.Where(t => t.WordProcessResultList.All(w => !w.Skip)).ToList().ForEach(tpr => CheckTagSetForDuplicates(correctlySpelledTagList, tpr));

             //// Check all tags that are unique in the provided set of tags and are 100% spelled correctly for a duplicate in the media tag repository.
             //resultList.Where(t => !t.DuplicateTagId.HasValue && t.WordProcessResultList.All(w => !w.Skip)).ToList().ForEach(CheckRepositoryForDuplicates);

             //resultList.Where(t => !t.MediaTagId.HasValue).ToList().ForEach(t => CheckTagSetForSynonyms(correctlySpelledTagList, t));

             return resultList;
        }
开发者ID:noudelenferink,项目名称:TagGardening2014,代码行数:27,代码来源:TagProcessor.cs

示例3: InsertPedidos

 private static void InsertPedidos(PedidoDAL pedidoDAL)
 {
     pedidos = new List<Pedido>
         {
             new Pedido { DataPedido = DateTime.Now,Vendedor = "Vendedor A",Situacao = false,Observacao = "Obsevação A",Produtos = produtos }
         };
     pedidos.ForEach(pedidoDAL.Insert);
 }
开发者ID:java-es,项目名称:OrderSale,代码行数:8,代码来源:Program.cs

示例4: InsertProdutos

 private static void InsertProdutos(ProdutoDAL produtoDAL)
 {
     produtos = new List<Produto>
         {
             new Produto { Nome="Produto A",Peso = 100,Quantidade = 1,preco = 50.25M},
             new Produto { Nome="Produto B",Peso = 200,Quantidade = 1,preco = 65.25M},
             new Produto { Nome="Produto C",Peso = 300,Quantidade = 4,preco = 125.25M }
         };
     produtos.ForEach(produtoDAL.Insert); ;
 }
开发者ID:java-es,项目名称:OrderSale,代码行数:10,代码来源:Program.cs

示例5: buildOptions

        public static string buildOptions(List<string> Categories)
        {
            string source = "";

            Categories.Sort();

            var catFlags = new string[] {
                ExtentFlag.GetPlaceHolder("testCategory"),
                ExtentFlag.GetPlaceHolder("testCategoryU")
            };

            Categories.ForEach(c =>
            {
                var catValues = new string[] {
                    c,
                    c.ToLower().Replace(" ", "")
                };

                source += SourceBuilder.Build(CategoryHtml.GetOptionSource(), catFlags, catValues);
            });

            return source;
        }
开发者ID:karthikbhatnagar,项目名称:extentreports,代码行数:23,代码来源:CategorySourceBuilder.cs

示例6: RestoreAzureWebsiteDeploymentTest

        public void RestoreAzureWebsiteDeploymentTest()
        {
            // Setup
            SimpleWebsitesManagement channel = new SimpleWebsitesManagement();

            channel.GetWebSpacesThunk = ar => new WebSpaces(new List<WebSpace> { new WebSpace { Name = "webspace1" }, new WebSpace { Name = "webspace2" } });
            channel.GetSitesThunk = ar =>
            {
                if (ar.Values["webspaceName"].Equals("webspace1"))
                {
                    return new Sites(new List<Site> { new Site { Name = "website1", WebSpace = "webspace1", SiteProperties = new SiteProperties
                        {
                            Properties = new List<NameValuePair>
                            {
                                new NameValuePair { Name = "repositoryuri", Value = "http" },
                                new NameValuePair { Name = "PublishingUsername", Value = "user1" },
                                new NameValuePair { Name = "PublishingPassword", Value = "password1" }
                            }
                        }}
                    });
                }

                return new Sites(new List<Site> { new Site { Name = "website2", WebSpace = "webspace2" } });
            };

            SimpleDeploymentServiceManagement deploymentChannel = new SimpleDeploymentServiceManagement();

            var deployments = new List<DeployResult> { new DeployResult { Id = "id1", Current = false }, new DeployResult { Id = "id2", Current = true } };
            deploymentChannel.GetDeploymentsThunk = ar => deployments;
            deploymentChannel.DeployThunk = ar =>
            {
                // Keep track of currently deployed id
                DeployResult newDeployment = deployments.FirstOrDefault(d => d.Id.Equals(ar.Values["commitId"]));
                if (newDeployment != null)
                {
                    // Make all inactive
                    deployments.ForEach(d => d.Complete = false);

                    // Set new to active
                    newDeployment.Complete = true;
                }
            };

            // Test
            RestoreAzureWebsiteDeploymentCommand restoreAzureWebsiteDeploymentCommand =
                new RestoreAzureWebsiteDeploymentCommand(channel, deploymentChannel)
            {
                Name = "website1",
                CommitId = "id2",
                ShareChannel = true,
                CommandRuntime = new MockCommandRuntime(),
                CurrentSubscription = new SubscriptionData { SubscriptionId = base.subscriptionName }
            };

            restoreAzureWebsiteDeploymentCommand.ExecuteCmdlet();
            Assert.AreEqual(1, ((MockCommandRuntime) restoreAzureWebsiteDeploymentCommand.CommandRuntime).OutputPipeline.Count);
            var responseDeployments = (IEnumerable<DeployResult>)((MockCommandRuntime) restoreAzureWebsiteDeploymentCommand.CommandRuntime).OutputPipeline.FirstOrDefault();
            Assert.IsNotNull(responseDeployments);
            Assert.AreEqual(2, responseDeployments.Count());
            Assert.IsTrue(responseDeployments.Any(d => d.Id.Equals("id2") && d.Complete));
            Assert.IsTrue(responseDeployments.Any(d => d.Id.Equals("id1") && !d.Complete));

            // Change active deployment to id1
            restoreAzureWebsiteDeploymentCommand = new RestoreAzureWebsiteDeploymentCommand(channel, deploymentChannel)
            {
                Name = "website1",
                CommitId = "id1",
                ShareChannel = true,
                CommandRuntime = new MockCommandRuntime(),
                CurrentSubscription = new SubscriptionData { SubscriptionId = base.subscriptionName }
            };

            restoreAzureWebsiteDeploymentCommand.ExecuteCmdlet();
            Assert.AreEqual(1, ((MockCommandRuntime)restoreAzureWebsiteDeploymentCommand.CommandRuntime).OutputPipeline.Count);
            responseDeployments = (IEnumerable<DeployResult>)((MockCommandRuntime)restoreAzureWebsiteDeploymentCommand.CommandRuntime).OutputPipeline.FirstOrDefault();
            Assert.IsNotNull(responseDeployments);
            Assert.AreEqual(2, responseDeployments.Count());
            Assert.IsTrue(responseDeployments.Any(d => d.Id.Equals("id1") && d.Complete));
            Assert.IsTrue(responseDeployments.Any(d => d.Id.Equals("id2") && !d.Complete));
        }
开发者ID:OctopusDeploy,项目名称:azure-sdk-tools,代码行数:80,代码来源:RestoreAzureWebsiteDeploymentTests.cs

示例7: MatchSaveTest

        public void MatchSaveTest()
        {
            const int countryId = 66;
            var country = TestEntities.CreateCountry(countryId, "countryEnglishName", "CountryName");
            var series = TestEntities.CreateSeries(1000, country, "A Lyga");
            var sessionFactory = SessionFactory.CreateSessionFactory(true);
            using (var session = sessionFactory.OpenSession())
            {
                session.SaveOrUpdate(country);
                session.SaveOrUpdate(series);
                session.Flush();
            }

            var match1 = TestEntities.CreateMatchFullData(1000, country, 1050, 1051,
                                                          new List<int> {10000, 10001, 10002}, 3000, 1);

            var match2 = TestEntities.CreateMatchFullData(1001, country, 1052, 1053,
                                              new List<int> { 10003, 10004, 10005 }, 3001, 1);

            series.AddMatch(match1);
            series.AddMatch(match2);

            var matchList = new List<Match> { match1, match2 };

            var prodSession = SessionManager.CurrentSession;
            var matchRepository = new MatchRepository(prodSession);

            using (var transaction = prodSession.BeginTransaction())
            {
                matchList.ForEach(matchRepository.SaveUpdate);
                transaction.Commit();
            }
        }
开发者ID:erikaspl,项目名称:WhoScored,代码行数:33,代码来源:MatchRepositoryTest.cs

示例8: PrepareRuntimeDeploymentInfo

        /// <summary>
        /// Set up runtime deployment info for each role in the service - after this method is called, 
        /// each role will have its startup configured with the URI of a runtime package to install at 
        /// role start
        /// </summary>
        /// <param name="service">The service to prepare</param>
        /// <param name="settings">The runtime settings to use to determine location</param>
        /// <param name="manifest"> </param>
        /// <returns>True if requested runtimes were successfully resolved, otherwise false</returns>
        internal bool PrepareRuntimeDeploymentInfo(AzureService service, ServiceSettings settings, string manifest = null)
        {
            CloudRuntimeCollection availableRuntimePackages;
            LocationName deploymentLocation = GetSettingsLocation(settings);
            if (!CloudRuntimeCollection.CreateCloudRuntimeCollection(deploymentLocation,
                out availableRuntimePackages, manifestFile: manifest))
            {
                throw new ArgumentException(string.Format(Resources.ErrorRetrievingRuntimesForLocation,
                    deploymentLocation));
            }

            ServiceDefinitionSchema.ServiceDefinition definition = service.Components.Definition;
            StringBuilder warningText = new StringBuilder();
            bool shouldWarn = false;
            List<CloudRuntimeApplicator> applicators = new List<CloudRuntimeApplicator>();
            if (definition.WebRole != null)
            {
                foreach (ServiceDefinitionSchema.WebRole role in definition.WebRole.Where(role => role.Startup != null && CloudRuntime.GetRuntimeStartupTask(role.Startup) != null))
                {
                    CloudRuntime.ClearRuntime(role);
                    string rolePath = Path.Combine(service.Paths.RootPath, role.name);
                    foreach (CloudRuntime runtime in CloudRuntime.CreateRuntime(role, rolePath))
                    {
                        CloudRuntimePackage package;
                        if (!availableRuntimePackages.TryFindMatch(runtime, out package))
                        {
                            string warning;
                            if (!runtime.ValidateMatch(package, out warning))
                            {
                                shouldWarn = true;
                                warningText.AppendFormat("{0}\r\n", warning);
                            }
                        }

                        applicators.Add(CloudRuntimeApplicator.CreateCloudRuntimeApplicator(runtime,
                            package, role));
                    }
                }
            }

            if (definition.WorkerRole != null)
            {
                foreach (ServiceDefinitionSchema.WorkerRole role in definition.WorkerRole.Where(role => role.Startup != null && CloudRuntime.GetRuntimeStartupTask(role.Startup) != null))
                {
                    string rolePath = Path.Combine(service.Paths.RootPath, role.name);
                    CloudRuntime.ClearRuntime(role);
                    foreach (CloudRuntime runtime in CloudRuntime.CreateRuntime(role, rolePath))
                    {
                        CloudRuntimePackage package;
                        if (!availableRuntimePackages.TryFindMatch(runtime, out package))
                        {
                            string warning;
                            if (!runtime.ValidateMatch(package, out warning))
                            {
                                shouldWarn = true;
                                warningText.AppendFormat("{0}\r\n", warning);
                            }
                        }
                        applicators.Add(CloudRuntimeApplicator.CreateCloudRuntimeApplicator(runtime,
                            package, role));
                    }
                }
            }

            if (!shouldWarn || ShouldProcess(string.Format(Resources.RuntimeMismatchWarning,
                _azureService.ServiceName)))
            {
                if (!shouldWarn || Force || ShouldContinue(warningText.ToString(),
                    string.Format(Resources.RuntimeMismatchWarning, _azureService.ServiceName)))
                {
                    applicators.ForEach<CloudRuntimeApplicator>(a => a.Apply());
                    service.Components.Save(service.Paths);
                    return true;
                }
            }

            return false;
        }
开发者ID:OctopusDeploy,项目名称:azure-sdk-tools,代码行数:87,代码来源:PublishAzureServiceProject.cs

示例9: SortCoordinates

 private void SortCoordinates(List<District> districts)
 {
     districts.ForEach(d => d.Coordinates = d.Coordinates.OrderBy(c => c.Index).ToList());
 }
开发者ID:CH033dotNET,项目名称:Taxi,代码行数:4,代码来源:DistrictManager.cs


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