using System;
using System.Collections.Generic;
using System.Text;
using DaveSexton.DocProject;
using DaveSexton.DocProject.Engine;
namespace DocSite {
///
/// Hooks into the DocProject build process for the project in which it's defined.
///
///
///
/// This class must be registered with the DocSite in the Active Projects
/// tools options page in order for DocProject to instantiate it during a help build.
///
///
/// The add-in will create an instance of this class in its own AppDomain instead
/// of Visual Studio's default AppDomain. Therefore, it's important to use the
/// method overloads to marshal calls back to the
/// UI thread when using Visual Studio automation. The automation methods inherited from
/// , such as
/// and
/// , marshal calls to Visual Studio's
/// AppDomain automatically.
///
///
/// To cancel the build at any time call the
/// method. The build process will end after the current step is executed,
/// unless the step is being executed in the background. In that case, it may
/// end immediately.
///
///
/// Note: Do not cache instances of the class and do
/// not invoke its members asynchronously. is not
/// thread-safe and is recreated each time the project is built.
///
///
public class BuildProcess : BuildProcessComponent {
DateTime buildStart, stepStart;
///
/// Called by the add-in before the project's help build actually starts.
///
/// Provides information about the build process.
public override void BuildStarting(BuildContext context) {
// Uncomment the following line to break into the debugger:
// System.Diagnostics.Debugger.Break();
buildStart = DateTime.Now;
}
///
/// Called by the add-in immediately before a is executed
/// during a help build.
///
/// implementation to be executed.
/// Provides information about the build process.
/// true indicates that the process should continue, otherwise,
/// false indicates that the process should skip this step.
public override bool BeforeExecuteStep(IBuildStep step, BuildContext context) {
stepStart = DateTime.Now;
return true;
}
///
/// Called by the add-in immediately after a has been
/// executed during a help build.
///
/// implementation to be executed.
/// Provides information about the build process.
public override void AfterExecuteStep(IBuildStep step, BuildContext context) {
TraceLine();
TraceLine("Step {0} Time Elapsed: {1}", context.CurrentStepIndex + 1, DateTime.Now - stepStart);
}
///
/// Called by the add-in after the project's help build has finished.
///
///
/// The method has no affect at this
/// point in the build process. This method is the final step before the
/// add-in displays the build statistics.
///
/// This method is always invoked if is invoked,
/// regardless of whether an exception is thrown in any of the other methods,
/// has been called, or an exeception has
/// been thrown by the build engine.
///
///
/// To determine whether a help build failed or succeeded, examine the value of the
/// property.
///
///
/// Provides information about the build process.
public override void BuildCompleted(BuildContext context) {
TraceLine();
TraceLine("Total Time Elapsed: {0}", DateTime.Now - buildStart);
}
}
}