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


C# Commit.Where方法代码示例

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


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

示例1: GetCommit

		/// <summary>
		/// Get the files in a commit from the repository.
		/// </summary>
		public IEnumerable<FileContent> GetCommit(Commit commit)
		{
			// group the files by directory - CVS can't cope with retrieving files in the same
			// directory in parallel
			var packages = from f in commit
						   where !f.IsDead
						   group f by Path.GetDirectoryName(f.File.Name) into dir
						   select dir as IEnumerable<FileRevision>;
			var dirQueue = new Queue<IEnumerable<FileRevision>>(packages);

			var taskCount = Math.Min(dirQueue.Count, m_cvsProcessCount);
			var tasks = new List<Task<FileContent>>(taskCount);
			var taskQueues = new List<Queue<FileRevision>>(taskCount);

			// start async tasks off
			for (int i = 0; i < taskCount; i++)
			{
				taskQueues.Add(new Queue<FileRevision>(dirQueue.Dequeue()));
				tasks.Add(StartNextFile(taskQueues[i].Dequeue()));
			}

			// now return all dead files
			foreach (var f in commit.Where(f => f.IsDead))
			{
				yield return FileContent.CreateDeadFile(f.File.Name);
			}

			// wait for tasks to complete and start new ones as they do
			while (tasks.Count > 0)
			{
				int taskIndex = Task.WaitAny(tasks.ToArray());
				var completedTask = tasks[taskIndex];

				if (taskQueues[taskIndex].Any())
				{
					// items left in the task's single directory queue
					tasks[taskIndex] = StartNextFile(taskQueues[taskIndex].Dequeue());
				}
				else if (dirQueue.Any())
				{
					// no more items in the task's directory, so start on the next one
					taskQueues[taskIndex] = new Queue<FileRevision>(dirQueue.Dequeue());
					tasks[taskIndex] = StartNextFile(taskQueues[taskIndex].Dequeue());
				}
				else
				{
					// no more directories left
					taskQueues.RemoveAt(taskIndex);
					tasks.RemoveAt(taskIndex);
				}

				yield return completedTask.Result;
			}
		}
开发者ID:runt18,项目名称:CvsntGitImporter,代码行数:57,代码来源:Cvs.cs

示例2: Apply

		/// <summary>
		/// Apply a commit.
		/// </summary>
		public void Apply(Commit commit)
		{
			var state = this[commit.Branch];
			state.Apply(commit);

			// find any file revisions that are branchpoints for branches and update the state of those branches
			var branches = commit
					.SelectMany(f => f.File.GetBranchesAtRevision(f.Revision))
					.Distinct()
					.Where(b => m_branches.ContainsKey(b));

			foreach (var branch in branches)
			{
				var tempCommit = new Commit("");
				foreach (var fr in commit.Where(f => f.File.GetBranchesAtRevision(f.Revision).Contains(branch)))
					tempCommit.Add(fr);
				this[branch].Apply(tempCommit);
			}
		}
开发者ID:runt18,项目名称:CvsntGitImporter,代码行数:22,代码来源:RepositoryState.cs

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