本文整理汇总了C#中System.Collections.SortedList.Where方法的典型用法代码示例。如果您正苦于以下问题:C# SortedList.Where方法的具体用法?C# SortedList.Where怎么用?C# SortedList.Where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.SortedList
的用法示例。
在下文中一共展示了SortedList.Where方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Pull
/// <summary>
/// Pulls versions
/// </summary>
/// <param name="git2vaultRepoPath">Key=git, Value=vault</param>
/// <param name="limitCount"></param>
/// <param name="restartLimitCount"></param>
/// <returns></returns>
public bool Pull(IEnumerable<KeyValuePair<string, string>> git2vaultRepoPath, long limitCount, long restartLimitCount)
{
int ticks = 0;
//get git current branch name
ticks += this.gitCurrentBranch(out OriginalGitBranch);
Console.WriteLine("Starting git branch is {0}", OriginalGitBranch);
//reorder target branches to start from current branch, so don't need to do checkout for first branch
var targetList =
git2vaultRepoPath.OrderByDescending(p => p.Key.Equals(OriginalGitBranch, StringComparison.CurrentCultureIgnoreCase));
ticks += vaultLogin();
if (!IsSetRootVaultWorkingFolder())
{
Environment.Exit(1);
}
try
{
foreach (var pair in targetList)
{
var gitBranch = pair.Key;
var vaultRepoPath = pair.Value;
Console.WriteLine("\nProcessing git branch {0}", gitBranch);
long currentGitVaultVersion = 0;
//reset ticks
ticks = 0;
if (restartLimitCount > 0)
{
//get current version
ticks += gitVaultVersion(gitBranch, restartLimitCount, ref currentGitVaultVersion);
}
else
{
currentGitVaultVersion = 0;
}
//get vaultVersions
IDictionary<long, VaultVersionInfo> vaultVersions = new SortedList<long, VaultVersionInfo>();
ticks += this.vaultPopulateInfo(vaultRepoPath, vaultVersions);
var versionsToProcess = vaultVersions.Where(p => p.Key > currentGitVaultVersion);
//do init only if there is something to work on
if (versionsToProcess.Count() > 0)
ticks += Init(vaultRepoPath, gitBranch);
//report init
if (null != Progress)
if (Progress(ProgressSpecialVersionInit, ticks))
return true;
var counter = 0;
foreach (var version in versionsToProcess)
{
ticks = Environment.TickCount;
// Obtain just the ChangeSet for this Version of the repo
TxInfo txnInfo = null;
try
{
if (ForceFullFolderGet)
{
throw new FileNotFoundException(
"Forcing full folder get");
}
// Get a list of the changed files
txnInfo = ServerOperations.ProcessCommandTxDetail(version.Value.TrxId);
foreach (VaultTxDetailHistoryItem txdetailitem in txnInfo.items)
{
// Do deletions, renames and moves ourselves
if (txdetailitem.RequestType == VaultRequestType.Delete)
{
// Convert the Vault path to a file system path
String ItemPath1 = String.Copy( txdetailitem.ItemPath1 );
// Ensure the file is within the folder we are working with.
if (ItemPath1.StartsWith(vaultRepoPath, true, System.Globalization.CultureInfo.CurrentCulture))
{
ItemPath1 = ItemPath1.Replace(vaultRepoPath, WorkingFolder, StringComparison.CurrentCultureIgnoreCase);
ItemPath1 = ItemPath1.Replace('/', '\\');
if (File.Exists(ItemPath1))
{
File.Delete(ItemPath1);
//.........这里部分代码省略.........
示例2: Pull
/// <summary>
/// Pulls versions
/// </summary>
/// <param name="git2vaultRepoPath">Key=git, Value=vault</param>
/// <param name="limitCount"></param>
/// <returns></returns>
public bool Pull(IEnumerable<KeyValuePair<string,string>> git2vaultRepoPath, long limitCount)
{
int ticks = 0;
//get git current branch
string gitCurrentBranch;
ticks += this.gitCurrentBranch(out gitCurrentBranch);
//reorder target branches to start from current (to avoid checkouts)
var targetList =
git2vaultRepoPath.OrderByDescending(p => p.Key.Equals(gitCurrentBranch, StringComparison.CurrentCultureIgnoreCase));
ticks += vaultLogin();
try
{
foreach (var pair in targetList)
{
var gitBranch = pair.Key;
var vaultRepoPath = pair.Value;
long currentGitVaultVersion = 0;
//reset ticks
ticks = 0;
//get current version
ticks += gitVaultVersion(gitBranch, ref currentGitVaultVersion);
//get vaultVersions
IDictionary<long, VaultVersionInfo> vaultVersions = new SortedList<long, VaultVersionInfo>();
ticks += this.vaultPopulateInfo(vaultRepoPath, vaultVersions);
var versionsToProcess = vaultVersions.Where(p => p.Key > currentGitVaultVersion);
//do init only if there is something to work on
if (versionsToProcess.Count() > 0)
ticks += Init(vaultRepoPath, gitBranch);
//report init
if (null != Progress)
if (Progress(ProgressSpecialVersionInit, ticks))
return true;
var counter = 0;
foreach (var version in versionsToProcess)
{
//get vault version
ticks = vaultGet(vaultRepoPath, version.Key, version.Value.TrxId);
//change all sln files
Directory.GetFiles(
WorkingFolder,
"*.sln",
SearchOption.AllDirectories)
//remove temp files created by vault
.Where(f => !f.Contains("~"))
.ToList()
.ForEach(f => ticks += removeSCCFromSln(f));
//change all csproj files
Directory.GetFiles(
WorkingFolder,
"*.csproj",
SearchOption.AllDirectories)
//remove temp files created by vault
.Where(f => !f.Contains("~"))
.ToList()
.ForEach(f => ticks += removeSCCFromCSProj(f));
//change all vdproj files
Directory.GetFiles(
WorkingFolder,
"*.vdproj",
SearchOption.AllDirectories)
//remove temp files created by vault
.Where(f => !f.Contains("~"))
.ToList()
.ForEach(f => ticks += removeSCCFromVDProj(f));
//get vault version info
var info = vaultVersions[version.Key];
//commit
ticks += gitCommit(info.Login, info.TrxId, this.GitDomainName,
buildCommitMessage(vaultRepoPath, version.Key, info), info.TimeStamp);
if (null != Progress)
if (Progress(version.Key, ticks))
return true;
counter++;
//call gc
if (0 == counter%GitGCInterval)
{
ticks = gitGC();
if (null != Progress)
if (Progress(ProgressSpecialVersionGc, ticks))
return true;
}
//check if limit is reached
//.........这里部分代码省略.........
示例3: Pull
/// <summary>
/// Pulls versions
/// </summary>
/// <param name="git2VaultRepoPath">Key=git, Value=vault</param>
/// <param name="limitCount"></param>
/// <returns></returns>
public bool Pull(IEnumerable<KeyValuePair<string, string>> git2VaultRepoPath, long limitCount)
{
int ticks = 0;
//get git current branch
string gitCurrentBranch;
ticks += _gitProcessor.GitCurrentBranch(GitCmd, WorkingFolder, out gitCurrentBranch);
//reorder target branches to start from current (to avoid checkouts)
var targetList =
git2VaultRepoPath.OrderByDescending(p => p.Key.Equals(gitCurrentBranch, StringComparison.CurrentCultureIgnoreCase));
ticks += VaultLogin();
try
{
foreach (var pair in targetList)
{
_logger.Debug(String.Format("...handling ... {0} and {1}", pair.Key, pair.Value));
var gitBranch = pair.Key;
var vaultRepoPath = pair.Value;
long currentGitVaultVersion;
//reset ticks
ticks = 0;
//get current version
ticks += GitVaultVersion(gitBranch, out currentGitVaultVersion);
//get vaultVersions
IDictionary<long, VaultVersionInfo> vaultVersions = new SortedList<long, VaultVersionInfo>();
ticks += VaultPopulateInfo(vaultRepoPath, vaultVersions);
var versionsToProcess = vaultVersions.Where(p => p.Key > currentGitVaultVersion).ToList();
//do init only if there is something to work on
if (versionsToProcess.Any())
{
ticks += Init(vaultRepoPath, gitBranch);
}
//report init
if (null != Progress)
if (Progress(PROGRESS_SPECIAL_VERSION_INIT, ticks))
return true;
var counter = 0;
foreach (var version in versionsToProcess)
{
_logger.Info(string.Format("performing actions for version: {0}", version.Key));
//get vault version
ticks = VaultGet(vaultRepoPath, version.Key, version.Value.TrxId);
_logger.Trace(string.Format("modifying all sln files for version: {0}", version.Key));
//change all sln files
Directory.GetFiles(
WorkingFolder,
"*.sln",
SearchOption.AllDirectories)
//remove temp files created by vault
.Where(f => !f.Contains("~"))
.ToList()
.ForEach(f => ticks += RemoveSccFromSln(f));
_logger.Trace(string.Format("modifying all CSPROJ files for version: {0}", version.Key));
//change all csproj files
Directory.GetFiles(
WorkingFolder,
"*.csproj",
SearchOption.AllDirectories)
//remove temp files created by vault
.Where(f => !f.Contains("~"))
.ToList()
.ForEach(f => ticks += RemoveSccFromCsProj(f));
_logger.Trace(string.Format("modifying all VDPROJ files for version: {0}", version));
//change all vdproj files
Directory.GetFiles(
WorkingFolder,
"*.vdproj",
SearchOption.AllDirectories)
//remove temp files created by vault
.Where(f => !f.Contains("~"))
.ToList()
.ForEach(f => ticks += RemoveSccFromVdProj(f));
//get vault version info
var info = vaultVersions[version.Key];
//commit
_logger.Trace("committing to git version: " + version.Key);
ticks += GitCommit(info.Login, info.TrxId, GitDomainName,
BuildCommitMessage(vaultRepoPath, version.Key, info), info.TimeStamp);
//.........这里部分代码省略.........