Sfoglia il codice sorgente

Replace ErrorEventArgs with ExceptionEventArgs

olegkap_cp 14 anni fa
parent
commit
fd22cf21a2

+ 2 - 2
Renci.SshClient/Renci.SshNet/BaseClient.cs

@@ -72,7 +72,7 @@ namespace Renci.SshNet
         /// <summary>
         /// Occurs when an error occurred.
         /// </summary>
-        public event EventHandler<ErrorEventArgs> ErrorOccurred;
+        public event EventHandler<ExceptionEventArgs> ErrorOccurred;
 
         /// <summary>
         /// Initializes a new instance of the <see cref="BaseClient"/> class.
@@ -177,7 +177,7 @@ namespace Renci.SshNet
                 throw new SshConnectionException("Client not connected.");
         }
 
-        private void Session_ErrorOccured(object sender, System.IO.ErrorEventArgs e)
+        private void Session_ErrorOccured(object sender, ExceptionEventArgs e)
         {
             if (this.ErrorOccurred != null)
             {

+ 1 - 1
Renci.SshClient/Renci.SshNet/Channels/Channel.cs

@@ -461,7 +461,7 @@ namespace Renci.SshNet.Channels
             this._disconnectedWaitHandle.Set();
         }
 
-        private void Session_ErrorOccured(object sender, System.IO.ErrorEventArgs e)
+        private void Session_ErrorOccured(object sender, ExceptionEventArgs e)
         {
             this._errorOccuredWaitHandle.Set();
         }

+ 27 - 0
Renci.SshClient/Renci.SshNet/Common/ExceptionEventArgs.cs

@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Renci.SshNet.Common
+{
+    /// <summary>
+    /// Provides data for the <see cref="ErrorOccured"/> event.
+    /// </summary>
+    public class ExceptionEventArgs : EventArgs
+    {
+        /// <summary>
+        /// Gets the System.Exception that represents the error that occurred.
+        /// </summary>
+        public Exception Exception { get; private set; }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ExceptionEventArgs"/> class.
+        /// </summary>
+        /// <param name="exception">An System.Exception that represents the error that occurred.</param>
+        public ExceptionEventArgs(Exception exception)
+        {
+            this.Exception = exception;
+        }
+    }
+}

+ 3 - 3
Renci.SshClient/Renci.SshNet/ForwardedPort.cs

@@ -117,10 +117,10 @@ namespace Renci.SshNet
         /// Handles session ErrorOccured event.
         /// </summary>
         /// <param name="sender">The source of the event.</param>
-        /// <param name="e">The <see cref="System.IO.ErrorEventArgs"/> instance containing the event data.</param>
-        private void Session_ErrorOccured(object sender, System.IO.ErrorEventArgs e)
+        /// <param name="e">The <see cref="ExceptionEventArgs"/> instance containing the event data.</param>
+        private void Session_ErrorOccured(object sender, ExceptionEventArgs e)
         {
-            this.RaiseExceptionEvent(e.GetException());
+            this.RaiseExceptionEvent(e.Exception);
         }
     }
 }

+ 1 - 0
Renci.SshClient/Renci.SshNet/Renci.SshNet.csproj

@@ -73,6 +73,7 @@
     <Compile Include="Common\ChannelEventArgs.cs" />
     <Compile Include="Common\ChannelOpenFailedEventArgs.cs" />
     <Compile Include="Common\ChannelRequestEventArgs.cs" />
+    <Compile Include="Common\ExceptionEventArgs.cs" />
     <Compile Include="Common\PipeStream.cs" />
     <Compile Include="Common\PortForwardEventArgs.cs" />
     <Compile Include="Common\SshAuthenticationException.cs" />

+ 2 - 2
Renci.SshClient/Renci.SshNet/Session.cs

@@ -235,7 +235,7 @@ namespace Renci.SshNet
         /// <summary>
         /// Occurs when an error occurred.
         /// </summary>
-        public event EventHandler<ErrorEventArgs> ErrorOccured;
+        public event EventHandler<ExceptionEventArgs> ErrorOccured;
 
         /// <summary>
         /// Occurs when session has been disconnected form the server.
@@ -1585,7 +1585,7 @@ namespace Renci.SshNet
 
             if (this.ErrorOccured != null)
             {
-                this.ErrorOccured(this, new ErrorEventArgs(exp));
+                this.ErrorOccured(this, new ExceptionEventArgs(exp));
             }
 
             if (connectionException != null && connectionException.DisconnectReason != DisconnectReason.ConnectionLost)

+ 4 - 4
Renci.SshClient/Renci.SshNet/Sftp/SftpSession.cs

@@ -31,7 +31,7 @@ namespace Renci.SshNet.Sftp
 
         private TimeSpan _operationTimeout;
 
-        public event EventHandler<ErrorEventArgs> ErrorOccured;
+        public event EventHandler<ExceptionEventArgs> ErrorOccured;
 
         /// <summary>
         /// Gets remote working directory.
@@ -919,9 +919,9 @@ namespace Renci.SshNet.Sftp
             this.RaiseError(new SshException("Connection was lost"));
         }
 
-        private void Session_ErrorOccured(object sender, ErrorEventArgs e)
+        private void Session_ErrorOccured(object sender, ExceptionEventArgs e)
         {
-            this.RaiseError(e.GetException());
+            this.RaiseError(e.Exception);
         }
 
         private void RaiseError(Exception error)
@@ -932,7 +932,7 @@ namespace Renci.SshNet.Sftp
 
             if (this.ErrorOccured != null)
             {
-                this.ErrorOccured(this, new ErrorEventArgs(error));
+                this.ErrorOccured(this, new ExceptionEventArgs(error));
             }
         }
 

+ 4 - 4
Renci.SshClient/Renci.SshNet/Shell.cs

@@ -75,7 +75,7 @@ namespace Renci.SshNet
         /// <summary>
         /// Occurs when an error occurred.
         /// </summary>
-        public event EventHandler<ErrorEventArgs> ErrorOccurred;
+        public event EventHandler<ExceptionEventArgs> ErrorOccurred;
 
         /// <summary>
         /// Initializes a new instance of the <see cref="Shell"/> class.
@@ -167,7 +167,7 @@ namespace Renci.SshNet
                 }
                 catch (Exception exp)
                 {
-                    this.RaiseError(new ErrorEventArgs(exp));
+                    this.RaiseError(new ExceptionEventArgs(exp));
                 }
             });
 
@@ -196,12 +196,12 @@ namespace Renci.SshNet
             }
         }
 
-        private void Session_ErrorOccured(object sender, ErrorEventArgs e)
+        private void Session_ErrorOccured(object sender, ExceptionEventArgs e)
         {
             this.RaiseError(e);
         }
 
-        private void RaiseError(ErrorEventArgs e)
+        private void RaiseError(ExceptionEventArgs e)
         {
             if (this.ErrorOccurred != null)
             {

+ 2 - 2
Renci.SshClient/Renci.SshNet/SshCommand.cs

@@ -315,9 +315,9 @@ namespace Renci.SshNet
             this._sessionErrorOccuredWaitHandle.Set();
         }
 
-        private void Session_ErrorOccured(object sender, ErrorEventArgs e)
+        private void Session_ErrorOccured(object sender, ExceptionEventArgs e)
         {
-            this._exception = e.GetException();
+            this._exception = e.Exception;
 
             this._sessionErrorOccuredWaitHandle.Set();
         }