public static IScanner <FileInfo> FilesInLocalPath(this IScannerFactory factory, IEnumerable <string> patterns, SearchOption option = SearchOption.TopDirectoryOnly)
        {
            var appDomain   = AppDomain.CurrentDomain;
            var directories = GetSearchDirs(appDomain);

            return(FilesInDirectory(factory, directories, patterns, option));
        }
Esempio n. 2
0
 public static IScanner <T> Empty <T>(this IScannerFactory factory)
 {
     if (factory == null)
     {
         throw new ArgumentNullException(nameof(factory));
     }
     return(new ImmutableScanner <T>(factory, Enumerable.Empty <T>()));
 }
Esempio n. 3
0
        /// <summary>
        /// Initializes an instance of the <see cref="Parser"/> with the specified scanner factory.
        /// </summary>
        /// <param name="scannerFactory">The factory of BASIC scanners.</param>
        public Parser(IScannerFactory <Token> scannerFactory)
        {
            if (scannerFactory == null)
            {
                throw new ArgumentNullException("scannerFactory");
            }

            this.scannerFactory = scannerFactory;
        }
Esempio n. 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ScanContext"/> class.
        /// </summary>
        public ScanContext(IScannerFactory factory)
        {
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }

            Factory = factory;
            Options = new KeyedByTypeCollection <IScanOption>();
        }
        public static IAppDomainScanner CurrentDomain(this IScannerFactory factory)
        {
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }
            var appDomain = System.AppDomain.CurrentDomain;

            return(new AppDomainScanner(factory, appDomain));
        }
Esempio n. 6
0
        /// <summary>
        /// Intializes a new instance of <see cref="AppDomainScanner"/> with the
        /// specified <see cref="AppDomain"/>.
        /// </summary>
        /// <param name="appDomain">The <see cref="AppDomain"/> that this scanner uses to retieves it's <see cref="Assembly"/> objects from.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="appDomain"/> argument is a null.</exception>
        public AppDomainScanner(IScannerFactory factory, AppDomain appDomain)
            : base(factory)
        {
            if (appDomain == null)
            {
                throw new ArgumentNullException(nameof(appDomain));
            }

            _appDomain              = appDomain;
            appDomain.AssemblyLoad += HandleAssemblyLoad;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ObservableScanner{T, TCollection}"/> class with the specified observable collection.
        /// </summary>
        /// <param name="factory">The <see cref="IScannerFactory"/> to use when creating objects.</param>
        /// <param name="collection">The observable collection to use.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="collection"/> argument is a null.</exception>
        public ObservableScanner(IScannerFactory factory, TCollection collection)
            : base(factory)
        {
            if (collection == null)
            {
                throw new ArgumentNullException(nameof(collection));
            }

            collection.CollectionChanged += HandleCollectionChanged;
            _collection = collection;
        }
Esempio n. 8
0
 public static IScanner <T> Immutable <T>(this IScannerFactory factory, params T[] source)
 {
     if (factory == null)
     {
         throw new ArgumentNullException(nameof(factory));
     }
     if (source == null)
     {
         throw new ArgumentNullException(nameof(source));
     }
     return(new ImmutableScanner <T>(factory, source));
 }
Esempio n. 9
0
 public static IAggregateScanner <T> Aggregate <T>(this IScannerFactory factory, params IScanner <T>[] source)
 {
     if (factory == null)
     {
         throw new ArgumentNullException(nameof(factory));
     }
     if (source == null)
     {
         throw new ArgumentNullException(nameof(source));
     }
     return(new AggregateScanner <T>(factory, source));
 }
Esempio n. 10
0
 public static IScanner <T> AsScanner <T>(this IEnumerable <T> source, IScannerFactory factory)
 {
     if (factory == null)
     {
         throw new ArgumentNullException(nameof(factory));
     }
     if (source == null)
     {
         throw new ArgumentNullException(nameof(source));
     }
     return(new ImmutableScanner <T>(factory, source));
 }
Esempio n. 11
0
 public static IAppDomainScanner AsScanner(this AppDomain appDomain, IScannerFactory factory)
 {
     if (factory == null)
     {
         throw new ArgumentNullException(nameof(factory));
     }
     if (appDomain == null)
     {
         throw new ArgumentNullException(nameof(appDomain));
     }
     return(new AppDomainScanner(factory, appDomain));
 }
Esempio n. 12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AggregateScanner{T}"/> class with the specified collection of scanners.
        /// </summary>
        /// <param name="factory">The <see cref="IScannerFactory"/> to use when creating objects.</param>
        /// <param name="scanners">A collection of <see cref="IScanner{T}"/> objects to add to the <see cref="AggregateScanner{T}"/>.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="scanners"/> argument is a null.</exception>
        public AggregateScanner(IScannerFactory factory, IEnumerable <IScanner <T> > scanners)
            : base(factory)
        {
            if (scanners == null)
            {
                throw new ArgumentNullException(nameof(scanners));
            }

            var collection = new ScannerCollection <T>(scanners);

            collection.CollectionChanged += HandleCollectionChanged;
            Scanners = collection;
        }
        public static IScanner <FileInfo> FilesInDirectory(this IScannerFactory factory, IEnumerable <string> directories, IEnumerable <string> patterns, SearchOption option = SearchOption.TopDirectoryOnly)
        {
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }
            if (directories == null)
            {
                throw new ArgumentNullException(nameof(directories));
            }
            if (patterns == null)
            {
                throw new ArgumentNullException(nameof(patterns));
            }

            return(factory
                   .Immutable(directories)
                   .Transform((context, directory) => patterns.SelectMany(pattern => Transforms.EnumerateFiles(context, directory, pattern, option))));
        }
 public static IScanner <FileInfo> FilesInDirectory(this IScannerFactory factory, IEnumerable <string> directories, SearchOption option = SearchOption.TopDirectoryOnly)
 {
     return(FilesInDirectory(factory, directories, Constants.DefaultSearchPatterns, option));
 }
        public static IScanner <FileInfo> FilesInDirectory(this IScannerFactory factory, string directory, IEnumerable <string> patterns, SearchOption option = SearchOption.TopDirectoryOnly)
        {
            var directories = new[] { directory };

            return(FilesInDirectory(factory, directories, patterns, option));
        }
        //

        public static IScanner <FileInfo> FilesInDirectory(this IScannerFactory factory, string directory, SearchOption option = SearchOption.TopDirectoryOnly)
        {
            var directories = new[] { directory };

            return(FilesInDirectory(factory, directories, Constants.DefaultSearchPatterns, option));
        }
