Ejemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:RyanKenward.Files.Business.DirectorySearch"/> class.
 /// </summary>
 /// <param name="fileSearch">File search.</param>
 /// <param name="fileManager">File manager.</param>
 /// <param name="searchDirectory">Search directory.</param>
 public DirectorySearch(
     IFileSearch fileSearch,
     IFileManager fileManager,
     string searchDirectory)
     : this(fileSearch, fileManager, searchDirectory, new FileSystem())
 {
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds a bundle for each individual file found using the file search. If no file search is provided the application
        /// default file search for the bundle type is used.
        /// </summary>
        /// <typeparam name="T">The type of bundle to create.</typeparam>
        /// <param name="directoryPath">The path to the directory to search. If null or empty the application source directory is used.</param>
        /// <param name="fileSearch">The <see cref="IFileSearch"/> used to find files. If null the application default file search for the bundle type is used.</param>
        /// <param name="customizeBundle">An optional action delegate called for each bundle.</param>
        public void AddPerIndividualFile <T>(string directoryPath = null, IFileSearch fileSearch = null, Action <T> customizeBundle = null)
            where T : Bundle
        {
            var directory = string.IsNullOrEmpty(directoryPath)
                                ? settings.SourceDirectory
                                : settings.SourceDirectory.GetDirectory(directoryPath);

            fileSearch = fileSearch ?? fileSearchProvider.GetFileSearch(typeof(T));
            var files         = fileSearch.FindFiles(directory);
            var bundleFactory = bundleFactoryProvider.GetBundleFactory <T>();

            foreach (var file in files)
            {
                var bundle = bundleFactory.CreateBundle(
                    file.FullPath,
                    new[] { file },
                    new BundleDescriptor {
                    AssetFilenames = { "*" }
                }
                    );
                if (customizeBundle != null)
                {
                    customizeBundle(bundle);
                }
                Add(bundle);
            }
        }
        public UpdateProjectFilesCommandHandlerFacade([NotNull] IFileSystem filesystem, [NotNull] IFileSearch fileSearcher)
        {
            Guard.NotNull(filesystem, nameof(filesystem));
            Guard.NotNull(fileSearcher, nameof(fileSearcher));

            this.filesystem   = filesystem;
            this.fileSearcher = fileSearcher;
        }
Ejemplo n.º 4
0
 /// <summary>
 ///     Initialises a new instance of the <see cref="SortEpisodesController" /> class.
 /// </summary>
 /// <param name="tvShowRepository">The TV show repository.</param>
 /// <param name="fileSearch">The file searcher.</param>
 /// <param name="storageProvider">The storage provider.</param>
 public SortEpisodesController(
     ITvShowRepository tvShowRepository,
     IFileSearch fileSearch,
     IStorageProvider storageProvider)
 {
     this.tvShowRepository = tvShowRepository;
     this.fileSearch       = fileSearch;
     this.storageProvider  = storageProvider;
 }
Ejemplo n.º 5
0
        public UpdateProjectFilesCommandHandlerImplementation(
            [NotNull] IFileSystem filesystem,
            [NotNull] IFileSearch fileSearcher)
        {
            Guard.NotNull(filesystem, nameof(filesystem));
            Guard.NotNull(fileSearcher, nameof(fileSearcher));

            this.filesystem   = filesystem;
            this.fileSearcher = fileSearcher;
            regex             = new Regex(Search, RegexOptions.Compiled);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:RyanKenward.Files.Business.DirectorySearch"/> class.
 /// </summary>
 /// <param name="fileSearch">File search.</param>
 /// <param name="fileManager">File manager.</param>
 /// <param name="searchDirectory">Search directory.</param>
 /// <param name="fileSystem">File system.</param>
 public DirectorySearch(
     IFileSearch fileSearch,
     IFileManager fileManager,
     string searchDirectory,
     IFileSystem fileSystem)
 {
     _fileSearch      = fileSearch;
     _fileManager     = fileManager;
     _searchDirectory = searchDirectory;
     _fileSystem      = fileSystem;
 }
Ejemplo n.º 7
0
 public Push(
     ILoggerFactory loggerFactory,
     RoboNuGetFile roboNuGetFile,
     IFileSearch fileSearch,
     IProcessExecutor processExecutor
     ) : base(loggerFactory)
 {
     _roboNuGetFile   = roboNuGetFile;
     _fileSearch      = fileSearch;
     _processExecutor = processExecutor;
 }
Ejemplo n.º 8
0
        public CleanAppConfigCommandHandler(
            [NotNull] IFileSearch fileSearcher,
            [NotNull] IReadOnlySourceControl sourceControl,
            [NotNull] ICleanSingleAppConfig cleanSingleAppConfig)
        {
            Guard.NotNull(fileSearcher, nameof(fileSearcher));
            Guard.NotNull(sourceControl, nameof(sourceControl));
            Guard.NotNull(cleanSingleAppConfig, nameof(cleanSingleAppConfig));

            this.fileSearcher         = fileSearcher;
            this.sourceControl        = sourceControl;
            this.cleanSingleAppConfig = cleanSingleAppConfig;
        }
Ejemplo n.º 9
0
 public Pack(
     ILoggerFactory loggerFactory,
     RoboNuGetFile roboNuGetFile,
     IFileSearch fileSearch,
     IIndex <SoftKeySet, IConsoleCommand> commands,
     IProcessExecutor processExecutor
     ) : base(loggerFactory)
 {
     _roboNuGetFile   = roboNuGetFile;
     _fileSearch      = fileSearch;
     _commands        = commands;
     _processExecutor = processExecutor;
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Adds a bundle for each sub-directory of the given path.
        /// </summary>
        /// <typeparam name="T">The type of bundles to create.</typeparam>
        /// <param name="applicationRelativePath">The path to the directory containing sub-directories.</param>
        /// <param name="fileSearch">A file source that gets the files to include from a directory.</param>
        /// <param name="customizeBundle">A delegate that is called for each created bundle to allow customization.</param>
        /// <param name="excludeTopLevel">Prevents the creation of an extra bundle from the top-level files of the path, if any.</param>
        public void AddPerSubDirectory <T>(string applicationRelativePath, IFileSearch fileSearch, Action <T> customizeBundle, bool excludeTopLevel = false)
            where T : Bundle
        {
            Trace.Source.TraceInformation(string.Format("Creating {0} for each subdirectory of {1}", typeof(T).Name, applicationRelativePath));

            fileSearch = fileSearch ?? fileSearchProvider.GetFileSearch(typeof(T));

            var bundleFactory   = bundleFactoryProvider.GetBundleFactory <T>();
            var parentDirectory = settings.SourceDirectory.GetDirectory(applicationRelativePath);

            if (!excludeTopLevel)
            {
                var topLevelFiles = fileSearch.FindFiles(parentDirectory)
                                    .Where(f => f.Directory.Equals(parentDirectory))
                                    .ToArray();
                var directoryBundle = CreateDirectoryBundle(applicationRelativePath, bundleFactory, topLevelFiles, parentDirectory);
                if (topLevelFiles.Any() || directoryBundle is IExternalBundle)
                {
                    if (customizeBundle != null)
                    {
                        customizeBundle(directoryBundle);
                    }
                    Add(directoryBundle);
                }
            }

            var directories = parentDirectory.GetDirectories().Where(IsNotHidden);

            foreach (var directory in directories)
            {
                Trace.Source.TraceInformation(string.Format("Creating {0} for {1}", typeof(T).Name, directory.FullPath));
                var allFiles = fileSearch.FindFiles(directory).ToArray();

                var descriptorFile = TryGetDescriptorFile <T>(directory);
                var descriptor     = ReadOrCreateBundleDescriptor(descriptorFile);

                if (!allFiles.Any() && descriptor.ExternalUrl == null)
                {
                    continue;
                }

                var bundle = bundleFactory.CreateBundle(directory.FullPath, allFiles, descriptor);
                if (customizeBundle != null)
                {
                    customizeBundle(bundle);
                }
                TraceAssetFilePaths(bundle);
                Add(bundle);
            }
        }
            internal ProgressCommandExecution(
                [NotNull] IFileSystem filesystem,
                [NotNull] IFileSearch fileSearch,
                [NotNull] IProgress <ProgressData> progress)
            {
                Guard.NotNull(filesystem, nameof(filesystem));
                Guard.NotNull(fileSearch, nameof(fileSearch));
                Guard.NotNull(progress, nameof(progress));

                this.filesystem = filesystem;
                this.fileSearch = fileSearch;
                this.progress   = progress;
                foundFileCount  = 0;
                position        = new ProgressDataPosition(0, 0);
            }
Ejemplo n.º 12
0
        /// <summary>
        /// Adds a bundle of type <typeparamref name="T"/> using asset files found in the given path.
        /// </summary>
        /// <typeparam name="T">The type of bundle to create.</typeparam>
        /// <param name="applicationRelativePath">The application relative path to the bundle's asset files.</param>
        /// <param name="fileSearch">The file search used to find asset files to include in the bundle.</param>
        /// <param name="customizeBundle">The delegate used to customize the created bundle before adding it to the collection.</param>
        public void Add <T>(string applicationRelativePath, IFileSearch fileSearch, Action <T> customizeBundle)
            where T : Bundle
        {
            applicationRelativePath = PathUtilities.AppRelative(applicationRelativePath);
            Trace.Source.TraceInformation(string.Format("Creating {0} for {1}", typeof(T).Name, applicationRelativePath));

            T   bundle;
            var bundleFactory = bundleFactoryProvider.GetBundleFactory <T>();

            var source = settings.SourceDirectory;

            if (source.DirectoryExists(applicationRelativePath))
            {
                fileSearch = fileSearch ?? fileSearchProvider.GetFileSearch(typeof(T));
                var directory = source.GetDirectory(applicationRelativePath);
                var allFiles  = fileSearch.FindFiles(directory);
                bundle = CreateDirectoryBundle(applicationRelativePath, bundleFactory, allFiles, directory);
            }
            else
            {
                var file = source.GetFile(applicationRelativePath);
                if (file.Exists)
                {
                    bundle = CreateSingleFileBundle(applicationRelativePath, file, bundleFactory);
                }
                else
                {
                    throw new DirectoryNotFoundException(string.Format("Bundle path not found: {0}", applicationRelativePath));
                }
            }

            if (customizeBundle != null)
            {
                customizeBundle(bundle);
            }

            TraceAssetFilePaths(bundle);

            Add(bundle);
        }
Ejemplo n.º 13
0
        public ProjectCollectionViewModel(
            [NotNull] IProjectViewModelFactory projectViewModelFactory,
            [NotNull] IStatusFullModel statusModel,
            [NotNull] IFileSearch fileSearch,
            [NotNull] IConfigurationService configurationService,
            [NotNull] IDelayService delayService)
        {
            Guard.NotNull(statusModel, nameof(statusModel));
            Guard.NotNull(projectViewModelFactory, nameof(projectViewModelFactory));
            Guard.NotNull(fileSearch, nameof(fileSearch));
            Guard.NotNull(configurationService, nameof(configurationService));
            Guard.NotNull(delayService, nameof(delayService));

            this.statusModel             = statusModel;
            this.projectViewModelFactory = projectViewModelFactory;
            this.fileSearch           = fileSearch;
            this.configurationService = configurationService;
            this.delayService         = delayService;

            Projects   = new ObservableCollection <ProjectViewModel>();
            Initialize = new CapturingExceptionAsyncCommand(async _ => await LoadProjectsAsync());
        }
 /// <summary>
 ///     Initialises a new instance of the <see cref="MissingDuplicateController" /> class.
 /// </summary>
 /// <param name="storageProvider">The storage provider.</param>
 /// <param name="fileSearch">The file search.</param>
 public MissingDuplicateController(IStorageProvider storageProvider, IFileSearch fileSearch)
 {
     this.storageProvider = storageProvider;
     this.fileSearch      = fileSearch;
 }
Ejemplo n.º 15
0
 public List(ILoggerFactory loggerFactory, RoboNuGetFile roboNuGetFile, IFileSearch fileSearch) : base(loggerFactory)
 {
     _roboNuGetFile = roboNuGetFile;
     _fileSearch    = fileSearch;
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Adds a bundle for each individual file found using the file search. If no file search is provided the application
        /// default file search for the bundle type is used.
        /// </summary>
        /// <typeparam name="T">The type of bundle to create.</typeparam>
        /// <param name="bundleCollection">The bundle collection to add to.</param>
        /// <param name="directoryPath">The path to the directory to search. If null or empty the application source directory is used.</param>
        /// <param name="fileSearch">The <see cref="IFileSearch"/> used to find files. If null the application default file search for the bundle type is used.</param>
        /// <param name="customizeBundle">An optional action delegate called for each bundle.</param>
        public static void AddPerIndividualFile <T>(this BundleCollection bundleCollection, string directoryPath = null, IFileSearch fileSearch = null, Action <T> customizeBundle = null)
            where T : Bundle
        {
            var directory = string.IsNullOrEmpty(directoryPath)
                ? bundleCollection.Settings.SourceDirectory
                : bundleCollection.Settings.SourceDirectory.GetDirectory(directoryPath);

            fileSearch = fileSearch ?? bundleCollection.Settings.DefaultFileSearches[typeof(T)];
            var files         = fileSearch.FindFiles(directory);
            var bundleFactory = (IBundleFactory <T>)bundleCollection.Settings.BundleFactories[typeof(T)];

            foreach (var file in files)
            {
                var bundle = bundleFactory.CreateBundle(
                    file.FullPath,
                    new[] { file },
                    new BundleDescriptor {
                    AssetFilenames = { "*" }
                }
                    );
                if (customizeBundle != null)
                {
                    customizeBundle(bundle);
                }
                bundleCollection.Add(bundle);
            }
        }
Ejemplo n.º 17
0
 /// <summary>
 /// Adds a bundle of type <typeparamref name="T"/> using asset files found in the given path.
 /// </summary>
 /// <typeparam name="T">The type of bundle to create.</typeparam>
 /// <param name="bundleCollection">The bundle collection to add to.</param>
 /// <param name="applicationRelativePath">The application relative path to the bundle's asset files.</param>
 /// <param name="fileSearch">The file search used to find asset files to include in the bundle.</param>
 public static void Add <T>(this BundleCollection bundleCollection, string applicationRelativePath, IFileSearch fileSearch)
     where T : Bundle
 {
     Add <T>(bundleCollection, applicationRelativePath, fileSearch, null);
 }
Ejemplo n.º 18
0
        /// <summary>
        /// Adds a bundle for each sub-directory of the given path.
        /// </summary>
        /// <typeparam name="T">The type of bundles to create.</typeparam>
        /// <param name="bundleCollection">The collection to add to.</param>
        /// <param name="applicationRelativePath">The path to the directory containing sub-directories.</param>
        /// <param name="fileSearch">A file source that gets the files to include from a directory.</param>
        /// <param name="customizeBundle">A delegate that is called for each created bundle to allow customization.</param>
        /// <param name="excludeTopLevel">Prevents the creation of an extra bundle from the top-level files of the path, if any.</param>
        public static void AddPerSubDirectory <T>(this BundleCollection bundleCollection, string applicationRelativePath, IFileSearch fileSearch, Action <T> customizeBundle, bool excludeTopLevel = false)
            where T : Bundle
        {
            Trace.Source.TraceInformation(string.Format("Creating {0} for each subdirectory of {1}", typeof(T).Name, applicationRelativePath));

            fileSearch = fileSearch ?? bundleCollection.Settings.DefaultFileSearches[typeof(T)];

            var bundleFactory   = (IBundleFactory <T>)bundleCollection.Settings.BundleFactories[typeof(T)];
            var parentDirectory = bundleCollection.Settings.SourceDirectory.GetDirectory(applicationRelativePath);

            if (!excludeTopLevel)
            {
                var topLevelFiles = fileSearch.FindFiles(parentDirectory)
                                    .Where(f => f.Directory == parentDirectory)
                                    .ToArray();
                var directoryBundle = CreateDirectoryBundle(applicationRelativePath, bundleFactory, topLevelFiles, parentDirectory);
                if (topLevelFiles.Any() || directoryBundle is IExternalBundle)
                {
                    if (customizeBundle != null)
                    {
                        customizeBundle(directoryBundle);
                    }
                    bundleCollection.Add(directoryBundle);
                }
            }

            var directories = parentDirectory.GetDirectories().Where(IsNotHidden);

            foreach (var directory in directories)
            {
                Trace.Source.TraceInformation(string.Format("Creating {0} for {1}", typeof(T).Name, directory.FullPath));
                var allFiles = fileSearch.FindFiles(directory).ToArray();

                var descriptorFile = TryGetDescriptorFile(directory);
                var descriptor     = descriptorFile.Exists
                                     ? new BundleDescriptorReader(descriptorFile).Read()
                                     : new BundleDescriptor {
                    AssetFilenames = { "*" }
                };

                if (!allFiles.Any() && descriptor.ExternalUrl == null)
                {
                    continue;
                }

                var bundle = bundleFactory.CreateBundle(directory.FullPath, allFiles, descriptor);
                if (customizeBundle != null)
                {
                    customizeBundle(bundle);
                }
                TraceAssetFilePaths(bundle);
                bundleCollection.Add(bundle);
            }
        }
Ejemplo n.º 19
0
 /// <summary>
 /// Adds a bundle for each sub-directory of the given path.
 /// </summary>
 /// <typeparam name="T">The type of bundles to create.</typeparam>
 /// <param name="bundleCollection">The collection to add to.</param>
 /// <param name="applicationRelativePath">The path to the directory containing sub-directories.</param>
 /// <param name="fileSearch">A file source that gets the files to include from a directory.</param>
 /// <param name="excludeTopLevel">Prevents the creation of an extra bundle from the top-level files of the directory, if any.</param>
 public static void AddPerSubDirectory <T>(this BundleCollection bundleCollection, string applicationRelativePath, IFileSearch fileSearch, bool excludeTopLevel = false)
     where T : Bundle
 {
     AddPerSubDirectory <T>(bundleCollection, applicationRelativePath, fileSearch, null, excludeTopLevel);
 }
Ejemplo n.º 20
0
 public void SetDefaultFileSearch <T>(IFileSearch fileSearch)
     where T : Bundle
 {
     fileSearches[typeof(T)] = fileSearch;
 }
 public SummaryCollectorFileSearchDecorator(IFileSearch decoratee, IStatistics statistics)
 {
     this.decoratee  = decoratee;
     this.statistics = statistics;
 }
Ejemplo n.º 22
0
 /// <summary>
 /// Adds a bundle for each sub-directory of the given path.
 /// </summary>
 /// <typeparam name="T">The type of bundles to create.</typeparam>
 /// <param name="applicationRelativePath">The path to the directory containing sub-directories.</param>
 /// <param name="fileSearch">A file source that gets the files to include from a directory.</param>
 /// <param name="excludeTopLevel">Prevents the creation of an extra bundle from the top-level files of the directory, if any.</param>
 public void AddPerSubDirectory <T>(string applicationRelativePath, IFileSearch fileSearch, bool excludeTopLevel = false)
     where T : Bundle
 {
     AddPerSubDirectory <T>(applicationRelativePath, fileSearch, null, excludeTopLevel);
 }
Ejemplo n.º 23
0
 /// <summary>
 /// Adds a bundle of type <typeparamref name="T"/> using asset files found in the given path.
 /// </summary>
 /// <typeparam name="T">The type of bundle to create.</typeparam>
 /// <param name="applicationRelativePath">The application relative path to the bundle's asset files.</param>
 /// <param name="fileSearch">The file search used to find asset files to include in the bundle.</param>
 public void Add <T>(string applicationRelativePath, IFileSearch fileSearch)
     where T : Bundle
 {
     Add <T>(applicationRelativePath, fileSearch, null);
 }
Ejemplo n.º 24
0
 public VerboseFileSearchDecorator(IFileSearch decoratee, IConsole console)
 {
     this.decoratee = decoratee;
     this.console   = console;
 }
Ejemplo n.º 25
0
        /// <summary>
        /// Adds a bundle of type <typeparamref name="T"/> using asset files found in the given path.
        /// </summary>
        /// <typeparam name="T">The type of bundle to create.</typeparam>
        /// <param name="bundleCollection">The bundle collection to add to.</param>
        /// <param name="applicationRelativePath">The application relative path to the bundle's asset files.</param>
        /// <param name="fileSearch">The file search used to find asset files to include in the bundle.</param>
        /// <param name="customizeBundle">The delegate used to customize the created bundle before adding it to the collection.</param>
        public static void Add <T>(this BundleCollection bundleCollection, string applicationRelativePath, IFileSearch fileSearch, Action <T> customizeBundle)
            where T : Bundle
        {
            Trace.Source.TraceInformation(string.Format("Creating {0} for {1}", typeof(T).Name, applicationRelativePath));

            T   bundle;
            var bundleFactory = (IBundleFactory <T>)bundleCollection.Settings.BundleFactories[typeof(T)];

            var source = bundleCollection.Settings.SourceDirectory;

            if (source.DirectoryExists(applicationRelativePath))
            {
                fileSearch = fileSearch ?? bundleCollection.Settings.DefaultFileSearches[typeof(T)];
                var directory = source.GetDirectory(applicationRelativePath);
                var allFiles  = fileSearch.FindFiles(directory);
                bundle = CreateDirectoryBundle(applicationRelativePath, bundleFactory, allFiles, directory);
            }
            else
            {
                var file = source.GetFile(applicationRelativePath);
                if (file.Exists)
                {
                    bundle = CreateSingleFileBundle(applicationRelativePath, file, bundleFactory);
                }
                else
                {
                    throw new DirectoryNotFoundException(string.Format("Bundle path not found: {0}", applicationRelativePath));
                }
            }

            if (customizeBundle != null)
            {
                customizeBundle(bundle);
            }

            TraceAssetFilePaths(bundle);

            bundleCollection.Add(bundle);
        }
Ejemplo n.º 26
0
 public FileService(IFileSearch searcher, IFileStorage merger)
 {
     FoundFiles = new ConcurrentDictionary <string, IFile>();
     _store     = merger;
     _search    = searcher;
 }