コード例 #1
0
        private ICompositeFilesSource ProcessPrivate(
            ICompositeFilesSource compositeFilesSource,
            bool isRoot)
        {
            CompositeFilesSource transformedCompositeSource = isRoot
                ? new StandardPackageDef(compositeFilesSource.Id)
                : new CompositeFilesSource(compositeFilesSource.Id);

            foreach (IFilesSource filesSource in compositeFilesSource.ListChildSources())
            {
                if (filesSource is ICompositeFilesSource)
                {
                    throw new NotImplementedException("Child composites are currently not supported");
                }

                FilesList filesList = new FilesList(filesSource.Id);

                bool transformed = false;
                if (filesSource is SingleFileSource)
                {
                    transformed = TryToTransformSingleFileSource((SingleFileSource)filesSource, filesList);
                }

                if (!transformed)
                {
                    TransformSource(filesSource, filesList);
                }

                transformedCompositeSource.AddFilesSource(filesList);
            }

            return(transformedCompositeSource);
        }
コード例 #2
0
        private ICompositeFilesSource ProcessPrivate(
            ICompositeFilesSource compositeFilesSource,
            bool isRoot)
        {
            CompositeFilesSource transformedCompositeSource = isRoot
                                                                  ? new StandardPackageDef(compositeFilesSource.Id)
                                                                  : new CompositeFilesSource(compositeFilesSource.Id);

            foreach (IFilesSource filesSource in compositeFilesSource.ListChildSources())
            {
                if (filesSource is ICompositeFilesSource)
                {
                    throw new NotImplementedException("Child composites are currently not supported");
                }

                FilesList filesList = new FilesList(filesSource.Id);

                LocalPath destinationPath = FindDestinationPathForSource(filesSource.Id);

                foreach (PackagedFileInfo sourceFile in filesSource.ListFiles())
                {
                    if (false == LoggingHelper.LogIfFilteredOut(sourceFile.FullPath.ToString(), filter, logger))
                    {
                        continue;
                    }

                    FullPath destinationFileName = new FullPath(destinationRootDir);
                    destinationFileName = destinationFileName.CombineWith(destinationPath);

                    if (sourceFile.LocalPath != null)
                    {
                        destinationFileName = destinationFileName.CombineWith(sourceFile.LocalPath);
                    }
                    else
                    {
                        destinationFileName =
                            destinationFileName.CombineWith(new LocalPath(Path.GetFileName(
                                                                              sourceFile.FullPath.ToString())));
                    }

                    string destFile = Path.GetFileName(destinationFileName.ToString());
                    if (fileTransformations.ContainsKey(destFile))
                    {
                        destinationFileName = new FullPath(Path.Combine(
                                                               Path.GetDirectoryName(destinationFileName.ToString()),
                                                               fileTransformations[destFile]));
                    }

                    filesList.AddFile(new PackagedFileInfo(destinationFileName));

                    copier.Copy(sourceFile.FullPath.ToString(), destinationFileName.ToString());
                }

                transformedCompositeSource.AddFilesSource(filesList);
            }

            return(transformedCompositeSource);
        }