本文整理汇总了C#中IConsole.OverWrite方法的典型用法代码示例。如果您正苦于以下问题:C# IConsole.OverWrite方法的具体用法?C# IConsole.OverWrite怎么用?C# IConsole.OverWrite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IConsole
的用法示例。
在下文中一共展示了IConsole.OverWrite方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ClonePublicHttpSubmodule
public static async Task ClonePublicHttpSubmodule(IConsole console, string sourceurl, string workingPath)
{
TransferProgressHandler transferHandler = e =>
{
console.OverWrite(
$"Bytes: {ByteSizeHelper.ToString(e.ReceivedBytes)}, Objects: {e.ReceivedObjects}/{e.TotalObjects}, Indexed: {e.IndexedObjects}");
return true;
};
CheckoutProgressHandler checkoutHandler =
(path, steps, totalSteps) => { console.OverWrite($"Checkout: {steps}/{totalSteps}"); };
await
Task.Factory.StartNew(
() =>
{
Repository.Clone(sourceurl, workingPath,
new CloneOptions {OnTransferProgress = transferHandler, OnCheckoutProgress = checkoutHandler});
});
}
示例2: CompileProject
//.........这里部分代码省略.........
}
if (doWork)
{
var objDirectory = project.GetObjectDirectory(superProject);
if (!Directory.Exists(objDirectory))
{
Directory.CreateDirectory(objDirectory);
}
var compileResults = new CompileResult();
compileResults.Project = project;
results.Add(compileResults);
var tasks = new List<Task>();
var numLocalTasks = 0;
var sourceFiles = project.SourceFiles.ToList();
foreach (var file in sourceFiles)
{
if (terminateBuild)
{
break;
}
if (SupportsFile(file))
{
var outputName = Path.GetFileNameWithoutExtension(file.Location) + ".o";
var dependencyFile = Path.Combine(objDirectory, Path.GetFileNameWithoutExtension(file.Location) + ".d");
var objectFile = Path.Combine(objDirectory, outputName);
var dependencyChanged = false;
if (System.IO.File.Exists(dependencyFile))
{
var dependencies = new List<string>();
dependencies.AddRange(ProjectExtensions.GetDependencies(dependencyFile));
foreach (var dependency in dependencies)
{
if (!System.IO.File.Exists(dependency) || System.IO.File.GetLastWriteTime(dependency) > System.IO.File.GetLastWriteTime(objectFile))
{
dependencyChanged = true;
break;
}
}
}
if (dependencyChanged || !System.IO.File.Exists(objectFile))
{
while (numTasks >= Jobs)
{
Thread.Yield();
}
lock (resultLock)
{
numLocalTasks++;
numTasks++;
console.OverWrite(string.Format("[CC {0}/{1}] [{2}] {3}", ++buildCount, fileCount, project.Name,
Path.GetFileName(file.Location)));
}
new Thread(() =>
{
var compileResult = Compile(console, superProject, project, file, objectFile);
lock (resultLock)
{
if (compileResults.ExitCode == 0 && compileResult.ExitCode != 0)
{
terminateBuild = true;
compileResults.ExitCode = compileResult.ExitCode;
}
else
{
compileResults.ObjectLocations.Add(objectFile);
compileResults.NumberOfObjectsCompiled++;
}
numTasks--;
numLocalTasks--;
}
}).Start();
}
else
{
buildCount++;
compileResults.ObjectLocations.Add(objectFile);
}
}
}
}
}
}
}
示例3: Link
private LinkResult Link(IConsole console, IStandardProject superProject, CompileResult compileResult,
CompileResult linkResults, string label = "")
{
var binDirectory = compileResult.Project.GetBinDirectory(superProject);
if (!Directory.Exists(binDirectory))
{
Directory.CreateDirectory(binDirectory);
}
var outputLocation = binDirectory;
var executable = Path.Combine(outputLocation, compileResult.Project.Name);
if (!string.IsNullOrEmpty(label))
{
executable += string.Format("-{0}", label);
}
if (compileResult.Project.Type == ProjectType.StaticLibrary)
{
executable = Path.Combine(outputLocation, "lib" + compileResult.Project.Name);
executable += StaticLibraryExtension;
}
else
{
executable += ExecutableExtension;
}
if (!Directory.Exists(outputLocation))
{
Directory.CreateDirectory(outputLocation);
}
var link = false;
foreach (var objectFile in compileResult.ObjectLocations)
{
if (System.IO.File.GetLastWriteTime(objectFile) > System.IO.File.GetLastWriteTime(executable))
{
link = true;
break;
}
}
if (!link)
{
foreach (var library in compileResult.LibraryLocations)
{
if (System.IO.File.GetLastWriteTime(library) > System.IO.File.GetLastWriteTime(executable))
{
link = true;
break;
}
}
}
var linkResult = new LinkResult {Executable = executable};
if (link)
{
console.OverWrite(string.Format("[LL] [{0}]", compileResult.Project.Name));
linkResult = Link(console, superProject, compileResult.Project, compileResult, executable);
}
if (linkResult.ExitCode == 0)
{
if (compileResult.Project.Type == ProjectType.StaticLibrary)
{
if (compileResult.ObjectLocations.Count > 0) // This is where we have a libray with just headers.
{
linkResults.LibraryLocations.Add(executable);
}
}
else
{
superProject.Executable = superProject.Location.MakeRelativePath(linkResult.Executable).ToAvalonPath();
superProject.Save();
console.WriteLine();
Size(console, compileResult.Project, linkResult);
linkResults.ExecutableLocations.Add(executable);
}
}
else if (linkResults.ExitCode == 0)
{
linkResults.ExitCode = linkResult.ExitCode;
}
return linkResult;
}
示例4: CompileProject
//.........这里部分代码省略.........
}
if (doWork)
{
var objDirectory = project.GetObjectDirectory(superProject);
if (!Directory.Exists(objDirectory))
{
Directory.CreateDirectory(objDirectory);
}
var compileResults = new CompileResult();
compileResults.Project = project;
results.Add(compileResults);
var tasks = new List<Task>();
//var parallelResult = Parallel.ForEach(project.SourceFiles, (file) =>
int numLocalTasks = 0;
foreach (var file in project.SourceFiles)
{
if (terminateBuild)
{
break;
}
if (Path.GetExtension(file.Location) == ".c" || Path.GetExtension(file.Location) == ".cpp")
{
var outputName = Path.GetFileNameWithoutExtension(file.Location) + ".o";
var dependencyFile = Path.Combine(objDirectory, Path.GetFileNameWithoutExtension(file.Location) + ".d");
var objectFile = Path.Combine(objDirectory, outputName);
bool dependencyChanged = false;
if (File.Exists(dependencyFile))
{
List<string> dependencies = new List<string>();
//lock(resultLock)
{
dependencies.AddRange(ProjectExtensions.GetDependencies(dependencyFile));
foreach (var dependency in dependencies)
{
if (!File.Exists(dependency) || File.GetLastWriteTime(dependency) > File.GetLastWriteTime(objectFile))
{
dependencyChanged = true;
break;
}
}
}
}
if (dependencyChanged || !File.Exists(objectFile))
{
while (numTasks >= Jobs)
{
Thread.Yield();
}
lock (resultLock)
{
numLocalTasks++;
numTasks++;
console.OverWrite(string.Format("[CC {0}/{1}] [{2}] {3}", ++buildCount, fileCount, project.Name, Path.GetFileName(file.Location)));
}
new Thread(new ThreadStart(() =>
{
var compileResult = Compile(console, superProject, project, file, objectFile);
lock (resultLock)
{
if (compileResults.ExitCode == 0 && compileResult.ExitCode != 0)
{
terminateBuild = true;
compileResults.ExitCode = compileResult.ExitCode;
}
else
{
compileResults.ObjectLocations.Add(objectFile);
}
numTasks--;
numLocalTasks--;
}
})).Start();
}
else
{
buildCount++;
compileResults.ObjectLocations.Add(objectFile);
}
}
}
}
}
}
}
示例5: Link
private void Link(IConsole console, Project superProject, CompileResult compileResult, CompileResult linkResults)
{
var binDirectory = compileResult.Project.GetBinDirectory(superProject);
if (!Directory.Exists(binDirectory))
{
Directory.CreateDirectory(binDirectory);
}
string outputLocation = binDirectory;
string executable = Path.Combine(outputLocation, compileResult.Project.Name);
if (compileResult.Project.Type == ProjectType.StaticLibrary)
{
executable = Path.Combine(outputLocation, "lib" + compileResult.Project.Name);
executable += ".a";
}
else
{
executable += ".elf";
}
if (!Directory.Exists(outputLocation))
{
Directory.CreateDirectory(outputLocation);
}
console.OverWrite(string.Format("[LL] [{0}]", compileResult.Project.Name));
var linkResult = Link(console, superProject, compileResult.Project, compileResult, outputLocation);
if (linkResult.ExitCode == 0)
{
if (compileResult.Project.Type == ProjectType.StaticLibrary)
{
linkResults.LibraryLocations.Add(executable);
}
else
{
console.WriteLine();
Size(console, compileResult.Project, linkResult);
linkResults.ExecutableLocations.Add(executable);
}
}
else if(linkResults.ExitCode == 0)
{
linkResults.ExitCode = linkResult.ExitCode;
}
}