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


C# ICollection.Aggregate方法代码示例

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


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

示例1: GetAllTypesAsString

        string GetAllTypesAsString(ICollection<string> types)
        {
            // This causes a conflict with the vim keyword 'contains'
            types.Remove("Contains");

            return types.Aggregate("", (current, type) => current + type + " ");
        }
开发者ID:sphynx79,项目名称:dotfiles,代码行数:7,代码来源:LookupAllTypesHandler.cs

示例2: EvaluateList

        public static string EvaluateList(ICollection<Object> collection, Object lowerNumber, Object higherNumber)
        {
            DivisionOutput result = collection.Aggregate(
                new DivisionOutput() { Operations = String.Empty, Log = String.Empty },
                (currentOutput, value) =>
                    currentOutput += EvaluateItem(value, lowerNumber, higherNumber));

            return result.Operations + "\r\n" + result.Log;
        }
开发者ID:tkocerka,项目名称:FizzBuzz,代码行数:9,代码来源:Divider.cs

示例3: Setup

 public static string Setup(BackgroundWorker worker, ICollection<Row> rows, ICollection<Row> excludeRows, IEnumerable<string> list, IEnumerable<string> exclude)
 {
     foreach (var i in list)
     {
         if (worker.CancellationPending) return null;
         if (exclude.Any(j => i.EndsWith(j, StringComparison.CurrentCultureIgnoreCase)))
         {
             excludeRows.Add(new Row(i, false));
         }
         else if (System.IO.Directory.Exists(i))
         {
             worker.ReportProgress(0, string.Format("{0:#,0}ファイル {1:#,0}行 {2:#,0}バイト 除外 {3:#,0}", rows.Count, rows.Aggregate(0L, (s, r) => s += r.Count ?? 0L), rows.Aggregate(0L, (s, r) => s += r.Size ?? 0L), excludeRows.Count));
             if (Setup(worker, rows, excludeRows, System.IO.Directory.EnumerateFileSystemEntries(i), exclude) == null) return null;
         }
         else if (!rows.Any(j => j.Path == i))
         {
             rows.Add(new Row(i, true));
         }
     }
     return string.Format("全 {0:#,0}ファイル {1:#,0}行 {2:#,0}バイト 除外 {3:#,0}", rows.Count, rows.Aggregate(0L, (s, r) => s += r.Count ?? 0L), rows.Aggregate(0L, (s, r) => s += r.Size ?? 0L), excludeRows.Count);
 }
开发者ID:nakazawaken1,项目名称:LineCounter,代码行数:21,代码来源:ResultWindow.xaml.cs

示例4: Parse

        internal static string Parse(string content, List<string> matches, ICollection<PgType> types)
        {
            foreach (string match in matches)
            {
                string comment = HtmlHelper.RemoveComment(match);

                if (!comment.StartsWith("Types"))
                {
                    continue;
                }

                comment = comment.Replace("Types", "");
                string items = "";
                items = types.Aggregate(items, (current, type) => current + Parse(comment, type));

                content = content.Replace(match, items);
            }
            return content;
        }
开发者ID:njmube,项目名称:pgdoc,代码行数:19,代码来源:TypeParser.cs

示例5: TextureAtlas

        public TextureAtlas(Device device, ICollection<string> filenames) {
            NumCells = filenames.Count;

            // Note: all textures need to be the same size
            var tex = Texture2D.FromFile(device, filenames.First());
            var w = tex.Description.Width;
            var h = tex.Description.Height;
            tex.Dispose();

            Columns = Math.Min(8192 / w, (int)Math.Ceiling(Math.Sqrt(NumCells)));
            Rows = Math.Min(8192 / h, (int)Math.Ceiling((float)NumCells/Columns));

            System.Diagnostics.Debug.Assert(Columns * Rows >= NumCells);

            var bitmap = new Bitmap(Columns * w, Rows * h);
            _texTransforms = new Matrix[NumCells];

            using (var g = Graphics.FromImage(bitmap)) {
                g.Clear(Color.Black);
                var r = 0;
                var c = 0;
                foreach (var filename in filenames) {
                    g.DrawImage(new Bitmap(filename), new Point(c*w, r*h) );

                    _texTransforms[r * Columns + c] =
                        Matrix.Scaling(1.0f/(Columns*2), 1.0f / (2*Rows), 0) * 
                        Matrix.Translation(c * w / (float)bitmap.Width, r * h / (float)bitmap.Width, 0);

                    c++;
                    if (c >= Columns) {
                        c = 0;
                        r++;
                    }

                }
            }
            var tmpFile = Path.GetTempFileName() + ".bmp";
            bitmap.Save(tmpFile);

            TextureView = ShaderResourceView.FromFile(device, tmpFile);
            TextureView.Resource.DebugName = "texture atlas: " +filenames.Aggregate((i, j) => i + ", " + j);
        }
