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


C# List.ForEach方法代码示例

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


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

示例1: ReadFeed

        public Feed ReadFeed(Uri uri)
        {
            Feed feed = null;
            var feedItems = new List<FeedItem>();
            Category category = null;

            SyndicationFeed syndicationFeed;
            using (var xmlReader = XmlReader.Create(uri.AbsoluteUri))
            {
                syndicationFeed = SyndicationFeed.Load(xmlReader);
                xmlReader.Close();
            }

            if (syndicationFeed == null) return null;
            foreach (var item in syndicationFeed.Items)
            {
                var feedItem = new FeedItem();
                Guid id;

                feedItem.Id = Guid.TryParse(item.Id, out id) ? id : new Guid();
                feedItem.Title = item.Title.Text;
                feedItem.Mp3Url = item.Links.Count > 1 ? item.Links[1].Uri : item.Links[0].Uri;
                feedItem.PublishDate = item.PublishDate.DateTime;
                feedItem.Description = StripHTML(item.Summary.Text);
                feedItem.IsUsed = false;
                feedItems.Add(feedItem);
            }

            var items = new List<Data.IFeedItem>();
            feedItems.ForEach(x => items.Add(x));
            feed = new Feed(Guid.NewGuid(), syndicationFeed.Title.Text, items, uri, category,0);

            return feed;
        }
开发者ID:kimdah3,项目名称:CSharpProjectLarsKimLinus,代码行数:34,代码来源:RssReader.cs

示例2: ReadFeedItems

        public List<FeedItem> ReadFeedItems(Uri uri)
        {
            var feedItems = new List<Data.IFeedItem>();
            SyndicationFeed syndicationFeed;
            using (var xmlReader = XmlReader.Create(uri.AbsoluteUri))
            {
                syndicationFeed = SyndicationFeed.Load(xmlReader);
                xmlReader.Close();
            }

            foreach (var item in syndicationFeed.Items)
            {
                var feedItem = new FeedItem();
                var id = Guid.NewGuid();
                feedItem.Id = Guid.TryParse(item.Id, out id) ? new Guid(item.Id) : id;
                feedItem.Title = item.Title.Text;
                feedItem.Mp3Url = item.Links[0].Uri;
                feedItem.PublishDate = item.PublishDate.DateTime;

                feedItems.Add(feedItem);
            }

            var ret = new List<FeedItem>();
            feedItems.ForEach(x => ret.Add(new FeedItem() { Id = x.Id, Mp3Url = x.Mp3Url, PublishDate = x.PublishDate, Title = x.Title }));
            return ret;
        }
开发者ID:kimdah3,项目名称:CSharpProjectLarsKimLinus,代码行数:26,代码来源:RssReader.cs

示例3: WhenDataFetchedThenWritesEachLine

        public static void WhenDataFetchedThenWritesEachLine()
        {
            var data = new List<string> { Guid.NewGuid().ToString() };
            var repository = new Mock<IDataRepository>();
            repository.Setup(m => m.Fetch()).Returns(data);
            var writer = new Mock<TextWriter>();

            new DisplayData(writer.Object, repository.Object).Run();

            data.ForEach(x => writer.Verify(m => m.WriteLine(x), Times.Once));
        }
开发者ID:smudge202,项目名称:hardcoding-example,代码行数:11,代码来源:DisplayDataTests.cs

示例4: Init

        public void Init()
        {
            if (!Directory.Exists(_workdirectory))
            {
                Directory.CreateDirectory(_workdirectory);
            }
            _requirements = Directory.EnumerateFiles(_workdirectory, "*.tz").ToList().Select(file =>
                new Requirement {Code = Path.GetFileNameWithoutExtension(file), Context = File.ReadAllText(file)})
                .ToList();
            DbManagementRepository dbManagementRepository = new DbManagementRepository();

            _requirements.ForEach(p => dbManagementRepository.Insert(p));
        }
开发者ID:qhczzqpjr,项目名称:MyRepository,代码行数:13,代码来源:FileManagementRepository.cs

