/// <summary>
 /// Processes the directory.
 /// </summary>
 /// <param name="directoryInfo">The directory info.</param>
 /// <param name="action">The action.</param>
 /// <returns><see langword="true"/> when the scan is allowed to continue. <see langword="false"/> if otherwise;</returns>
 public virtual bool ProcessDirectory(DirectoryInfo directoryInfo, ScanDirectoryAction action)
 {
     if (DirectoryEvent != null)
     {
         return(RaiseDirectoryEvent(directoryInfo, action));
     }
     return(true);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="DirectoryEventArgs"/> class.
        /// </summary>
        /// <param name="directory"><see cref="DirectoryInfo"/> object for the current path.</param>
        /// <param name="action">The action.</param>
        internal DirectoryEventArgs(DirectoryInfo directory, ScanDirectoryAction action)
        {
            if (directory == null)
            {
                throw new ArgumentNullException("directory");
            }

            // Get File information
            _directoryInfo = directory;
            _action        = action;
        }
        /// <summary>
        /// Raises the directory event.
        /// </summary>
        /// <param name="directory"><see cref="DirectoryInfo"/> object for the current path.</param>
        /// <param name="action">The <see cref="ScanDirectoryAction"/> action value.</param>
        /// <returns><see langword="true"/> when the scan is allowed to continue. <see langword="false"/> if otherwise;</returns>
        private bool RaiseDirectoryEvent(DirectoryInfo directory, ScanDirectoryAction action)
        {
            bool continueScan = true;

            // Only do something when the event has been declared.
            if (FileEvent != null)
            {
                // Create a new argument object for the file event.
                DirectoryEventArgs args = new DirectoryEventArgs(directory, action);

                // Now raise the event.
                DirectoryEvent(this, args);

                continueScan = !args.Cancel;
            }
            return(continueScan);
        }
 /// <summary>
 /// Processes the directory.
 /// </summary>
 /// <param name="directoryInfo">The directory info.</param>
 /// <param name="action">The action.</param>
 /// <returns><see langword="true"/> when the scan is allowed to continue. <see langword="false"/> if otherwise;</returns>
 public virtual bool ProcessDirectory(DirectoryInfo directoryInfo, ScanDirectoryAction action)
 {
     if (DirectoryEvent != null)
     {
         return RaiseDirectoryEvent(directoryInfo, action);
     }
     return true;
 }
        /// <summary>
        /// Raises the directory event.
        /// </summary>
        /// <param name="directory"><see cref="DirectoryInfo"/> object for the current path.</param>
        /// <param name="action">The <see cref="ScanDirectoryAction"/> action value.</param>
        /// <returns><see langword="true"/> when the scan is allowed to continue. <see langword="false"/> if otherwise;</returns>
        private bool RaiseDirectoryEvent(DirectoryInfo directory, ScanDirectoryAction action)
        {
            bool continueScan = true;

            // Only do something when the event has been declared.
            if (FileEvent != null)
            {
                // Create a new argument object for the file event.
                DirectoryEventArgs args = new DirectoryEventArgs(directory, action);

                // Now raise the event.
                DirectoryEvent(this, args);

                continueScan = !args.Cancel;
            }
            return continueScan;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DirectoryEventArgs"/> class.
        /// </summary>
        /// <param name="directory"><see cref="DirectoryInfo"/> object for the current path.</param>
        /// <param name="action">The action.</param>
        internal DirectoryEventArgs(DirectoryInfo directory, ScanDirectoryAction action)
        {
            if (directory == null) throw new ArgumentNullException("directory");

            // Get File information
            _directoryInfo = directory;
            _action = action;
        }