本文整理汇总了C#中IProgressMonitor.BeginTask方法的典型用法代码示例。如果您正苦于以下问题:C# IProgressMonitor.BeginTask方法的具体用法?C# IProgressMonitor.BeginTask怎么用?C# IProgressMonitor.BeginTask使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IProgressMonitor
的用法示例。
在下文中一共展示了IProgressMonitor.BeginTask方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Build
/// <summary>
/// Builds the specified solution item.
/// </summary>
/// <param name = "monitor">The monitor.</param>
/// <param name = "item">The item.</param>
/// <param name = "configuration">The configuration.</param>
/// <returns>The build result.</returns>
protected override BuildResult Build(IProgressMonitor monitor, SolutionEntityItem item, ConfigurationSelector configuration)
{
BuildResult result = new BuildResult ();
// Pre-build
monitor.BeginTask (GettextCatalog.GetString ("Pre-Building..."), 1);
this.PreBuild (result, monitor, item, configuration);
monitor.EndTask();
if (result.ErrorCount > 0) {
return result;
}
// Build
monitor.BeginTask (GettextCatalog.GetString ("Building"), 1);
result.Append (base.Build (monitor, item, configuration));
monitor.EndTask();
if (result.ErrorCount > 0) {
return result;
}
// Post-build
monitor.BeginTask (GettextCatalog.GetString ("Post-Building..."), 1);
this.PostBuild (result, monitor, item, configuration);
monitor.EndTask();
return result;
}
示例2: SafeCopy
private void SafeCopy(IPluginDescriptor plugin, IProgressMonitor progressMonitor)
{
using (progressMonitor.BeginTask(string.Format("Copying {0} plugin", plugin.PluginId), plugin.FilePaths.Count))
{
var sourceFolder = Path.Combine(sourcePluginFolder, plugin.RecommendedInstallationPath);
var targetFolder = Path.Combine(targetPluginFolder, plugin.RecommendedInstallationPath);
foreach (var file in plugin.FilePaths)
{
var sourceFileInfo = new FileInfo(Path.Combine(sourceFolder, file));
var destination = new FileInfo(Path.Combine(targetFolder, file));
try
{
if (fileSystem.DirectoryExists(destination.DirectoryName) == false)
fileSystem.CreateDirectory(destination.DirectoryName);
fileSystem.CopyFile(sourceFileInfo.FullName, destination.FullName, true);
}
catch (Exception ex)
{
exceptionPolicy.Report(string.Format("Error copying file: {0}", file), ex);
}
}
}
}
示例3: LoadSolutionItem
protected override SolutionEntityItem LoadSolutionItem (IProgressMonitor monitor, string fileName)
{
SolutionEntityItem entry = base.LoadSolutionItem (monitor, fileName);
if (entry == null)
return null;
Project project = entry as Project;
if (project == null)
return entry;
//Project
MakefileData data = entry.ExtendedProperties ["MonoDevelop.Autotools.MakefileInfo"] as MakefileData;
if (data == null)
return entry;
monitor.BeginTask (GettextCatalog.GetString ("Updating project from Makefile"), 1);
try {
data.OwnerProject = project;
if (data.SupportsIntegration)
data.UpdateProject (monitor, false);
monitor.Step (1);
} catch (Exception e) {
monitor.ReportError (GettextCatalog.GetString (
"Error loading Makefile for project {0}", project.Name), e);
} finally {
monitor.EndTask ();
}
entry.SetNeedsBuilding (false);
return entry;
}
示例4: RunImpl
protected internal override TestResult RunImpl(ITestCommand rootTestCommand, Model.Tree.TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor)
{
using (progressMonitor.BeginTask("Running tests.", rootTestCommand.TestCount))
{
// Note: We do not check options.SkipTestExecution here because we want to build up
// the tree of data-driven test steps. So we actually check it later on in the
// PatternTestExecutor. This is different from framework adapters
// at this time (because they do not generally support dynamically generated data-driven tests).
Sandbox sandbox = new Sandbox();
EventHandler canceledHandler = delegate { sandbox.Abort(TestOutcome.Canceled, "The user canceled the test run."); };
try
{
progressMonitor.Canceled += canceledHandler;
TestAssemblyExecutionParameters.Reset();
PatternTestExecutor executor = new PatternTestExecutor(options, progressMonitor, formatter, converter, environmentManager);
// Inlined to minimize stack depth.
var action = executor.CreateActionToRunTest(rootTestCommand, parentTestStep, sandbox, null);
action.Run();
return action.Result;
}
finally
{
progressMonitor.Canceled -= canceledHandler;
sandbox.Dispose();
}
}
}
示例5: Execute
/// <inheritdoc />
protected override void Execute(UnmanagedTestRepository repository, IProgressMonitor progressMonitor)
{
using (progressMonitor.BeginTask("Exploring " + repository.FileName, 1))
{
BuildTestModel(repository, progressMonitor);
}
}
示例6: ApplyPendingSettingsChanges
/// <inheritdoc />
public override void ApplyPendingSettingsChanges(IElevationContext elevationContext, IProgressMonitor progressMonitor)
{
using (progressMonitor.BeginTask("Saving preferences.", 1))
{
var preferencePanes = new List<PreferencePane>(GetPreferencePanes());
if (preferencePanes.Count == 0)
return;
double workPerPreferencePane = 1.0 / preferencePanes.Count;
foreach (PreferencePane preferencePane in preferencePanes)
{
if (progressMonitor.IsCanceled)
return;
if (preferencePane.PendingSettingsChanges)
{
preferencePane.ApplyPendingSettingsChanges(
preferencePane.RequiresElevation ? elevationContext : null,
progressMonitor.CreateSubProgressMonitor(workPerPreferencePane));
}
else
{
progressMonitor.Worked(workPerPreferencePane);
}
}
}
}
示例7: SaveReportAs
public string SaveReportAs(Report report, string fileName, string format, IProgressMonitor progressMonitor)
{
var file = string.Empty;
using (progressMonitor.BeginTask("Generating report", 100))
{
var folderName = Path.GetDirectoryName(fileName);
var reportContainer = new FileSystemReportContainer(folderName,
Path.GetFileNameWithoutExtension(fileName));
var reportWriter = reportManager.CreateReportWriter(report, reportContainer);
if (progressMonitor.IsCanceled)
throw new OperationCanceledException();
// Delete the report if it already exists
reportContainer.DeleteReport();
if (progressMonitor.IsCanceled)
throw new OperationCanceledException();
progressMonitor.Worked(10);
// Format the report
var reportFormatterOptions = new ReportFormatterOptions();
using (var subProgressMonitor = progressMonitor.CreateSubProgressMonitor(90))
reportManager.Format(reportWriter, format, reportFormatterOptions, subProgressMonitor);
if (progressMonitor.IsCanceled)
throw new OperationCanceledException();
if (reportWriter.ReportDocumentPaths.Count > 0)
file = Path.Combine(folderName, reportWriter.ReportDocumentPaths[0]);
}
return file;
}
示例8: WriteFile
public void WriteFile (string file, object obj, MSBuildFileFormat format, bool saveProjects, IProgressMonitor monitor)
{
Solution sol = (Solution) obj;
string tmpfilename = String.Empty;
try {
monitor.BeginTask (GettextCatalog.GetString ("Saving solution: {0}", file), 1);
try {
if (File.Exists (file))
tmpfilename = Path.GetTempFileName ();
} catch (IOException) {
}
string baseDir = Path.GetDirectoryName (file);
if (tmpfilename == String.Empty) {
WriteFileInternal (file, sol, baseDir, format, saveProjects, monitor);
} else {
WriteFileInternal (tmpfilename, sol, baseDir, format, saveProjects, monitor);
FileService.SystemRename (tmpfilename, file);
}
} catch (Exception ex) {
monitor.ReportError (GettextCatalog.GetString ("Could not save solution: {0}", file), ex);
LoggingService.LogError (GettextCatalog.GetString ("Could not save solution: {0}", file), ex);
if (!String.IsNullOrEmpty (tmpfilename) && File.Exists (tmpfilename))
File.Delete (tmpfilename);
throw;
} finally {
monitor.EndTask ();
}
}
示例9: Execute
protected override void Execute(IntPtr bridgeFunc, IProgressMonitor subMonitor)
{
using (subMonitor.BeginTask("Exploring " + File.Name, 100))
{
BoostTestExploreDelegate bridge =
(BoostTestExploreDelegate)Marshal.GetDelegateForFunctionPointer(
bridgeFunc,
typeof(BoostTestExploreDelegate)
);
VisitorDelegate visitTestCase = new VisitorDelegate(VisitTestCase);
VisitorDelegate beginVisitTestSuite = new VisitorDelegate(BeginVisitTestSuite);
VisitorDelegate endVisitTestSuite = new VisitorDelegate(EndVisitTestSuite);
ErrorReporterDelegate errorReporter =
new ErrorReporterDelegate((text) => Logger.Log(LogSeverity.Error, text));
bridge(
File.FullName,
visitTestCase,
beginVisitTestSuite,
endVisitTestSuite,
errorReporter
);
TestModelSerializer.PublishTestModel(TestModel, MessageSink);
}
}
示例10: Install
public override void Install(IProgressMonitor progressMonitor)
{
using (progressMonitor.BeginTask("Installing TestDriven.Net Runner", testFrameworkManager.TestFrameworkHandles.Count + 2))
{
// Remove old registrations.
RemoveExistingRegistryKeys(progressMonitor);
progressMonitor.Worked(1);
// Register Icarus
string icarusPath = FindIcarusPath();
if (icarusPath != null)
InstallRegistryKeysForIcarus(icarusPath, progressMonitor);
progressMonitor.Worked(1);
// Register frameworks
foreach (ComponentHandle<ITestFramework, TestFrameworkTraits> testFrameworkHandle in testFrameworkManager.TestFrameworkHandles)
{
TestFrameworkTraits testFrameworkTraits = testFrameworkHandle.GetTraits();
TDNetRunnerInstallationMode installationMode = preferenceManager.GetInstallationModeForFramework(testFrameworkHandle.Id);
if (installationMode != TDNetRunnerInstallationMode.Disabled)
{
int priority = installationMode == TDNetRunnerInstallationMode.Default ? 25 : 5;
foreach (AssemblySignature frameworkAssembly in testFrameworkTraits.FrameworkAssemblies)
{
InstallRegistryKeysForFramework(testFrameworkTraits.Name, frameworkAssembly, priority,
progressMonitor);
}
}
progressMonitor.Worked(1);
}
}
}
示例11: RunImpl
protected internal override TestResult RunImpl(ITestCommand rootTestCommand, TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor)
{
using (progressMonitor.BeginTask("Running tests.", rootTestCommand.TestCount))
{
return RunTest(rootTestCommand, parentTestStep, options, progressMonitor);
}
}
示例12: RunImpl
/// <inheritdoc />
protected override TestResult RunImpl(ITestCommand rootTestCommand, TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor)
{
ThrowIfDisposed();
using (progressMonitor.BeginTask(Resources.MbUnit2TestController_RunningMbUnitTests, 1))
{
if (progressMonitor.IsCanceled)
return new TestResult(TestOutcome.Canceled);
if (options.SkipTestExecution)
{
return SkipAll(rootTestCommand, parentTestStep);
}
else
{
IList<ITestCommand> testCommands = rootTestCommand.GetAllCommands();
using (InstrumentedFixtureRunner fixtureRunner = new InstrumentedFixtureRunner(fixtureExplorer,
testCommands, progressMonitor, parentTestStep))
{
return fixtureRunner.Run();
}
}
}
}
示例13: CompileXibFiles
public static BuildResult CompileXibFiles (IProgressMonitor monitor, IEnumerable<ProjectFile> files,
FilePath outputRoot)
{
var result = new BuildResult ();
var ibfiles = GetIBFilePairs (files, outputRoot).Where (NeedsBuilding).ToList ();
if (ibfiles.Count > 0) {
monitor.BeginTask (GettextCatalog.GetString ("Compiling interface definitions"), 0);
foreach (var file in ibfiles) {
file.EnsureOutputDirectory ();
var args = new ProcessArgumentBuilder ();
args.AddQuoted (file.Input);
args.Add ("--compile");
args.AddQuoted (file.Output);
var psi = new ProcessStartInfo ("ibtool", args.ToString ());
monitor.Log.WriteLine (psi.FileName + " " + psi.Arguments);
psi.WorkingDirectory = outputRoot;
string errorOutput;
int code;
try {
code = ExecuteCommand (monitor, psi, out errorOutput);
} catch (System.ComponentModel.Win32Exception ex) {
LoggingService.LogError ("Error running ibtool", ex);
result.AddError (null, 0, 0, null, "ibtool not found. Please ensure the Apple SDK is installed.");
return result;
}
if (code != 0) {
//FIXME: parse the plist that ibtool returns
result.AddError (null, 0, 0, null, "ibtool returned error code " + code);
}
}
monitor.EndTask ();
}
return result;
}
示例14: RunImpl
protected override TestResult RunImpl( ITestCommand rootTestCommand, TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor )
{
using(progressMonitor.BeginTask( "Verifying Specifications", rootTestCommand.TestCount ) )
{
if( options.SkipTestExecution )
{
return SkipAll( rootTestCommand, parentTestStep );
}
else
{
ITestContext rootContext = rootTestCommand.StartPrimaryChildStep( parentTestStep );
TestStep rootStep = rootContext.TestStep;
TestOutcome outcome = TestOutcome.Passed;
foreach( ITestCommand command in rootTestCommand.Children )
{
NSpecAssemblyTest assemblyTest = command.Test as NSpecAssemblyTest;
if( assemblyTest == null )
continue;
var assemblyResult = this.RunAssembly( command, rootStep );
outcome = outcome.CombineWith( assemblyResult.Outcome );
}
return rootContext.FinishStep( outcome, null );
}
}
}
示例15: Execute
public void Execute(IProgressMonitor progressMonitor)
{
if (string.IsNullOrEmpty(FileName))
throw new Exception("No filename provided to delete.");
using (progressMonitor.BeginTask("Deleting report", 100))
fileSystem.DeleteFile(FileName);
}