开发者ID:amitprakash07,项目名称:dx11,代码行数:42,代码来源:TextureAtlas.cs

示例6: DataTableToCSV

        /// <summary>
        ///     导出到CSV文件
        /// </summary>
        /// <param name="titles">文件标题</param>
        /// <param name="datas">数据</param>
        /// <param name="fileName">要保存的文件名</param>
        public static void DataTableToCSV(ICollection<string> titles, IEnumerable<object[]> datas, string fileName,
            char split = ',', Encoding encoding = null)
        {
            if (encoding == null)
                encoding = Encoding.UTF8;
            var fs = new FileStream(fileName, FileMode.OpenOrCreate);

            var sw = new StreamWriter(new BufferedStream(fs), encoding);

            var title = titles.Aggregate("", (current, title1) => current + (title1 + split));

            title = title.Substring(0, title.Length - 1) + "\n";

            sw.Write(title);

            foreach (var rows in datas)
            {
                var line = new StringBuilder();
                foreach (var row in rows)
                {
                    if (row != null)
                    {
                        line.Append(row.ToString().Trim());
                    }
                    else
                    {
                        line.Append(" ");
                    }
                    line.Append(split);
                }
                var result = line.ToString().Substring(0, line.Length - 1) + "\n";

                sw.Write(result);
            }

            sw.Close();

            fs.Close();
        }
开发者ID:CHERRISHGRY,项目名称:Hawk,代码行数:45,代码来源:FileConnectorTable.cs

示例7: GetWebsiteNameForGoCommand

 /// <summary>
 /// this method will acquire the website name from a given command which has been identified
 /// as a go to website command.
 /// </summary>
 /// <param name="commandSegments">command segments as a list (to remove problems that may occur when there are spaces)</param>
 /// <returns>identified website name</returns>
 public static string GetWebsiteNameForGoCommand(ICollection<string> commandSegments)
 {
     try
     {
         var fileContent = FileManager.GetContentOfAFile("fnc_brwsr_go"); // get the contents of the respective file as a list
         // the file content above do not comprise of the website names
         // thus the underneath foreach loop will iterate through the file content
         // and if the any of the content is available in the command segments, it will remove them
         // so that the website name will be remaining at the end
         foreach (var content in fileContent.Where(commandSegments.Contains))
         {
             commandSegments.Remove(content);
         }
         // from the remaining command segment, if the user has provided the command as
         // for instance google dot com, the "dot" will be replaced by a "." and finally the command
         // segments will be concatenated and returned to the user
         return commandSegments.Aggregate("", (current, segment) => current + (segment == "dot" ? "." : segment));
     }
     catch (Exception ex)
     {
         Log.ErrorLog(ex);
         throw;
     }
 }
开发者ID:prabash,项目名称:Voice-Based-Web-Browser,代码行数:30,代码来源:CommandParametersManager.cs

示例8: GetCategories

        static string GetCategories(ICollection<Category> categories)
        {
            if (categories == null || categories.Count == 0)
                return string.Empty;

            var html = categories.Aggregate("", (current, cat) => current + string.Format("<a href='#' onclick=\"ChangePostFilter('Category','{0}','{1}')\">{1}</a>, ", cat.Id, cat.Title));
            return html.Trim().Substring(0, html.Trim().Length - 1);
        }
开发者ID:ssuing8825,项目名称:CSharpBBQ,代码行数:8,代码来源:JsonPosts.cs

