|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MSHelpCompiler;
using TenTec.Utils;
namespace SandCastleHelpBuilder
{
/// <summary>
/// Redirects HXComp output.
/// </summary>
internal class HxCompError : IHxCompError
{
#region Methods
/// <summary>
/// Creates a new instance of HxCompError
/// </summary>
public HxCompError(ProcessStepDelegate progressCallback)
{
ProgressCallback = progressCallback;
}
#endregion
#region Properties
/// <summary>
/// Indicates whether a fatal compilation error has occured.
/// </summary>
public bool IsFailed
{
get;
private set;
}
/// <summary>
/// If the compile failed this holds whatever error message was return by HxComp.
/// </summary>
public string ErrorMessage
{
get;
private set;
}
/// <summary>
/// The delegate which is used to report progress.
/// </summary>
public ProcessStepDelegate ProgressCallback
{
get;
private set;
}
#endregion
#region IHxCompError Interface
HxCompStatus IHxCompError.QueryStatus()
{
//_compileFailed is only ever true if we get a fatal error message in report error
if (IsFailed)
return HxCompStatus.HxCompStatus_Cancel;
else
return HxCompStatus.HxCompStatus_Continue;
}
void IHxCompError.ReportError(String taskItemString, String fileName, Int32 lineNum, Int32 charNum, HxCompErrorSeverity severity, String descriptionString)
{
StringBuilder myMessage = new StringBuilder("HxComp error\n");
myMessage.AppendFormat("\tTaskItemString={0}\n", taskItemString);
myMessage.AppendFormat("\tFilename={0}\n", fileName);
myMessage.AppendFormat("\tLineNum={0}\n", lineNum);
myMessage.AppendFormat("\tCharNum={0}\n", charNum);
myMessage.AppendFormat("\tSeverity={0}\n", severity);
myMessage.AppendFormat("\tDescriptionString={0}\n", descriptionString);
if (ProgressCallback != null)
ProgressCallback(myMessage.ToString(), true);
if (severity == HxCompErrorSeverity.HxCompErrorSeverity_Fatal)
{
IsFailed = true;
ErrorMessage = descriptionString;
}
}
void IHxCompError.ReportMessage(HxCompErrorSeverity severity, String descriptionString)
{
if (severity == HxCompErrorSeverity.HxCompErrorSeverity_Fatal)
{
string myMessage = string.Format("{0}: {1}", severity, descriptionString);
if (ProgressCallback != null)
ProgressCallback(myMessage.ToString(), true);
IsFailed = true;
ErrorMessage = descriptionString;
}
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.