Example #1
0
        public FileSystemRepository(
            ITemplatePathResolver pathResolver,
            IFileSystem fileSystem,
            ITemplateCompiler compiler,
            ITemplateClassNameBuilder classNameBuilder,
            ITemplateCodeBuilder codeBuilder,
            ICodeDomProviderFactory codeDomProviderFactory,
            ICompiledTemplateFactory compiledTemplateFactory,
            IFileSystemRepositoryConfiguration configuration)
        {
            pathResolver.ThrowIfNull("pathResolver");
            fileSystem.ThrowIfNull("fileSystem");
            compiler.ThrowIfNull("compiler");
            classNameBuilder.ThrowIfNull("classNameBuilder");
            codeBuilder.ThrowIfNull("codeBuilder");
            codeDomProviderFactory.ThrowIfNull("codeDomProviderFactory");
            compiledTemplateFactory.ThrowIfNull("compiledTemplateFactory");
            configuration.ThrowIfNull("configuration");

            _pathResolver            = pathResolver;
            _fileSystem              = fileSystem;
            _compiler                = compiler;
            _classNameBuilder        = classNameBuilder;
            _codeBuilder             = codeBuilder;
            _codeDomProviderFactory  = codeDomProviderFactory;
            _compiledTemplateFactory = compiledTemplateFactory;
            _configuration           = configuration;
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Job"/> class.
        /// </summary>
        /// <param name="name">The name of the job.</param>
        /// <param name="sourceFileSystem">The source file system.</param>
        /// <param name="targetFileSystem">The target file system.</param>
        /// <param name="directoryA">The directory A.</param>
        /// <param name="directoryB">The directory B.</param>
        protected Job(string name, IFileSystem sourceFileSystem, IFileSystem targetFileSystem, IDirectoryInfo directoryA, IDirectoryInfo directoryB)
        {
            sourceFileSystem.ThrowIfNull(() => sourceFileSystem);
            targetFileSystem.ThrowIfNull(() => targetFileSystem);
            directoryA.ThrowIfNull(() => directoryA);
            directoryB.ThrowIfNull(() => directoryB);

            if (String.IsNullOrEmpty(name))
            {
                throw new ArgumentException("The name cannot be null or empty.", Reflector.GetMemberName(() => name));
            }

            this.SourceFileSystem = sourceFileSystem;
            this.TargetFileSystem = targetFileSystem;

            this.DirectoryA = directoryA;
            this.DirectoryB = directoryB;

            this.Name = name;

            this.proceededFilePaths    = new HashSet <string>();
            this.excludedPaths         = new HashSet <string>();
            this.deletedDirectoryPaths = new HashSet <string>();

            this.pauseHandle = new AutoResetEvent(false);
        }
Example #3
0
        public IEnumerable<AssetFile> ResolveAssetFiles(IFileSystem fileSystem)
        {
            fileSystem.ThrowIfNull("fileSystem");

            string path = fileSystem.AbsolutePath(_relativePath);

            yield return new AssetFile(path, _encoding);
        }
Example #4
0
        public IEnumerable <AssetFile> ResolveAssetFiles(IFileSystem fileSystem)
        {
            fileSystem.ThrowIfNull("fileSystem");

            string path = fileSystem.AbsolutePath(_relativePath);

            yield return(new AssetFile(path, _encoding));
        }
Example #5
0
        public FileSystemWatcher GetFileSystemWatcher(IFileSystem fileSystem)
        {
            fileSystem.ThrowIfNull("fileSystem");

            string path = fileSystem.AbsolutePath(_relativePath);

            return(new FileSystemWatcher(Path.GetDirectoryName(path), Path.GetFileName(path)));
        }
Example #6
0
        public FileSystemWatcher GetFileSystemWatcher(IFileSystem fileSystem)
        {
            fileSystem.ThrowIfNull("fileSystem");

            string path = fileSystem.AbsolutePath(_relativePath);

            return new FileSystemWatcher(Path.GetDirectoryName(path), Path.GetFileName(path));
        }
Example #7
0
        public IoOperations(IFileSystem fileSystem, string outputFolderPath, ILogger logger)
        {
            this.FileSystem = fileSystem.ThrowIfNull(nameof(fileSystem));
            this.OutputFolderPath = outputFolderPath;
            this.Logger = logger.ThrowIfNull(nameof(logger));

            this.WriteLog("outputFolderPath = " + outputFolderPath);
        }
Example #8
0
        public BundleContents GetContents(IFileSystem fileSystem, IEnumerable <IAssetTransformer> transformers)
        {
            fileSystem.ThrowIfNull("fileSystem");
            transformers.ThrowIfNull("transformers");

            AssetFile[] unorderedAssets = _assets.SelectMany(arg => arg.ResolveAssetFiles(fileSystem)).ToArray();

            return(GetContents(fileSystem, unorderedAssets, new DelimiterConcatenator(), transformers));
        }
Example #9
0
        /// <summary>
        /// Copies the specified file to the target directory.
        /// </summary>
        /// <param name="sourceFileSystem">The source file system.</param>
        /// <param name="sourceFile">The source file.</param>
        /// <param name="targetDirectory">The target directory.</param>
        /// <exception cref="AccessException">The source file or target directory could not be accessed.</exception>
        public void CopyFile(IFileSystem sourceFileSystem, IFileInfo sourceFile, IDirectoryInfo targetDirectory)
        {
            sourceFileSystem.ThrowIfNull(() => sourceFileSystem);
            sourceFile.ThrowIfNull(() => sourceFile);
            targetDirectory.ThrowIfNull(() => targetDirectory);

            if (!(targetDirectory is LocalDirectoryInfo))
            {
                throw new ArgumentException("The target directory must be of type LocalDirectoryInfo.", "targetDirectory");
            }

            try
            {
                using (Stream sourceStream = sourceFileSystem.OpenFileStream(sourceFile))
                {
                    string targetFilePath = this.CombinePath(targetDirectory.FullName, sourceFile.Name);

                    try
                    {
                        using (FileStream targetStream = File.Create(targetFilePath))
                        {
                            if (sourceFile.Length > 0)
                            {
                                var copyOperation = new StreamCopyOperation(sourceStream, targetStream, 256 * 1024, true);

                                copyOperation.CopyProgressChanged +=
                                    (sender, e) => this.FileCopyProgressChanged.RaiseSafe(this, e);

                                copyOperation.Execute();
                            }
                        }
                    }

                    catch (IOException)
                    {
                        File.Delete(targetFilePath);

                        throw;
                    }
                }
            }

            catch (UnauthorizedAccessException ex)
            {
                throw new AccessException("The file could not be accessed.", ex);
            }

            catch (SecurityException ex)
            {
                throw new AccessException("The file could not be accessed.", ex);
            }

            catch (IOException ex)
            {
                throw new AccessException("The file could not be accessed.", ex);
            }
        }
Example #10
0
        /// <summary>
        /// Copies the specified file to the target directory.
        /// </summary>
        /// <param name="sourceFileSystem">The source file system.</param>
        /// <param name="sourceFile">The source file.</param>
        /// <param name="targetDirectory">The target directory.</param>
        /// <exception cref="AccessException">The source file or target directory could not be accessed.</exception>
        public void CopyFile(IFileSystem sourceFileSystem, IFileInfo sourceFile, IDirectoryInfo targetDirectory)
        {
            sourceFileSystem.ThrowIfNull(() => sourceFileSystem);
            sourceFile.ThrowIfNull(() => sourceFile);
            targetDirectory.ThrowIfNull(() => targetDirectory);

            if (!(targetDirectory is LocalDirectoryInfo))
                throw new ArgumentException("The target directory must be of type LocalDirectoryInfo.", "targetDirectory");

            try
            {
                using (Stream sourceStream = sourceFileSystem.OpenFileStream(sourceFile))
                {
                    string targetFilePath = this.CombinePath(targetDirectory.FullName, sourceFile.Name);

                    try
                    {
                        using (FileStream targetStream = File.Create(targetFilePath))
                        {
                            if (sourceFile.Length > 0)
                            {
                                var copyOperation = new StreamCopyOperation(sourceStream, targetStream, 256 * 1024, true);

                                copyOperation.CopyProgressChanged +=
                                    (sender, e) => this.FileCopyProgressChanged.RaiseSafe(this, e);

                                copyOperation.Execute();
                            }
                        }
                    }

                    catch (IOException)
                    {
                        File.Delete(targetFilePath);

                        throw;
                    }
                }
            }

            catch (UnauthorizedAccessException ex)
            {
                throw new AccessException("The file could not be accessed.", ex);
            }

            catch (SecurityException ex)
            {
                throw new AccessException("The file could not be accessed.", ex);
            }

            catch (IOException ex)
            {
                throw new AccessException("The file could not be accessed.", ex);
            }
        }
Example #11
0
        public IEnumerable<AssetFile> ResolveAssetFiles(IFileSystem fileSystem)
        {
            fileSystem.ThrowIfNull("fileSystem");

            string directory = fileSystem.AbsolutePath(_relativeDirectory);
            string[] paths = fileSystem.GetDirectoryFiles(directory, _searchPattern, _searchOption);

            return paths
                .Where(arg => _filter == null || _filter.Filter(arg) == FilterResult.Include)
                .Select(arg => new AssetFile(arg, _encoding));
        }
Example #12
0
        public FileSystemWatcher GetFileSystemWatcher(IFileSystem fileSystem)
        {
            fileSystem.ThrowIfNull("fileSystem");

            string directory = fileSystem.AbsolutePath(_relativeDirectory);

            return(new FileSystemWatcher(directory, _searchPattern)
            {
                IncludeSubdirectories = _searchOption == SearchOption.AllDirectories
            });
        }
Example #13
0
        public FileSystemWatcher GetFileSystemWatcher(IFileSystem fileSystem)
        {
            fileSystem.ThrowIfNull("fileSystem");

            string directory = fileSystem.AbsolutePath(_relativeDirectory);

            return new FileSystemWatcher(directory, _searchPattern)
                {
                    IncludeSubdirectories = _searchOption == SearchOption.AllDirectories
                };
        }
Example #14
0
        public IEnumerable <AssetFile> ResolveAssetFiles(IFileSystem fileSystem)
        {
            fileSystem.ThrowIfNull("fileSystem");

            string directory = fileSystem.AbsolutePath(_relativeDirectory);

            string[] paths = fileSystem.GetDirectoryFiles(directory, _searchPattern, _searchOption);

            return(paths
                   .Where(arg => _filter == null || _filter.Filter(arg) == FilterResult.Include)
                   .Select(arg => new AssetFile(arg, _encoding)));
        }
Example #15
0
        public BundleWatcher(Bundle bundle, IFileSystem fileSystem, IEnumerable <IAssetTransformer> transformers)
        {
            bundle.ThrowIfNull("bundle");
            fileSystem.ThrowIfNull("fileSystem");
            transformers.ThrowIfNull("transformers");

            _bundle              = bundle;
            _transformers        = transformers.ToArray();
            _fileSystem          = fileSystem;
            _watchTimer.Elapsed += WatchTimerElapsed;
            RefreshContents();
            WatchForChanges();
        }
Example #16
0
        public DefaultBundleDependencyContainer(IHttpRuntime httpRuntime, IFileSystem fileSystem)
        {
            httpRuntime.ThrowIfNull("httpRuntime");
            fileSystem.ThrowIfNull("fileSystem");

            _container = new Dictionary <Type, object>
            {
                { typeof(IHttpRuntime), httpRuntime },
                { typeof(IFileSystem), fileSystem },
                { typeof(IGuidFactory), new GuidFactory() },
                { typeof(ISystemClock), new SystemClock() }
            };
        }
Example #17
0
        public BundleContents GetContents(IFileSystem fileSystem, IComparer <AssetFile> assetOrder, IAssetConcatenator concatenator, IEnumerable <IAssetTransformer> transformers)
        {
            fileSystem.ThrowIfNull("fileSystem");
            assetOrder.ThrowIfNull("assetOrder");
            concatenator.ThrowIfNull("concatenator");
            transformers.ThrowIfNull("transformers");

            AssetFile[] orderedAssets = _assets
                                        .SelectMany(arg => arg.ResolveAssetFiles(fileSystem))
                                        .OrderBy(arg => arg, assetOrder)
                                        .ToArray();

            return(GetContents(fileSystem, orderedAssets, concatenator, transformers));
        }
        public BundleWatcher(Bundle bundle, IFileSystem fileSystem, IComparer<AssetFile> assetOrder, IEnumerable<IAssetTransformer> transformers)
        {
            bundle.ThrowIfNull("bundle");
            fileSystem.ThrowIfNull("fileSystem");
            assetOrder.ThrowIfNull("assetOrder");
            transformers.ThrowIfNull("transformers");

            _bundle = bundle;
            _assetOrder = assetOrder;
            _transformers = transformers.ToArray();
            _fileSystem = fileSystem;
            _watchTimer.Elapsed += WatchTimerElapsed;
            RefreshContents();
            WatchForChanges();
        }
        public BundleWatcher(Bundle bundle, IFileSystem fileSystem, IAssetConcatenator concatenator, IEnumerable<IAssetTransformer> transformers)
        {
            bundle.ThrowIfNull("bundle");
            fileSystem.ThrowIfNull("fileSystem");
            concatenator.ThrowIfNull("concatenator");
            transformers.ThrowIfNull("transformers");

            _bundle = bundle;
            _concatenator = concatenator;
            _transformers = transformers.ToArray();
            _fileSystem = fileSystem;
            _watchTimer.Elapsed += WatchTimerElapsed;
            RefreshContents();
            WatchForChanges();
        }
Example #20
0
        public BundleWatcher(Bundle bundle, IFileSystem fileSystem, IComparer <AssetFile> assetOrder, IAssetConcatenator concatenator, IEnumerable <IAssetTransformer> transformers)
        {
            bundle.ThrowIfNull("bundle");
            fileSystem.ThrowIfNull("fileSystem");
            assetOrder.ThrowIfNull("assetOrder");
            concatenator.ThrowIfNull("concatenator");
            transformers.ThrowIfNull("transformers");

            _bundle              = bundle;
            _assetOrder          = assetOrder;
            _concatenator        = concatenator;
            _transformers        = transformers.ToArray();
            _fileSystem          = fileSystem;
            _watchTimer.Elapsed += WatchTimerElapsed;
            RefreshContents();
            WatchForChanges();
        }
Example #21
0
        /// <summary>
        /// Copies the specified file to the target directory.
        /// </summary>
        /// <param name="sourceFileSystem">The source file system.</param>
        /// <param name="sourceFile">The source file.</param>
        /// <param name="targetDirectory">The target directory.</param>
        /// <exception cref="AccessException">The source file or target directory could not be accessed.</exception>
        /// /// <exception cref="ArgumentException">The target directory is not of type <see cref="FlagFtp.FtpDirectoryInfo"/>.</exception>
        public void CopyFile(IFileSystem sourceFileSystem, IFileInfo sourceFile, IDirectoryInfo targetDirectory)
        {
            sourceFileSystem.ThrowIfNull(() => sourceFileSystem);
            sourceFile.ThrowIfNull(() => sourceFile);
            targetDirectory.ThrowIfNull(() => targetDirectory);

            if (!(targetDirectory is FtpDirectoryInfo))
            {
                throw new ArgumentException("The target directory must be of type FtpDirectoryInfo.", "targetDirectory");
            }

            Uri targetFilePath = new Uri(this.CombinePath(targetDirectory.FullName, sourceFile.Name));

            try
            {
                using (Stream sourceStream = sourceFileSystem.OpenFileStream(sourceFile))
                {
                    using (Stream targetStream = this.client.OpenWrite(targetFilePath))
                    {
                        if (sourceFile.Length > 0)
                        {
                            var copyOperation = new StreamCopyOperation(sourceStream, targetStream, 8 * 1024, true);

                            copyOperation.CopyProgressChanged +=
                                (sender, e) => this.FileCopyProgressChanged.RaiseSafe(this, e);

                            copyOperation.Execute();
                        }
                    }
                }
            }

            catch (WebException ex)
            {
                switch (ex.Status)
                {
                case WebExceptionStatus.ConnectFailure:
                case WebExceptionStatus.ProxyNameResolutionFailure:
                    throw new FileSystemUnavailableException("The FTP server is currently unavailable.", ex);
                }

                throw new AccessException("The file could not be accessed", ex);
            }
        }
Example #22
0
        /// <summary>
        /// Copies the specified file to the target directory.
        /// </summary>
        /// <param name="sourceFileSystem">The source file system.</param>
        /// <param name="sourceFile">The source file.</param>
        /// <param name="targetDirectory">The target directory.</param>
        /// <exception cref="AccessException">The source file or target directory could not be accessed.</exception>
        /// /// <exception cref="ArgumentException">The target directory is not of type <see cref="FlagFtp.FtpDirectoryInfo"/>.</exception>
        public void CopyFile(IFileSystem sourceFileSystem, IFileInfo sourceFile, IDirectoryInfo targetDirectory)
        {
            sourceFileSystem.ThrowIfNull(() => sourceFileSystem);
            sourceFile.ThrowIfNull(() => sourceFile);
            targetDirectory.ThrowIfNull(() => targetDirectory);

            if (!(targetDirectory is FtpDirectoryInfo))
                throw new ArgumentException("The target directory must be of type FtpDirectoryInfo.", "targetDirectory");

            Uri targetFilePath = new Uri(this.CombinePath(targetDirectory.FullName, sourceFile.Name));

            try
            {
                using (Stream sourceStream = sourceFileSystem.OpenFileStream(sourceFile))
                {
                    using (Stream targetStream = this.client.OpenWrite(targetFilePath))
                    {
                        if (sourceFile.Length > 0)
                        {
                            var copyOperation = new StreamCopyOperation(sourceStream, targetStream, 8 * 1024, true);

                            copyOperation.CopyProgressChanged +=
                                (sender, e) => this.FileCopyProgressChanged.RaiseSafe(this, e);

                            copyOperation.Execute();
                        }
                    }
                }
            }

            catch (WebException ex)
            {
                switch (ex.Status)
                {
                    case WebExceptionStatus.ConnectFailure:
                    case WebExceptionStatus.ProxyNameResolutionFailure:
                        throw new FileSystemUnavailableException("The FTP server is currently unavailable.", ex);
                }

                throw new AccessException("The file could not be accessed", ex);
            }
        }
Example #23
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Job"/> class.
        /// </summary>
        /// <param name="name">The name of the job.</param>
        /// <param name="sourceFileSystem">The source file system.</param>
        /// <param name="targetFileSystem">The target file system.</param>
        /// <param name="directoryA">The directory A.</param>
        /// <param name="directoryB">The directory B.</param>
        protected Job(string name, IFileSystem sourceFileSystem, IFileSystem targetFileSystem, IDirectoryInfo directoryA, IDirectoryInfo directoryB)
        {
            sourceFileSystem.ThrowIfNull(() => sourceFileSystem);
            targetFileSystem.ThrowIfNull(() => targetFileSystem);
            directoryA.ThrowIfNull(() => directoryA);
            directoryB.ThrowIfNull(() => directoryB);

            if (String.IsNullOrEmpty(name))
                throw new ArgumentException("The name cannot be null or empty.", Reflector.GetMemberName(() => name));

            this.SourceFileSystem = sourceFileSystem;
            this.TargetFileSystem = targetFileSystem;

            this.DirectoryA = directoryA;
            this.DirectoryB = directoryB;

            this.Name = name;

            this.proceededFilePaths = new HashSet<string>();
            this.excludedPaths = new HashSet<string>();
            this.deletedDirectoryPaths = new HashSet<string>();

            this.pauseHandle = new AutoResetEvent(false);
        }
Example #24
0
 public LowerCasingFileSystem(IFileSystem wrappedFileSystem)
 {
     WrappedFileSystem = wrappedFileSystem.ThrowIfNull("wrappedFileSystem");
 }
Example #25
0
 public BuildStepBase(IFileSystem fileSystem, Settings settings, ILogger logger)
 {
     FileSystem = fileSystem.ThrowIfNull("fileSystem");
     Settings   = settings.ThrowIfNull("settings");
     Logger     = logger.ThrowIfNull("logger");
 }
Example #26
0
 public CountingFileSystem(IFileSystem wrappedFileSystem)
 {
     WrappedFileSystem = wrappedFileSystem.ThrowIfNull("wrappedFileSystem");
     StatsByExtension  = new Dictionary <string, FileSystemStats>();
 }
Example #27
0
        public BundleContents GetContents(IFileSystem fileSystem, IEnumerable<IAssetTransformer> transformers)
        {
            fileSystem.ThrowIfNull("fileSystem");
            transformers.ThrowIfNull("transformers");

            AssetFile[] unorderedAssets = _assets.SelectMany(arg => arg.ResolveAssetFiles(fileSystem)).ToArray();

            return GetContents(fileSystem, unorderedAssets, new DelimiterConcatenator(), transformers);
        }
Example #28
0
        public BundleContents GetContents(IFileSystem fileSystem, IComparer<AssetFile> assetOrder, IAssetConcatenator concatenator, IEnumerable<IAssetTransformer> transformers)
        {
            fileSystem.ThrowIfNull("fileSystem");
            assetOrder.ThrowIfNull("assetOrder");
            concatenator.ThrowIfNull("concatenator");
            transformers.ThrowIfNull("transformers");

            AssetFile[] orderedAssets = _assets
                .SelectMany(arg => arg.ResolveAssetFiles(fileSystem))
                .OrderBy(arg => arg, assetOrder)
                .ToArray();

            return GetContents(fileSystem, orderedAssets, concatenator, transformers);
        }