示例9: AppendLine

        private static double AppendLine(PageRenderData context, ICollection<TextElement> inlines, TextAlignment align, 
                                         ParagraphInfo p, double width, double top, double defaultFontSize, 
                                         int paragraphID, bool firstLine)
        {
            if (inlines.Count == 0)
                return top;

            double height = inlines.Max((t => t.Height));
            double inlinesWidth = inlines.Sum((t => t.Width));
            double leftMargin = 0.0;
            double wordSpacing = 0.0;
            double textIndent = !firstLine || align != TextAlignment.Justify && align != TextAlignment.Left
                              ? 0.0
                              : p.TextIndent;
            width -= p.MarginRight + p.MarginLeft + textIndent;

            switch (align)
            {
                case TextAlignment.Center:
                    leftMargin = (width - inlinesWidth)/2.0;
                    break;
                case TextAlignment.Right:
                    leftMargin = width - inlinesWidth;
                    break;
                case TextAlignment.Justify:
                    wordSpacing = (width - inlinesWidth)/(inlines.Count - 1);
                    break;
            }

            double tempLeftMargin = leftMargin + (p.MarginLeft + textIndent);

            inlines.Aggregate(tempLeftMargin, (current, inlineItem) => 
                BuildInlineItem(context, top, defaultFontSize, paragraphID, inlineItem, height, current, wordSpacing));

            return top + height * AppSettings.Default.FontSettings.FontInterval;
        }
开发者ID:Korshunoved,项目名称:Win10reader,代码行数:36,代码来源:ContextBuilder.cs

示例10: GetSummaryReport

        public static string GetSummaryReport(ICollection<SessionEx> sessions)
        {
            var res = new StringBuilder(DefaultBufferSize);

            res.AppendLine("Name\tValue");

            if (sessions.Count > 0)
            {
                var minDate = sessions.Min(session => session.LastUpdateTime);
                res.AppendLine("MinDate\t{0}", minDate.ToString("yyyy-MM-dd HH:mm:ss"));

                var maxDate = sessions.Max(session => session.LastUpdateTime);
                res.AppendLine("MaxDate\t{0}", maxDate.ToString("yyyy-MM-dd HH:mm:ss"));
            }

            // append leading space as a workaround for the PowerPivot quirk
            // http://social.msdn.microsoft.com/Forums/en-US/sqlkjpowerpivotforexcel/thread/456699ec-b5a2-4ae9-bc9f-b7ed2d637959
            res.AppendLine("SessionsCount\t {0}", sessions.Count);

            var latencyRecordsCount = sessions.Aggregate(0,
                (val, session) => val + session.Records.Where(Util.IsLatency).Count());
            res.AppendLine("LatencyRecordsCount\t {0}", latencyRecordsCount);

            var jitterRecordsCount = sessions.Aggregate(0,
                (val, session) => val + session.Records.Where(Util.IsJitter).Count());
            res.AppendLine("JitterRecordsCount\t {0}", jitterRecordsCount);

            return res.ToString();
        }
开发者ID:sopel,项目名称:AppMetrics,代码行数:29,代码来源:Report.cs