示例5: GetEssayCategories

        public List<Category> GetEssayCategories()
        {
            var categories = new List<Category>();

            foreach (var essayDictItem in essaysDictionary)
            {
                if (!categories.Exists(e => e.Name == essayDictItem.Value.Category))
                {
                    categories.Add(new Category(essayDictItem.Value.Category));
                }

                categories.Single(e => e.Name == essayDictItem.Value.Category).EssaysForCategory.Add(
                    new EssayForCategory(essayDictItem.Value.Title, essayDictItem.Key, essayDictItem.Value.PublishInfo.OriginalPublishDate));
            }

            categories.ForEach(c => c.EssaysForCategory = c.EssaysForCategory.OrderByDescending(e => e.PublishDate).ToList());
            return categories;
        }
开发者ID:kawaicheung,项目名称:lifeimitatescode,代码行数:18,代码来源:Library.cs

示例6: UpdateAdCacheFromPaper

        //jlg bad logic
        private void UpdateAdCacheFromPaper(Newspaper entity)
        {
            List<Advertisement> deletedAds = new List<Advertisement>();

            foreach (var ad in entity.Advertisements)
            {
                switch (entity.DbStatus)
                {
                    case DbModificationState.Unchanged:
                    case DbModificationState.Added:
                    case DbModificationState.Modified:

                        if(!_advertisementCache.ContainsKey(ad.UKey))
                            _advertisementCache.Add(ad.UKey,ad);

                        deletedAds.AddRange(entity.Advertisements.Where(a=>a.DbStatus==DbModificationState.Deleted));
                        break;

                    case DbModificationState.Deleted:

                        foreach (var cacheAd in _advertisementCache.Values.ToList())
                        {
                            cacheAd.Newspapers.Remove(entity);
                        }
                        break;
                }
            }

            deletedAds.ForEach(a=>_advertisementCache.Remove(a.UKey));
        }
开发者ID:jgartee,项目名称:PillarKata,代码行数:31,代码来源:NewspaperAdRepository.cs