Esempio n. 17
0
 public Scanner(IScannerFactory factory)
 {
     _factory = factory.IsNotNull() ? factory : throw new HareDuDiagnosticsException();
 }
Esempio n. 18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AggregateScanner{T}"/> class.
 /// </summary>
 public AggregateScanner(IScannerFactory factory)
     : this(factory, Enumerable.Empty <IScanner <T> >())
 {
     // nothing
 }
Esempio n. 19
0
		/// <summary>
		/// Initializes a new instance of <see cref="Scanner{T}"/> that uses the specified factory.
		/// </summary>
		/// <param name="factory">The <see cref="IScannerFactory"/> to use when creating objects.</param>
		protected Scanner(IScannerFactory factory)
		{
			if (factory == null) throw new ArgumentNullException(nameof(factory));
			Factory = factory;
		}
Esempio n. 20
0
 public MovieSourceScanner(MovieSystemService movieSystemService, IScannerFactory scannerFactory)
 {
     _movieSystemService = movieSystemService;
     _scannerFactory = scannerFactory;
 }
Esempio n. 21
0
 /// <summary>
 /// Returns an empty <see cref="IScanner{T}"/>.
 /// </summary>
 /// <summary>
 /// Intializes a new instance of the <see cref="ImmutableScanner{T}"/> class with the specified collection of items.
 /// </summary>
 /// <param name="factory">The <see cref="IScannerFactory"/> to use when creating objects.</param>
 /// <param name="source">The collection of items that this scanner will return.</param>
 public ImmutableScanner(IScannerFactory factory, IEnumerable <T> source)
     : base(factory)
 {
     _source = source ?? Enumerable.Empty <T>();
 }
 public static IScanner <FileInfo> FilesInLocalPath(this IScannerFactory factory)
 {
     return(FilesInLocalPath(factory, Constants.DefaultSearchPatterns));
 }
 public static IObservableScanner <T, ObservableCollection <T> > Observable <T>(this IScannerFactory factory, ObservableCollection <T> collection)
 {
     if (factory == null)
     {
         throw new ArgumentNullException(nameof(factory));
     }
     if (collection == null)
     {
         throw new ArgumentNullException(nameof(collection));
     }
     return(new ObservableScanner <T, ObservableCollection <T> >(factory, collection));
 }