Exemplo n.º 1
0
        /// <summary>
        /// Performs a directory deletion.
        /// </summary>
        /// <param name="fileSystem">The file system.</param>
        /// <param name="directory">The directory to delete.</param>
        /// <param name="execute">if set to true, the operation gets executed.</param>
        private void PerformDirectoryDeletionOperation(IFileSystem fileSystem, IDirectoryInfo directory, bool execute)
        {
            var eventArgs = new DirectoryDeletionEventArgs(directory.FullName);

            this.OnDeletingDirectory(eventArgs);

            var directoryScanner = new FileSystemScanner(directory);

            directoryScanner.FileFound += (sender, e) =>
                                          this.OnProceededFile(new FileProceededEventArgs(e.File.FullName, e.File.Length));

            directoryScanner.Start();

            if (execute)
            {
                try
                {
                    fileSystem.DeleteDirectory(directory);

                    this.OnDeletedDirectory(eventArgs);
                }

                catch (AccessException)
                {
                    this.OnDirectoryDeletionError(new DirectoryDeletionEventArgs(directory.FullName));
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Performs a directory deletion.
        /// </summary>
        /// <param name="fileSystem">The file system.</param>
        /// <param name="directory">The directory to delete.</param>
        /// <param name="execute">if set to true, the operation gets executed.</param>
        private void PerformDirectoryDeletionOperation(IFileSystem fileSystem, IDirectoryInfo directory, bool execute)
        {
            var eventArgs = new DirectoryDeletionEventArgs(directory.FullName);

            this.OnDeletingDirectory(eventArgs);

            var directoryScanner = new FileSystemScanner(directory);

            directoryScanner.FileFound += (sender, e) =>
                this.OnProceededFile(new FileProceededEventArgs(e.File.FullName, e.File.Length));

            directoryScanner.Start();

            if (execute)
            {
                try
                {
                    fileSystem.DeleteDirectory(directory);

                    this.OnDeletedDirectory(eventArgs);
                }

                catch (AccessException)
                {
                    this.OnDirectoryDeletionError(new DirectoryDeletionEventArgs(directory.FullName));
                }
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Raises the <see cref="DirectoryDeletionError"/> event.
 /// </summary>
 /// <param name="e">The <see cref="FlagSync.Core.DirectoryDeletionEventArgs"/> instance containing the event data.</param>
 protected virtual void OnDirectoryDeletionError(DirectoryDeletionEventArgs e)
 {
     this.DirectoryDeletionError.RaiseSafe(this, e);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Raises the <see cref="DeletingDirectory"/> event.
 /// </summary>
 /// <param name="e">The <see cref="FlagSync.Core.DirectoryDeletionEventArgs"/> instance containing the event data.</param>
 protected virtual void OnDeletingDirectory(DirectoryDeletionEventArgs e)
 {
     this.DeletingDirectory.RaiseSafe(this, e);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Handles the DeletedDirectory event of the currentJob control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="FlagSync.Core.DirectoryDeletionEventArgs"/> instance containing the event data.</param>
 private void currentJob_DeletedDirectory(object sender, DirectoryDeletionEventArgs e)
 {
     this.DeletedDirectory.RaiseSafe(this, e);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Handles the DeletedDirectory event of the currentJob control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="FlagSync.Core.DirectoryDeletionEventArgs"/> instance containing the event data.</param>
 private void currentJob_DeletedDirectory(object sender, DirectoryDeletionEventArgs e)
 {
     this.DeletedDirectory.RaiseSafe(this, e);
 }
Exemplo n.º 7
0
 /// <summary>
 /// Raises the <see cref="DirectoryDeletionError"/> event.
 /// </summary>
 /// <param name="e">The <see cref="FlagSync.Core.DirectoryDeletionEventArgs"/> instance containing the event data.</param>
 protected virtual void OnDirectoryDeletionError(DirectoryDeletionEventArgs e)
 {
     this.DirectoryDeletionError.RaiseSafe(this, e);
 }
Exemplo n.º 8
0
 /// <summary>
 /// Raises the <see cref="DeletedDirectory"/> event.
 /// </summary>
 /// <param name="e">The <see cref="FlagSync.Core.DirectoryDeletionEventArgs"/> instance containing the event data.</param>
 protected virtual void OnDeletedDirectory(DirectoryDeletionEventArgs e)
 {
     this.DeletedDirectory.RaiseSafe(this, e);
 }