示例7: CreateTranslations

        public static List<Translation> CreateTranslations(TranslationRepository translationsRepository)
        {
            var english = new CultureInfo("en-US");
            var dutch = new CultureInfo("nl-NL");

            var translations = new List<Translation>
            {
                // en-US
                new Translation("Login", "Login", english),
                new Translation("Logout", "Logout", english),
                new Translation("Home", "Home", english),
                new Translation("Users", "Users", english),
                new Translation("SendEmail", "Send email", english),
                new Translation("FlashMessages", "Flash messages", english),
                new Translation("Unauthorized", "Unauthorized", english),
                new Translation("Forbidden", "Forbidden", english),
                new Translation("PageNotFound", "Page not found", english),
                new Translation("InternalServerError", "Internal server error", english),
                new Translation("DearSirOrMadam", "Dear sir or madam", english),
                new Translation("KindRegards", "Kind regards", english),
                new Translation("ResetPassword", "Reset password", english),
                new Translation("ResetPasswordMailMessage", "We received a request to change your password. By clicking the link below you are able to reset your password.\r\nIn case you did not initiate this request, you can simply ignore this message, your password will remain unchanged.\r\n", english),
                new Translation("ResetPasswordMailMessageText", "We received a request to change your password. By using the link below you are able to reset your password.\r\nIn case you did not initiate this request, you can simply ignore this message, your password will remain unchanged.\r\n", english),
                new Translation("Required", "Required", english),
                new Translation("Email", "Email", english),
                new Translation("Password", "Password", english),
                new Translation("RepeatPassword", "Repeat password", english),
                new Translation("SignIn", "Sign in", english),
                new Translation("EmailAndPasswordCombinationNotValid", "Email and/or password is not valid", english),
                new Translation("InvalidEmailAddress", "Emailaddress is not valid", english),
                new Translation("UserWithEmailAddressWasNotFound", "User with emailaddress '{0}' was not found", english),
                new Translation("Send", "Send", english),
                new Translation("Back", "Back", english),
                new Translation("ChangePassword", "Change password", english),
                new Translation("PasswordsDoNotMatch", "Passwords do not match", english),
                new Translation("RequestToResetYourPassword", "Request to reset your password", english),
                new Translation("Success", "Success", english),
                new Translation("Info", "Info", english),
                new Translation("Warning", "Warning", english),
                new Translation("Error", "Error", english),
                new Translation("AnEmailWasSendToYourEmailaddressWithInstructionsOnHowToResetYourPassword", "An email was send to your emailaddress with instructions on how to reset your password", english),
                new Translation("YourPasswordWasChangedSuccessfully", "Your password was changed successfully", english),
                new Translation("ChuckNorrisFacts", "Chuck Norris Facts", english),
                new Translation("Shortcuts", "Shortcuts", english),
                new Translation("MorePages", "More pages", english),
                new Translation("PasswordShouldContainAtLeast5Characters", "Password should contain at least 5 characters", english),
                new Translation("ClientSideFlashMessages", "Client side flash messages", english),
                new Translation("InlineClientSideFlashMessages", "Inline client side flash messages", english),
                new Translation("EmailSuccessfullySend", "Email successfully send", english),

                // nl-NL
                new Translation("Login", "Inloggen", dutch),
                new Translation("Logout", "Uitloggen", dutch),
                new Translation("Home", "Thuis", dutch),
                new Translation("Users", "Gebruikers", dutch),
                new Translation("SendEmail", "Verstuur e-mail", dutch),
                new Translation("FlashMessages", "Notificatie berichten", dutch),
                new Translation("Unauthorized", "Onbevoegd", dutch),
                new Translation("Forbidden", "Verboden", dutch),
                new Translation("PageNotFound", "Pagina niet gevonden", dutch),
                new Translation("InternalServerError", "Interne server fout", dutch),
                new Translation("DearSirOrMadam", "Geachte heer, mevrouw", dutch),
                new Translation("KindRegards", "Vriendelijke groeten", dutch),
                new Translation("ResetPassword", "Reset wachtwoord", dutch),
                new Translation("ResetPasswordMailMessage", "Een aanvraag voor wijziging van uw wachtwoord is bij ons aangekomen. Door op onderstaande link te klikken kunt u een nieuw wachtwoord opgeven.\r\nIndien u geen verzoek tot wijziging heeft gedaan kunt u deze email als niet verzonden beschouwen, uw bestaande wachtwoord blijft dan intact.\r\n", dutch),
                new Translation("ResetPasswordMailMessage", "Een aanvraag voor wijziging van uw wachtwoord is bij ons aangekomen. Door onderstaande link te gebruiken kunt u een nieuw wachtwoord opgeven.\r\nIndien u geen verzoek tot wijziging heeft gedaan kunt u deze email als niet verzonden beschouwen, uw bestaande wachtwoord blijft dan intact.\r\n", dutch),
                new Translation("Required", "Verplicht", dutch),
                new Translation("Email", "Email", dutch),
                new Translation("Password", "Wachtwoord", dutch),
                new Translation("RepeatPassword", "Herhaal wachtwoord", dutch),
                new Translation("SignIn", "Inloggen", dutch),
                new Translation("EmailAndPasswordCombinationNotValid", "Email en/of wachtwoord is niet geldig", dutch),
                new Translation("InvalidEmailAddress", "Emailadres is niet geldig", dutch),
                new Translation("UserWithEmailAddressWasNotFound", "Gebruiker met emailadres '{0}' is niet gevonden", dutch),
                new Translation("Send", "Verzenden", dutch),
                new Translation("Back", "Terug", dutch),
                new Translation("ChangePassword", "Wachtwoord wijzigen", dutch),
                new Translation("PasswordsDoNotMatch", "Wachtwoorden komen niet overeen", dutch),
                new Translation("RequestToResetYourPassword", "Verzoek om uw wachtwoord te wijzigen", dutch),
                new Translation("Success", "Succes", dutch),
                new Translation("Info", "Info", dutch),
                new Translation("Warning", "Pas op", dutch),
                new Translation("Error", "Fout", dutch),
                new Translation("AnEmailWasSendToYourEmailaddressWithInstructionsOnHowToResetYourPassword", "Een email is naar u toegestuurd met instructies hoe u uw wachtwoord kunt resetten.", dutch),
                new Translation("YourPasswordWasChangedSuccessfully", "Uw wachtwoord is succesvol aangepast", dutch),
                new Translation("ChuckNorrisFacts", "Chuck Norris Feiten", dutch),
                new Translation("Shortcuts", "Shortcuts", dutch),
                new Translation("MorePages", "Meer pagina's", dutch),
                new Translation("PasswordShouldContainAtLeast5Characters", "Wachtwoord dient minimaal 5 tekens te bevatten", dutch),
                new Translation("ClientSideFlashMessages", "Client side flash berichten", dutch),
                new Translation("InlineClientSideFlashMessages", "Inline client side flash berichten", dutch),
                new Translation("EmailSuccessfullySend", "Email succesvol verzonden", dutch),
            };

            translations.ForEach(translationsRepository.Save);

            return translations;
        }