示例11: UpdateSummaryInformation

        /// <summary>
        /// Updates information in summary page.
        /// </summary>
        /// <param name="remappingList">List of remappings</param>
        private void UpdateSummaryInformation(ICollection<RemappingResult> remappingList)
        {
            TimeSpan baseDuration = m_plan.GetTotalTime(m_character.After(m_plan.ChosenImplantSet), false);
            lvPoints.Items.Clear();

            // Add global informations
            ListViewGroup globalGroup = new ListViewGroup("Global informations");
            lvPoints.Groups.Add(globalGroup);

            TimeSpan savedTime = remappingList.Aggregate(TimeSpan.Zero,
                                                         (current, remap) =>
                                                         current.Add(remap.BaseDuration.Subtract(remap.BestDuration)));

            lvPoints.Items.Add(new ListViewItem(
                $"Current time : {baseDuration.ToDescriptiveText(DescriptiveTextOptions.IncludeCommas)}", globalGroup));

            if (savedTime != TimeSpan.Zero)
            {
                lvPoints.Items.Add(
                    new ListViewItem(
                        $"Optimized time : {baseDuration.Subtract(savedTime).ToDescriptiveText(DescriptiveTextOptions.IncludeCommas)}",
                        globalGroup));

                if (savedTime < TimeSpan.Zero)
                {
                    ListViewItem savedTimeItem = lvPoints.Items.Add(
                        new ListViewItem(
                            $"{(-savedTime).ToDescriptiveText(DescriptiveTextOptions.IncludeCommas)} slower than current.",
                                         globalGroup));
                    savedTimeItem.ForeColor = Color.DarkRed;
                }
                else
                {
                    ListViewItem savedTimeItem = lvPoints.Items.Add(
                        new ListViewItem(
                            $"{savedTime.ToDescriptiveText(DescriptiveTextOptions.IncludeCommas)} better than current.",
                                         globalGroup));
                    savedTimeItem.ForeColor = Color.DarkGreen;
                }
            }
            else
                lvPoints.Items.Add(new ListViewItem("Your attributes are already optimal.", globalGroup));

            // Notify plan updated
            ListViewItem lvi = new ListViewItem("Your plan has been updated.", globalGroup)
                                   { Font = FontFactory.GetFont(lvPoints.Font, FontStyle.Bold) };
            lvPoints.Items.Add(lvi);

            // Add pages and summary informations
            TimeSpan lastRemap = TimeSpan.Zero;
            foreach (RemappingResult remap in remappingList)
            {
                AddSummaryForRemapping(remap, ref lastRemap);
            }

            columnHeader.Width = lvPoints.ClientSize.Width;
        }
开发者ID:RapidFiring,项目名称:evemon,代码行数:61,代码来源:AttributesOptimizerWindow.cs

示例12: GetClosestLocation

 private Location GetClosestLocation(ICollection<Location> locations, Location location)
 {
     return locations.Aggregate((loc1, loc2) => location.ComputeEuclidicDistance(loc1) < location.ComputeEuclidicDistance(loc2) ? loc1 : loc2);
 }
开发者ID:UnderNotic,项目名称:ShortPathAlg,代码行数:4,代码来源:RandomGraphGenerator.cs

示例13: Optimize

 public void Optimize(
         BigInteger allFeatureBitMask, BigInteger rejectingFeatureBitMask,
         ICollection<BigInteger> rejectedFeatures) {
     Accepting &= allFeatureBitMask
                  ^ rejectedFeatures.Aggregate(rejectingFeatureBitMask, (a, b) => a | b);
 }
开发者ID:RainsSoft,项目名称:Code2Xml,代码行数:6,代码来源:ClassifierUnit.cs

示例14: DeduceType

        public static Type DeduceType(ICollection<object> values)
        {
            // Try to find a common type among the elements.
            var result = values.Aggregate(null as Type,
                (current, next) => GetCommonType(current, next != null ? next.GetType() : typeof(object)));

            if (result == typeof(object))
            {
                // Try again with interfaces.
                var interfaceSets = values.Select(item => item != null ? item.GetType().GetInterfaces() : null);
                foreach (var commonInterface in CommonInterfaces)
                {
                    if (interfaceSets.All(interfaceSet =>
                        interfaceSet == null || interfaceSet.Contains(commonInterface)))
                    {
                        result = commonInterface;
                        break;
                    }
                }
            }

            return result ?? typeof(object);
        }
开发者ID:ricksladkey,项目名称:Markup-Programming,代码行数:23,代码来源:TypeHelper.cs

示例15: GetTags

        static string GetTags(ICollection<string> tags)
        {
            if (tags == null || tags.Count == 0)
                return string.Empty;

            var html = tags.Aggregate("", (current, tag) => current + string.Format("<a href='#' onclick=\"ChangePostFilter('Tag','{0}','')\">{0}</a>, ", tag));
            return html.Trim().Substring(0, html.Trim().Length - 1);
        }
开发者ID:ssuing8825,项目名称:CSharpBBQ,代码行数:8,代码来源:JsonPosts.cs


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