public void Execute(string destinationFilePath)
{
if (string.IsNullOrWhiteSpace(destinationFilePath))
{
throw new ArgumentException("Destination file can't be empty.", "destinationFilePath");
}
if (string.IsNullOrWhiteSpace(SourceFilePath) || !File.Exists(SourceFilePath))
{
throw new FileNotFoundException("Can't find source file.", SourceFilePath);
}
if (string.IsNullOrWhiteSpace(TransformFile) || !File.Exists(TransformFile))
{
throw new FileNotFoundException("Can't find transform file.", TransformFile);
}
string transformFileContents = File.ReadAllText(TransformFile);
var document = new XmlDocument();
try
{
document.Load(SourceFilePath);
}
catch (Exception ex)
{
throw new Exception(string.Format("Error loading source '{0}': {1}", SourceFilePath, ex.Message), ex);
}
var transformation = new XmlTransformation(transformFileContents, false, _transformationLogger);
try
{
bool result = transformation.Apply(document);
}
catch (Exception ex)
{
throw new Exception(string.Format("Error generating '{0}': {1}", destinationFilePath, ex.Message), ex);
}
document.Save(destinationFilePath);
}