Ejemplo n.º 1
0
            public void Test()
            {
                ExecuteHandlers <Result> handler = new ExecuteHandlers <Result>();

                handler.AddCommand(new MyCommand());
                handler.Execute();
            }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of FileSearcher class.
        /// </summary>
        /// <param name="folder">The start search directory.</param>
        /// <param name="pattern">The search pattern.</param>
        /// <param name="handlerOption">Specifies where FilesFound event handlers are executed.</param>
        /// <exception cref="ArgumentException"></exception>
        /// <exception cref="ArgumentNullException"></exception>
        public FileSearcher(string folder, string pattern, ExecuteHandlers handlerOption)
        {
            CheckFolder(folder);

            CheckPattern(pattern);

            searcher = new FilePatternSearcher(folder, pattern, handlerOption);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of FileSearcher class.
        /// </summary>
        /// <param name="folder">The start search directory.</param>
        /// <param name="isValid">The delegate that determines algorithm of file selection.</param>
        /// <param name="handlerOption">Specifies where FilesFound event handlers are executed.</param>
        /// <exception cref="ArgumentException"></exception>
        /// <exception cref="ArgumentNullException"></exception>
        public FileSearcher(string folder, Func <FileInfo, bool> isValid, ExecuteHandlers handlerOption)
        {
            CheckFolder(folder);

            CheckDelegate(isValid);

            searcher = new FileDelegateSearcher(folder, isValid, handlerOption);
        }
Ejemplo n.º 4
0
 public ScriptInterpreter GetLoaderOfFiletype(string type)
 {
     lock (ExecuteHandlers)
     {
         SystemExecHandler handler;
         if (ExecuteHandlers.TryGetValue(type, out handler))
         {
             return(null);
         }
     }
     return(new AIMLScriptIntperForFiletype(type, this));
 }
Ejemplo n.º 5
0
        Result IExternalCommand.Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            while (ExecuteHandlers.Count > 0)
            {
                var first = ExecuteHandlers.Dequeue();

                first(commandData, ref message, elements);
            }

            while (InvokeHandlers.Count > 0)
            {
                var first = InvokeHandlers.Dequeue();

                first(commandData.Application);
            }

            return(Result.Succeeded);
        }
Ejemplo n.º 6
0
 public FileDelegateSearcher(string folder, Func <FileInfo, bool> isValid, ExecuteHandlers handlerOption) : base(folder, handlerOption)
 {
     this.isValid = isValid;
 }