开发者ID:robinvanderknaap,项目名称:SkaeleArchitecture,代码行数:98,代码来源:PocoGenerator.cs

示例8: Run

        static async void Run()
        {

            //var extractPath = ExtractingFromZip();
            var xmlPath =
                @"E:\TWs\Database-2015-Team-Flerovium-\ImportingReports\ImportingReports\XmlImportFile\Books.xml";
            XDocument doc = XDocument.Load(xmlPath);

            var zipFilePath = @"E:\TWs\Database-2015-Team-Flerovium-\ImportingReports\ImportingReports\ZipFile\Sales-Reports.zip";
            var extractedFolderPath = ExtractZip(zipFilePath);
            var dateNamedFolders = GetDateNamedFolders(extractedFolderPath);

            var allSales = new List<Sale>();

            foreach (var folder in dateNamedFolders)
            {
                foreach (var file in folder.GetFiles())
                {
                    var salesForFile = ExtractExcelData(file.FullName, file.Name, folder.Name);
                    allSales.AddRange(salesForFile);
                }
            }

            allSales.ForEach(Console.WriteLine);

            var root = doc.Root;

            var books = root.Elements().AsQueryable().Select(BookMongo.FromXElement).ToList();

            var client = new MongoClient("mongodb://localhost");
            var db = client.GetDatabase("books-db");

            var booksCollection = db.GetCollection<BsonDocument>("books");

            var bsonBooks = books.AsQueryable().Select(BookMongo.ToBsonDocument);

            await booksCollection.InsertManyAsync(bsonBooks);

            var dbContext = new BooksDbContext();
            var mongoBooks = await booksCollection.Find(new BsonDocument()).ToListAsync();
            var bookModels = mongoBooks.Select(bookBson =>
            {
                var authorIdToString = bookBson["AuthorId"].ToString();
                var author =
                    dbContext.Authors.FirstOrDefault(a => a.AuthorId.ToString() == authorIdToString);
                if (author == null)
                {
                    author = new Author
                    {
                        AuthorId = int.Parse(bookBson["AuthorId"].ToString()),
                        AuthorName = bookBson["Author"].ToString()
                    };
                    dbContext.Authors.AddOrUpdate(a => a.AuthorName, author);
                    dbContext.SaveChanges();
                }

                var publisherIdToString = bookBson["PublisherId"].ToString();
                var publisher = dbContext.BookPublishers.FirstOrDefault(
                     b => b.BookPublisherId.ToString() == publisherIdToString);

                if (publisher == null)
                {
                    publisher = new BookPublisher
                    {
                        BookPublisherId = int.Parse(bookBson["PublisherId"].ToString()),
                        BookPublisherName = bookBson["Publisher"].ToString()
                    };
                    dbContext.BookPublishers.AddOrUpdate(p => p.BookPublisherName, publisher);
                    dbContext.SaveChanges();
                }

                var book = new Book
                {
                    BookId = int.Parse(bookBson["BookId"].ToString()),
                    AuthorId = int.Parse(bookBson["AuthorId"].ToString()),
                    BookPublisherId = int.Parse(bookBson["PublisherId"].ToString()),
                    Title = bookBson["Title"].ToString(),
                    BasePrice = decimal.Parse(bookBson["BasePrice"].ToString()),
                    Author = author,
                    Publisher = publisher
                };
                return book;
            });

            Console.WriteLine("--------------- {0} Saving Books", bookModels.Count());
            dbContext.Books.AddOrUpdate(b => b.Title, bookModels.ToArray());

            dbContext.SaveChanges();
            Console.WriteLine("---------------Books saved!");

            allSales.ForEach(sale => dbContext.Sales.Add(sale));
            dbContext.SaveChanges();

            Console.WriteLine("HERE");
            var products = MySQLReadProductsTable();
            WriteExcelSheet(products, "Products.xlsx");

            var towns = MySQLReadTownsTable();
            WriteExcelSheet(towns, "Towns.xlsx");

//.........这里部分代码省略.........
开发者ID:GeriCookie,项目名称:Database-2015-Team-Flerovium-,代码行数:101,代码来源:Program.cs

示例9: HandleUrl

        public static void HandleUrl(string url, MetroWindow window)
        {
            url = WebUtility.UrlDecode(url.Remove(0, FullName.Length));

            var r = Regex.Matches(url, "(project|projectGroup)/([^/]*)/([^/]*)/([^/]*)/?");
            foreach (Match m in r)
            {
                var linkType = m.Groups[1].ToString();
              
                switch (linkType)
                {
                    case "project":
                        var gitHubUser = m.Groups[2].ToString();
                        var repositoryName = m.Groups[3].ToString();
                        var assemblyName = m.Groups[4].ToString();

                        var w = new InstallerWindow { Owner = window };
                        w.ListAssemblies(
                            string.Format("https://github.com/{0}/{1}", gitHubUser, repositoryName), true,
                            assemblyName != "" ? m.Groups[4].ToString() : null);
                        w.ShowDialog();
                        break;

                    case "projectGroup":
                        
                        var remaining = url.Remove(0, 13);
                        var assemblies = new List<LeagueSharpAssembly>();

                        while (remaining.IndexOf("/", StringComparison.InvariantCulture) != -1)
                        {
                            var data = remaining.Split(new[] {'/'});
                            if (data.Length < 3)
                            {
                                break;
                            }
                            
                            var assembly = new LeagueSharpAssembly(data[2], "", 
                                string.Format("https://github.com/{0}/{1}", data[0], data[1]));
                            assemblies.Add(assembly);
                            for (int i = 0; i < 3; i++)
                            {
                                remaining = remaining.Remove(0, remaining.IndexOf("/", StringComparison.InvariantCulture) + 1);
                            }
                        }

                        if (assemblies.Count > 0)
                        {
                            assemblies.ForEach(
                                assembly => Config.Instance.SelectedProfile.InstalledAssemblies.Add(assembly));
                            ((MainWindow) window).PrepareAssemblies(assemblies, true, true, false);
                            ((MainWindow) window).ShowTextMessage(Utility.GetMultiLanguageText("Installer"),
                                Utility.GetMultiLanguageText("SuccessfullyInstalled"));
                        }
                        break;
                }
            }
        }
开发者ID:joaocustodio,项目名称:LeagueSharp.Loader-1,代码行数:57,代码来源:LSUriScheme.cs

示例10: Copy


//.........这里部分代码省略.........
            dpsString.Replace("{timer}", interval.ToString(@"mm\:ss"));
            dpsString.Replace("{partyDps}",
                FormatHelpers.Instance.FormatValue(lastHit - firstHit > 0
                    ? entityInfo.TotalDamage/(lastHit - firstHit)
                    : 0) + LP.PerSecond);
            dpsString.Replace("{enrage}", FormatHelpers.Instance.FormatPercent(enrageperc));
            dpsString.Replace("{debuff_list}", String.Join(" | ",
                bossDebuff.Where(x => x.Key.Id != 8888888 && x.Value.Duration(firstTick, lastTick) > 0).OrderByDescending(x => x.Value.Duration(firstTick, lastTick)).ToList().Select(
                    x => x.Key.ShortName + " " + FormatHelpers.Instance.FormatPercent((double)x.Value.Duration(firstTick, lastTick) / (lastTick - firstTick)) +
                        " (" + TimeSpan.FromTicks(x.Value.Duration(firstTick, lastTick)).ToString(@"mm\:ss") + ") ")
            ));
            dpsString.Replace("{debuff_list_p}", String.Join(" | ",
                bossDebuff.Where(x => x.Key.Id != 8888888 && x.Value.Duration(firstTick, lastTick) > 0).OrderByDescending(x => x.Value.Duration(firstTick, lastTick)).ToList().Select(
                    x => x.Key.ShortName + " " + FormatHelpers.Instance.FormatPercent((double)x.Value.Duration(firstTick, lastTick) / (lastTick - firstTick)))
            ));

            var placeholders = new List<KeyValuePair<PlayerDamageDealt, Dictionary<string, string>>>();
            foreach (var playerStats in playerInfosOrdered)
            {
                var playerHolder = new Dictionary<string, string>();
                placeholders.Add(new KeyValuePair<PlayerDamageDealt, Dictionary<string, string>>(playerStats, playerHolder));
                var buffs = abnormals.Get(playerStats.Source);
                AbnormalityDuration slaying;
                var firstOrDefault = heals.FirstOrDefault(x => x.Source == playerStats.Source);
                double healCritrate = 0;
                if (firstOrDefault != null)
                {
                    healCritrate = firstOrDefault.CritRate;
                }
                buffs.Times.TryGetValue(BasicTeraData.Instance.HotDotDatabase.Slaying, out slaying);
                var slayingperc = lastTick - firstTick == 0
                    ? 0
                    : (double)(slaying?.Duration(firstTick, lastTick) ?? 0) / (lastTick - firstTick);
                playerHolder["{slaying}"] = FormatHelpers.Instance.FormatPercent(slayingperc);
                playerHolder["{dps}"] = FormatHelpers.Instance.FormatValue(playerStats.Interval == 0 ? playerStats.Amount : playerStats.Amount * TimeSpan.TicksPerSecond / playerStats.Interval) + LP.PerSecond;
                playerHolder["{global_dps}"] = FormatHelpers.Instance.FormatValue(entityInfo.Interval == 0 ? playerStats.Amount : playerStats.Amount * TimeSpan.TicksPerSecond / entityInfo.Interval) + LP.PerSecond;
                playerHolder["{interval}"] = playerStats.Interval/TimeSpan.TicksPerSecond + LP.Seconds;
                playerHolder["{damage_dealt}"] = FormatHelpers.Instance.FormatValue(playerStats.Amount);
                playerHolder["{class}"] = LP.ResourceManager.GetString(playerStats.Source.Class.ToString(), LP.Culture) + "";
                playerHolder["{fullname}"] = playerStats.Source.FullName;
                playerHolder["{name}"] = playerStats.Source.Name;
                playerHolder["{deaths}"] = buffs.Death.Count(firstTick, lastTick) + "";
                playerHolder["{death_duration}"] = TimeSpan.FromTicks(buffs.Death.Duration(firstTick, lastTick)).ToString(@"mm\:ss");
                playerHolder["{aggro}"] = buffs.Aggro(entityInfo.Entity).Count(firstTick, lastTick) + "";
                playerHolder["{aggro_duration}"] = TimeSpan.FromTicks(buffs.Aggro(entityInfo.Entity).Duration(firstTick, lastTick)).ToString(@"mm\:ss");
                playerHolder["{damage_percentage}"] = playerStats.Amount * 100 / entityInfo.TotalDamage + "%";
                playerHolder["{crit_rate}"] = playerStats.CritRate + "%";
                playerHolder["{crit_rate_heal}"] = healCritrate + "%";
                playerHolder["{biggest_crit}"] = FormatHelpers.Instance.FormatValue(skills.BiggestCrit(playerStats.Source.User, entityInfo.Entity, timedEncounter));
                playerHolder["{damage_received}"] = FormatHelpers.Instance.FormatValue(skills.DamageReceived(playerStats.Source.User, entityInfo.Entity, timedEncounter));
                playerHolder["{hits_received}"] = FormatHelpers.Instance.FormatValue(skills.HitsReceived(playerStats.Source.User, entityInfo.Entity, timedEncounter));
                playerHolder["{debuff_list}"] = String.Join(" | ",
                    bossDebuff.Where(x=>x.Key.Id!=8888888 && x.Value.InitialPlayerClass==playerStats.Source.Class && x.Value.Duration(firstTick,lastTick)>0).OrderByDescending(x => x.Value.Duration(firstTick, lastTick)).ToList().Select(
                        x=>x.Key.ShortName + " " + FormatHelpers.Instance.FormatPercent((double)x.Value.Duration(firstTick,lastTick) / (lastTick - firstTick)) +
                            " ("+ TimeSpan.FromTicks(x.Value.Duration(firstTick, lastTick)).ToString(@"mm\:ss")+") ")
                );
                playerHolder["{debuff_list_p}"] = String.Join(" | ",
                    bossDebuff.Where(x => x.Key.Id != 8888888 && x.Value.InitialPlayerClass == playerStats.Source.Class && x.Value.Duration(firstTick, lastTick) > 0).OrderByDescending(x => x.Value.Duration(firstTick, lastTick)).ToList().Select(
                        x => x.Key.ShortName + " " + FormatHelpers.Instance.FormatPercent((double)x.Value.Duration(firstTick, lastTick) / (lastTick - firstTick)))
                );
            }
            var placeholderLength = placeholders.SelectMany(x => x.Value).GroupBy(x=>x.Key).ToDictionary(x=>x.Key,x=>x.Max(z=> graphics.MeasureString(z.Value, Font, default(PointF), StringFormat.GenericTypographic).Width));
            var dpsmono = new StringBuilder(dpsString.ToString());
            var placeholderMono = placeholders.SelectMany(x => x.Value).GroupBy(x => x.Key).ToDictionary(x => x.Key, x => x.Max(z => z.Value.Length));
            if ((content.Contains('\\')||lowDpsContent.Contains('\\')) && BasicTeraData.Instance.WindowData.FormatPasteString)
                placeholders.ForEach(x =>
                {
                    var currentContent = x.Key.Amount*100/entityInfo.TotalDamage >= lowDpsThreshold ? new StringBuilder(content): new StringBuilder(lowDpsContent);
                    x.Value.ToList().ForEach(z => currentContent.Replace(z.Key, PadRight(z.Value,placeholderLength[z.Key])));
                    dpsString.Append(currentContent);
                    currentContent = x.Key.Amount * 100 / entityInfo.TotalDamage >= lowDpsThreshold ? new StringBuilder(content) : new StringBuilder(lowDpsContent);
                    x.Value.ToList().ForEach(z => currentContent.Replace(z.Key, z.Value.PadRight(placeholderMono[z.Key])));
                    dpsmono.Append(currentContent);
                });
            else
                { placeholders.ForEach(x =>
                    {
                        var currentContent = x.Key.Amount * 100 / entityInfo.TotalDamage >= lowDpsThreshold ? new StringBuilder(content) : new StringBuilder(lowDpsContent);
                        x.Value.ToList().ForEach(z => currentContent.Replace(z.Key, z.Value));
                        dpsString.Append(currentContent);
                    });
                dpsmono = dpsString;
                }
            var footerstr=footer.Replace("{debuff_list}", String.Join(" | ",
                    bossDebuff.Where(x => x.Key.Id != 8888888 && x.Value.Duration(firstTick, lastTick) > 0).OrderByDescending(x => x.Value.Duration(firstTick, lastTick)).ToList().Select(
                        x => x.Key.ShortName + " " + FormatHelpers.Instance.FormatPercent((double)x.Value.Duration(firstTick, lastTick) / (lastTick - firstTick)) +
                        " (" + TimeSpan.FromTicks(x.Value.Duration(firstTick, lastTick)).ToString(@"mm\:ss") + ") ")
                )).Replace("{debuff_list_p}", String.Join(" | ",
                    bossDebuff.Where(x => x.Key.Id != 8888888 && x.Value.Duration(firstTick, lastTick) > 0).OrderByDescending(x => x.Value.Duration(firstTick, lastTick)).ToList().Select(
                        x => x.Key.ShortName + " " + FormatHelpers.Instance.FormatPercent((double)x.Value.Duration(firstTick, lastTick) / (lastTick - firstTick)))
                ));
            dpsString.Append(footerstr);
            dpsmono.Append(footerstr);
            var paste = dpsString.ToString();
            var monoPaste = dpsmono.ToString();
            while (paste.Contains(" \\")) paste = paste.Replace(" \\", "\\");
            while (monoPaste.Contains(" \\")) monoPaste = monoPaste.Replace(" \\", "\\");
            monoPaste = monoPaste.Replace("\\", Environment.NewLine);
            return new Tuple<string,string>(paste ,monoPaste);
        }
开发者ID:neowutran,项目名称:ShinraMeter,代码行数:101,代码来源:CopyPaste.cs

示例11: GetEssayYears

        public List<Year> GetEssayYears()
        {
            var years = new List<Year>();

            foreach (var essayDictItem in essaysDictionary)
            {
                if (!years.Exists(e => e.YearValue == essayDictItem.Value.PublishYear))
                {
                    years.Add(new Year(essayDictItem.Value.PublishYear));
                }

                years.Single(e => e.YearValue == essayDictItem.Value.PublishYear).EssaysForYear.Add(
                    new EssayForYear(essayDictItem.Value.Title, essayDictItem.Key, essayDictItem.Value.Category, essayDictItem.Value.PublishInfo.OriginalPublishDate));
            }

            years.ForEach(c => c.EssaysForYear = c.EssaysForYear.OrderByDescending(e => e.PublishDate).ToList());
            return years.OrderByDescending(y => y.YearValue).ToList();
        }
开发者ID:kawaicheung,项目名称:lifeimitatescode,代码行数:18,代码来源:Library.cs


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