Execute() public method

Make transformation of file SourceFilePath with transform file TransformFile to destinationFilePath.
public Execute ( string destinationFilePath ) : void
destinationFilePath string File path of destination transformation.
return void
コード例 #1
0
ファイル: DirectoryProcessor.cs プロジェクト: benjamine/CFT
        private bool PerformTransform(string sourceFile, string transformFile, string destinationFile)
        {
            if (!File.Exists(sourceFile))
                throw new FileNotFoundException("The source file was not found", sourceFile);

            var destinationDirectory = Path.GetDirectoryName(destinationFile);

            if (!Directory.Exists(destinationDirectory))
                Directory.CreateDirectory(destinationDirectory);

            // If a transformation file does not exist, just copy sourceFile as the destinationFile
            if (!File.Exists(transformFile))
            {
                var sourceContent = File.ReadAllText(sourceFile);
                File.WriteAllText(destinationFile, sourceContent);
                return false;
            }

            var transformTask = new TransformationTask(sourceFile, transformFile);
            transformTask.Execute(destinationFile);

            return true;
        }