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


C# Commit.Max方法代码示例

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


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

示例1: ToStream

        /// <summary>
        ///   To stream.
        /// </summary>
        /// <param name="commiters">The commiters.</param>
        /// <param name="outputStream">The output stream.</param>
        /// <returns>A stream containing markup contents.</returns>
        public Stream ToStream(Commit[] commiters, Stream outputStream = null)
        {
            MemoryStream memory = new MemoryStream();
            StreamWriter writer;

            if (outputStream == null)
            {
                writer = new StreamWriter(memory);
            }
            else
            {
                writer = new StreamWriter(outputStream);
            }

            foreach (TextBlock block in this._blocks)
            {
                switch (block.Type)
                {
                    case BlockType.Author:

                        var uniqueAuthors = commiters.Select(x => x.Author).Distinct();

                        foreach (var author in uniqueAuthors)
                        {
                            this.WriteAuthors(
                                    writer,
                                    block,
                                    commiters.Where(x => x.Author.Equals(author)).ToArray());

                            if (!string.IsNullOrEmpty(block.PostText))
                            {
                                var last = uniqueAuthors.Last();

                                // Add the separator if it is not the last route.
                                if (last != author)
                                {
                                    writer.Write(block.PostText);
                                    writer.Flush();
                                }
                            }
                        }

                        break;

                    case BlockType.Date:

                        // Stub.

                        break;

                    default:

                        int idx;

                        // Search for y-min tokens.
                        while ((idx = block.Text.IndexOf("{ymin}", StringComparison.CurrentCultureIgnoreCase)) > -1)
                        {
                            block.Text = block.Text.Replace(
                                block.Text.Substring(idx, "{ymin}".Length),
                                commiters.Min(x => x.LinesOfChange).ToString());
                        }

                        // Search for y-max tokens.
                        while ((idx = block.Text.IndexOf("{ymax}", StringComparison.CurrentCultureIgnoreCase)) > -1)
                        {
                            block.Text = block.Text.Replace(
                                block.Text.Substring(idx, "{ymax}".Length),
                                commiters.Max(x => x.LinesOfChange).ToString());
                        }

                        // Search for y-min tokens.
                        while ((idx = block.Text.IndexOf("{xmin}", StringComparison.CurrentCultureIgnoreCase)) > -1)
                        {
                            block.Text = block.Text.Replace(
                                block.Text.Substring(idx, "{xmin}".Length),
                                ConvertToJavascriptTimestamp(commiters.Min(x => x.Date)).ToString());
                        }

                        // Search for y-max tokens.
                        while ((idx = block.Text.IndexOf("{xmax}", StringComparison.CurrentCultureIgnoreCase)) > -1)
                        {
                            block.Text = block.Text.Replace(
                                block.Text.Substring(idx, "{xmax}".Length),
                                ConvertToJavascriptTimestamp(commiters.Max(x => x.Date)).ToString());
                        }

                        // Nothing to see here.
                        writer.Write(block.Text);
                        writer.Flush();

                        break;
                }
            }

//.........这里部分代码省略.........
开发者ID:bmallred,项目名称:churn-sharp,代码行数:101,代码来源:Parser.cs


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