Ejemplo n.º 7
0
 public FileCancellationPatternSearcher(string folder, string pattern, CancellationToken token, ExecuteHandlers handlerOption, bool suppressOperationCanceledException)
     : base(folder, token, handlerOption, suppressOperationCanceledException)
 {
     this.pattern = pattern;
 }
        /// <summary>
        /// Initializes a new instance of FileSearchMultiple class.
        /// </summary>
        /// <param name="folders">Start search directories.</param>
        /// <param name="isValid">The delegate that determines algorithm of file selection.</param>
        /// <param name="tokenSource">Instance of CancellationTokenSource for search process cancellation possibility.</param>
        /// <param name="handlerOption">Specifies where FilesFound event handlers are executed.</param>
        /// <param name="suppressOperationCanceledException">Determines whether necessary suppress OperationCanceledException if it possible.</param>
        /// <exception cref="ArgumentException"></exception>
        /// <exception cref="ArgumentNullException"></exception>
        public FileSearchMultiple(List <string> folders, Func <FileInfo, bool> isValid, CancellationTokenSource tokenSource, ExecuteHandlers handlerOption, bool suppressOperationCanceledException)
        {
            CheckFolders(folders);

            CheckDelegate(isValid);

            CheckTokenSource(tokenSource);

            searchers = new List <FileSearchBase>();

            this.suppressOperationCanceledException = suppressOperationCanceledException;

            foreach (var folder in folders)
            {
                searchers.Add(new FileCancellationDelegateSearch(folder, isValid, handlerOption, false, tokenSource.Token));
            }

            this.tokenSource = tokenSource;
        }
 /// <summary>
 /// Initializes a new instance of FileSearchMultiple class.
 /// </summary>
 /// <param name="folders">Start search directories.</param>
 /// <param name="pattern">The search pattern.</param>
 /// <param name="tokenSource">Instance of CancellationTokenSource for search process cancellation possibility.</param>
 /// <param name="handlerOption">Specifies where FilesFound event handlers are executed.</param>
 /// <exception cref="ArgumentException"></exception>
 /// <exception cref="ArgumentNullException"></exception>
 public FileSearchMultiple(List <string> folders, string pattern, CancellationTokenSource tokenSource, ExecuteHandlers handlerOption)
     : this(folders, pattern, tokenSource, handlerOption, true)
 {
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Initialize a new instance of DirectorySearch class.
 /// </summary>
 /// <param name="folder">The start search directory.</param>
 /// <param name="pattern">The search pattern.</param>
 /// <param name="tokenSource">Instance of CancellationTokenSource for search process cancellation possibility.</param>
 /// <param name="handlerOption">Specifies where DirectoriesFound event handlers are executed.</param>
 /// <exception cref="ArgumentException"></exception>
 /// <exception cref="ArgumentNullException"></exception>
 public DirectorySearcher(string folder, string pattern, CancellationTokenSource tokenSource, ExecuteHandlers handlerOption)
     : this(folder, pattern, tokenSource, handlerOption, true)
 {
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Initialize a new instance of DirectorySearch class.
 /// </summary>
 /// <param name="folder">The start search directory.</param>
 /// <param name="isValid">The delegate that determines algorithm of directory selection.</param>
 /// <param name="tokenSource">Instance of CancellationTokenSource for search process cancellation possibility.</param>
 /// <param name="handlerOption">Specifies where DirectoriesFound event handlers are executed.</param>
 /// <exception cref="ArgumentException"></exception>
 /// <exception cref="ArgumentNullException"></exception>
 public DirectorySearcher(string folder, Func <DirectoryInfo, bool> isValid, CancellationTokenSource tokenSource, ExecuteHandlers handlerOption)
     : this(folder, isValid, tokenSource, ExecuteHandlers.InCurrentTask, true)
 {
 }
Ejemplo n.º 12
0
 public FileCancellationSearcherBase(string folder, CancellationToken token, ExecuteHandlers handlerOption, bool suppressOperationCanceledException)
     : base(folder, handlerOption)
 {
     this.token = token;
     this.SuppressOperationCanceledException = suppressOperationCanceledException;
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Initializes a new instance of FileSearcher class.
 /// </summary>
 /// <param name="folder">The start search directory.</param>
 /// <param name="isValid">The delegate that determines algorithm of file selection.</param>
 /// <param name="tokenSource">Instance of CancellationTokenSource for search process cancellation possibility.</param>
 /// <param name="handlerOption">Specifies where FilesFound event handlers are executed.</param>
 /// <exception cref="ArgumentException"></exception>
 /// <exception cref="ArgumentNullException"></exception>
 public FileSearcher(string folder, Func <FileInfo, bool> isValid, CancellationTokenSource tokenSource, ExecuteHandlers handlerOption)
     : this(folder, isValid, tokenSource, handlerOption, true)
 {
 }
Ejemplo n.º 14
0
 public FilePatternSearcher(string folder, string pattern, ExecuteHandlers handlerOption) : base(folder, handlerOption)
 {
     this.pattern = pattern;
 }
Ejemplo n.º 15
0
 public FileCancellationDelegateSearcher(string folder, Func <FileInfo, bool> isValid, CancellationToken token, ExecuteHandlers handlerOption, bool suppressOperationCanceledException)
     : base(folder, token, handlerOption, suppressOperationCanceledException)
 {
     this.isValid = isValid;
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Initialize a new instance of DirectorySearch class.
        /// </summary>
        /// <param name="folder">The start search directory.</param>
        /// <param name="isValid">The delegate that determines algorithm of directory selection.</param>
        /// <param name="tokenSource">Instance of CancellationTokenSource for search process cancellation possibility.</param>
        /// <param name="handlerOption">Specifies where DirectoriesFound event handlers are executed.</param>
        /// <param name="suppressOperationCanceledException">Determines whether necessary suppress OperationCanceledException if it possible.</param>
        /// <exception cref="ArgumentException"></exception>
        /// <exception cref="ArgumentNullException"></exception>
        public DirectorySearcher(string folder, Func <DirectoryInfo, bool> isValid, CancellationTokenSource tokenSource, ExecuteHandlers handlerOption, bool suppressOperationCanceledException)
        {
            CheckFolder(folder);

            CheckDelegate(isValid);

            CheckTokenSource(tokenSource);

            searcher         = new DirectoryCancellationDelegateSearcher(folder, isValid, tokenSource.Token, handlerOption, suppressOperationCanceledException);
            this.tokenSource = tokenSource;
        }
Ejemplo n.º 17
0
 public FileSearcherBase(string folder, ExecuteHandlers handlerOption)
 {
     this.folder        = folder;
     this.handlerOption = handlerOption;
     taskHandlers       = new ConcurrentBag <Task>();
 }
Ejemplo n.º 18
0
        /// <summary>
        /// Initialize a new instance of DirectorySearch class.
        /// </summary>
        /// <param name="folder">The start search directory.</param>
        /// <param name="pattern">The search pattern.</param>
        /// <param name="tokenSource">Instance of CancellationTokenSource for search process cancellation possibility.</param>
        /// <param name="handlerOption">Specifies where DirectoriesFound event handlers are executed.</param>
        /// <param name="suppressOperationCanceledException">Determines whether necessary suppress OperationCanceledException if it possible.</param>
        /// <exception cref="ArgumentException"></exception>
        /// <exception cref="ArgumentNullException"></exception>
        public DirectorySearcher(string folder, string pattern, CancellationTokenSource tokenSource, ExecuteHandlers handlerOption, bool suppressOperationCanceledException)
        {
            CheckFolder(folder);

            CheckPattern(pattern);

            CheckTokenSource(tokenSource);

            searcher         = new DirectoryCancellationPatternSearcher(folder, pattern, tokenSource.Token, handlerOption, suppressOperationCanceledException);
            this.tokenSource = tokenSource;
        }
 /// <summary>
 /// Initializes a new instance of FileSearchMultiple class.
 /// </summary>
 /// <param name="folders">Start search directories.</param>
 /// <param name="isValid">The delegate that determines algorithm of file selection.</param>
 /// <param name="tokenSource">Instance of CancellationTokenSource for search process cancellation possibility.</param>
 /// <param name="handlerOption">Specifies where FilesFound event handlers are executed.</param>
 /// <exception cref="ArgumentException"></exception>
 /// <exception cref="ArgumentNullException"></exception>
 public FileSearchMultiple(List <string> folders, Func <FileInfo, bool> isValid, CancellationTokenSource tokenSource, ExecuteHandlers handlerOption)
     : this(folders, isValid, tokenSource, handlerOption, true)
 {
 }
 public DirectoryCancellationSearcherBase(string folder, CancellationToken token, ExecuteHandlers handlerOption, bool suppressOperationCanceledException)
 {
     this.folder        = folder;
     this.token         = token;
     this.handlerOption = handlerOption;
     this.SuppressOperationCanceledException = suppressOperationCanceledException;
     taskHandlers = new ConcurrentBag <Task>();
 }
        /// <summary>
        /// Initializes a new instance of FileSearchMultiple class.
        /// </summary>
        /// <param name="folders">Start search directories.</param>
        /// <param name="pattern">The search pattern.</param>
        /// <param name="tokenSource">Instance of CancellationTokenSource for search process cancellation possibility.</param>
        /// <param name="handlerOption">Specifies where FilesFound event handlers are executed.</param>
        /// <param name="suppressOperationCanceledException">Determines whether necessary suppress OperationCanceledException if it possible.</param>
        /// <exception cref="ArgumentException"></exception>
        /// <exception cref="ArgumentNullException"></exception>
        public FileSearchMultiple(List <string> folders, string pattern, CancellationTokenSource tokenSource, ExecuteHandlers handlerOption, bool suppressOperationCanceledException)
        {
            CheckFolders(folders);

            CheckPattern(pattern);

            CheckTokenSource(tokenSource);

            searchers = new List <FileSearchBase>();

            this.suppressOperationCanceledException = suppressOperationCanceledException;

            foreach (var folder in folders)
            {
                searchers.Add(new FileCancellationPatternSearch(folder, pattern, handlerOption, false, tokenSource.Token));
            }

            this.tokenSource = tokenSource;
        }