コード例 #1
0
        /// <summary>
        /// Defines a transformation for <see cref="SingleFileSource"/> which copies the file to the destination
        /// and renames the file in the process.
        /// </summary>
        /// <param name="sourceId">ID of the <see cref="SingleFileSource"/>.</param>
        /// <param name="destinationFileName">The destination directory and file name (local path).</param>
        /// <returns>This same instance of the <see cref="CopyProcessor"/>.</returns>
        public CopyProcessor AddSingleFileTransformation(string sourceId, LocalPath destinationFileName)
        {
            CopyProcessorTransformation transformation = new CopyProcessorTransformation(sourceId, destinationFileName, CopyProcessorTransformationOptions.SingleFile);

            _transformations.Add(sourceId, transformation);
            return(this);
        }
コード例 #2
0
        private bool TryToTransformSingleFileSource(SingleFileSource source, FilesList filesList)
        {
            if (!_transformations.ContainsKey(source.Id))
            {
                return(false);
            }

            CopyProcessorTransformation transformation = _transformations[source.Id];

            if ((transformation.Options & CopyProcessorTransformationOptions.SingleFile) == 0)
            {
                return(false);
            }

            LocalPath destinationPath = transformation.DestinationPath;

            PackagedFileInfo sourceFile              = source.ListFiles().ToList().First();
            FullPath         destinationFullPath     = _destinationRootDir.CombineWith(destinationPath);
            FileFullPath     destinationFileFullPath = destinationFullPath.ToFileFullPath();

            filesList.AddFile(new PackagedFileInfo(destinationFileFullPath));
            _copier.Copy(sourceFile.FileFullPath, destinationFileFullPath);

            return(true);
        }
コード例 #3
0
        public CopyProcessor AddTransformationWithDirFlattening(string sourceId, LocalPath destinationDir)
        {
            CopyProcessorTransformation transformation = new CopyProcessorTransformation(
                sourceId, destinationDir, CopyProcessorTransformationOptions.FlattenDirStructure);

            _transformations.Add(sourceId, transformation);
            return(this);
        }
コード例 #4
0
        public CopyProcessor AddTransformation(string sourceId, LocalPath destinationDir)
        {
            CopyProcessorTransformation transformation = new CopyProcessorTransformation(
                sourceId, destinationDir, CopyProcessorTransformationOptions.None);

            _transformations.Add(sourceId, transformation);
            return(this);
        }
コード例 #5
0
        private void TransformSource(IFilesSource filesSource, FilesList filesList)
        {
            CopyProcessorTransformation transformation = FindTransformationForSource(filesSource.Id);
            bool flattenDirs = (transformation.Options & CopyProcessorTransformationOptions.FlattenDirStructure) != 0;

            LocalPath destinationPath = transformation.DestinationPath;

            foreach (PackagedFileInfo sourceFile in filesSource.ListFiles())
            {
                if (!LoggingHelper.LogIfFilteredOut(sourceFile.FileFullPath.ToString(), _filter, _taskContext, _logFiles))
                {
                    continue;
                }

                FullPath destinationFullPath = _destinationRootDir.CombineWith(destinationPath);

                if (sourceFile.LocalPath != null)
                {
                    LocalPath destLocalPath = sourceFile.LocalPath;
                    if (flattenDirs)
                    {
                        destLocalPath = destLocalPath.Flatten;
                    }

                    destinationFullPath = destinationFullPath.CombineWith(destLocalPath);
                }
                else
                {
                    destinationFullPath =
                        destinationFullPath.CombineWith(new LocalPath(sourceFile.FileFullPath.FileName));
                }

                string destFile = destinationFullPath.FileName;
                if (_fileTransformations.ContainsKey(destFile))
                {
                    destinationFullPath = destinationFullPath.ParentPath.CombineWith(
                        _fileTransformations[destFile]);
                }

                FileFullPath destinationFileFullPath = destinationFullPath.ToFileFullPath();
                filesList.AddFile(new PackagedFileInfo(destinationFileFullPath));

                _copier.Copy(sourceFile.FileFullPath, destinationFileFullPath);
            }
        }