From e7ff062145e9a21c29d221e4ceb856175189fd82 Mon Sep 17 00:00:00 2001 From: Gert Driesen Date: Sat, 22 Nov 2014 17:11:41 +0000 Subject: [PATCH] Remove redundant this qualifier, and fixes general warnings. --- .../Renci.SshNet/AuthenticationMethod.cs | 2 +- .../Channels/ChannelDirectTcpip.NET40.cs | 2 +- .../Channels/ChannelForwardedTcpip.NET40.cs | 10 +- Renci.SshClient/Renci.SshNet/CipherInfo.cs | 4 +- .../Renci.SshNet/Common/ASCIIEncoding.cs | 20 +-- .../Renci.SshNet/Common/AsyncResult.cs | 62 +++---- .../Common/AuthenticationBannerEventArgs.cs | 4 +- .../Common/AuthenticationEventArgs.cs | 4 +- .../Common/AuthenticationPrompt.cs | 6 +- .../Common/AuthenticationPromptEventArgs.cs | 6 +- .../Common/ChannelDataEventArgs.cs | 4 +- .../Renci.SshNet/Common/ChannelEventArgs.cs | 2 +- .../Common/ChannelOpenFailedEventArgs.cs | 6 +- .../Common/ChannelRequestEventArgs.cs | 2 +- .../Renci.SshNet/Common/DerData.cs | 130 +++++++-------- .../Renci.SshNet/Common/ExceptionEventArgs.cs | 2 +- .../Renci.SshNet/Common/Extensions.NET.cs | 4 +- .../Renci.SshNet/Common/Extensions.cs | 31 ++-- .../Renci.SshNet/Common/HostKeyEventArgs.cs | 10 +- .../Common/NetConfServerException.NET40.cs | 2 +- .../Renci.SshNet/Common/ObjectIdentifier.cs | 2 +- .../Common/ProxyException.NET40.cs | 2 +- .../Common/ScpDownloadEventArgs.cs | 6 +- .../Renci.SshNet/Common/ScpException.NET40.cs | 2 +- .../Renci.SshNet/Common/ScpUploadEventArgs.cs | 6 +- .../Renci.SshNet/Common/SemaphoreLight.cs | 24 +-- .../Common/SftpPathNotFoundException.NET40.cs | 2 +- .../SftpPermissionDeniedException.NET40.cs | 2 +- .../Renci.SshNet/Common/ShellDataEventArgs.cs | 4 +- .../SshAuthenticationException.NET40.cs | 2 +- .../Common/SshConnectionException.NET40.cs | 2 +- .../Common/SshConnectionException.cs | 6 +- .../Renci.SshNet/Common/SshData.cs | 141 ++++++++-------- .../Renci.SshNet/Common/SshException.NET40.cs | 2 +- .../SshOperationTimeoutException.NET40.cs | 2 +- ...SshPassPhraseNullOrEmptyException.NET40.cs | 2 +- .../Renci.SshNet/Compression/Compressor.cs | 44 ++--- .../Renci.SshNet/Compression/Zlib.cs | 2 +- .../Renci.SshNet/Compression/ZlibOpenSsh.cs | 10 +- .../Renci.SshNet/ConnectionInfo.cs | 42 ++--- Renci.SshClient/Renci.SshNet/ExpectAction.cs | 8 +- .../Renci.SshNet/ForwardedPortDynamic.NET.cs | 11 +- .../Renci.SshNet/ForwardedPortLocal.NET.cs | 2 +- .../Renci.SshNet/ForwardedPortLocal.cs | 11 +- .../Renci.SshNet/ForwardedPortRemote.cs | 1 - Renci.SshClient/Renci.SshNet/HashInfo.cs | 4 +- .../KeyboardInteractiveConnectionInfo.cs | 8 +- .../Messages/Authentication/BannerMessage.cs | 8 +- .../Messages/Authentication/FailureMessage.cs | 8 +- .../InformationRequestMessage.cs | 16 +- .../InformationResponseMessage.cs | 8 +- .../PasswordChangeRequiredMessage.cs | 8 +- .../Authentication/PublicKeyMessage.cs | 8 +- .../Messages/Authentication/RequestMessage.cs | 14 +- .../Authentication/RequestMessageHost.cs | 20 +-- .../RequestMessageKeyboardInteractive.cs | 8 +- .../Authentication/RequestMessagePassword.cs | 16 +- .../Authentication/RequestMessagePublicKey.cs | 20 +-- .../Messages/Connection/ChannelDataMessage.cs | 8 +- .../Messages/Connection/ChannelEofMessage.cs | 2 +- .../Connection/ChannelExtendedDataMessage.cs | 14 +- .../Connection/ChannelFailureMessage.cs | 2 +- .../Messages/Connection/ChannelMessage.cs | 6 +- .../ChannelOpen/ChannelOpenMessage.cs | 40 ++--- .../ChannelOpen/DirectTcpipChannelInfo.cs | 24 +-- .../ChannelOpen/ForwardedTcpipChannelInfo.cs | 16 +- .../ChannelOpen/X11ChannelOpenInfo.cs | 8 +- .../ChannelOpenConfirmationMessage.cs | 20 +-- .../Connection/ChannelOpenFailureMessage.cs | 18 +- .../ChannelRequest/BreakRequestInfo.cs | 8 +- .../ChannelRequest/ChannelRequestMessage.cs | 14 +- .../ChannelRequest/EndOfWriteRequestInfo.cs | 2 +- .../EnvironmentVariableRequestInfo.cs | 14 +- .../ChannelRequest/ExecRequestInfo.cs | 17 +- .../ChannelRequest/ExitSignalRequestInfo.cs | 26 +-- .../ChannelRequest/ExitStatusRequestInfo.cs | 8 +- .../ChannelRequest/KeepAliveRequestInfo.cs | 2 +- .../ChannelRequest/PseudoTerminalInfo.cs | 38 ++--- .../Connection/ChannelRequest/RequestInfo.cs | 4 +- .../ChannelRequest/ShellRequestInfo.cs | 2 +- .../ChannelRequest/SignalRequestInfo.cs | 8 +- .../ChannelRequest/SubsystemRequestInfo.cs | 8 +- .../ChannelRequest/WindowChangeRequestInfo.cs | 26 +-- .../X11ForwardingRequestInfo.cs | 26 +-- .../ChannelRequest/XonXoffRequestInfo.cs | 8 +- .../Connection/ChannelSuccessMessage.cs | 2 +- .../Connection/ChannelWindowAdjustMessage.cs | 8 +- .../Connection/GlobalRequestMessage.cs | 38 ++--- .../Connection/RequestSuccessMessage.cs | 10 +- .../Renci.SshNet/Messages/Message.cs | 8 +- .../Renci.SshNet/Messages/MessageAttribute.cs | 4 +- .../Messages/Transport/DebugMessage.cs | 12 +- .../Messages/Transport/DisconnectMessage.cs | 17 +- .../Messages/Transport/IgnoreMessage.cs | 8 +- .../KeyExchangeDhGroupExchangeGroup.cs | 8 +- .../KeyExchangeDhGroupExchangeInit.cs | 6 +- .../KeyExchangeDhGroupExchangeReply.cs | 12 +- .../KeyExchangeDhGroupExchangeRequest.cs | 18 +- .../Transport/KeyExchangeDhInitMessage.cs | 8 +- .../Transport/KeyExchangeDhReplyMessage.cs | 14 +- .../Transport/KeyExchangeEcdhInitMessage.cs | 8 +- .../Transport/KeyExchangeEcdhReplyMessage.cs | 14 +- .../Transport/KeyExchangeInitMessage.cs | 60 +++---- .../Transport/ServiceAcceptMessage.cs | 6 +- .../Transport/ServiceRequestMessage.cs | 8 +- Renci.SshClient/Renci.SshNet/NetConfClient.cs | 4 +- .../Renci.SshNet/Netconf/NetConfSession.cs | 2 +- .../Renci.SshNet/NoneAuthenticationMethod.cs | 26 +-- .../PasswordAuthenticationMethod.NET40.cs | 2 +- .../PasswordAuthenticationMethod.cs | 54 +++--- .../Renci.SshNet/PasswordConnectionInfo.cs | 28 ++-- .../PrivateKeyAuthenticationMethod.cs | 70 ++++---- .../Renci.SshNet/PrivateKeyConnectionInfo.cs | 8 +- .../Renci.SshNet/PrivateKeyFile.cs | 32 ++-- Renci.SshClient/Renci.SshNet/ScpClient.NET.cs | 81 ++++----- Renci.SshClient/Renci.SshNet/ScpClient.cs | 80 ++++----- Renci.SshClient/Renci.SshNet/Session.NET40.cs | 10 +- .../Renci.SshNet/Sftp/SftpDataMessage.cs | 9 +- .../Sftp/SftpDownloadAsyncResult.cs | 2 +- Renci.SshClient/Renci.SshNet/Sftp/SftpFile.cs | 114 ++++++------- .../Renci.SshNet/Sftp/SftpFileAttributes.cs | 126 +++++++------- .../Renci.SshNet/Sftp/SftpFileStream.cs | 2 +- .../Sftp/SftpFileSystemInformation.cs | 20 +-- .../Sftp/SftpListDirectoryAsyncResult.cs | 2 +- .../Renci.SshNet/Sftp/SftpMessage.cs | 44 ++--- .../SftpSynchronizeDirectoriesAsyncResult.cs | 2 +- .../Sftp/SftpUploadAsyncResult.cs | 2 +- .../Renci.SshNet/SftpClient.NET.cs | 17 +- Renci.SshClient/Renci.SshNet/SftpClient.cs | 4 +- Renci.SshClient/Renci.SshNet/Shell.cs | 154 +++++++++--------- Renci.SshClient/Renci.SshNet/ShellStream.cs | 6 +- Renci.SshClient/Renci.SshNet/SshClient.cs | 4 +- 132 files changed, 1170 insertions(+), 1170 deletions(-) diff --git a/Renci.SshClient/Renci.SshNet/AuthenticationMethod.cs b/Renci.SshClient/Renci.SshNet/AuthenticationMethod.cs index 264e6e8c..81818028 100644 --- a/Renci.SshClient/Renci.SshNet/AuthenticationMethod.cs +++ b/Renci.SshClient/Renci.SshNet/AuthenticationMethod.cs @@ -37,7 +37,7 @@ namespace Renci.SshNet if (username.IsNullOrWhiteSpace()) throw new ArgumentException("username"); - this.Username = username; + Username = username; } /// diff --git a/Renci.SshClient/Renci.SshNet/Channels/ChannelDirectTcpip.NET40.cs b/Renci.SshClient/Renci.SshNet/Channels/ChannelDirectTcpip.NET40.cs index 1e3f5720..8d51e119 100644 --- a/Renci.SshClient/Renci.SshNet/Channels/ChannelDirectTcpip.NET40.cs +++ b/Renci.SshClient/Renci.SshNet/Channels/ChannelDirectTcpip.NET40.cs @@ -9,7 +9,7 @@ namespace Renci.SshNet.Channels { partial void InternalSocketReceive(byte[] buffer, ref int read) { - read = this._socket.Receive(buffer); + read = _socket.Receive(buffer); } partial void InternalSocketSend(byte[] data) diff --git a/Renci.SshClient/Renci.SshNet/Channels/ChannelForwardedTcpip.NET40.cs b/Renci.SshClient/Renci.SshNet/Channels/ChannelForwardedTcpip.NET40.cs index 3ff238f8..c5182bdc 100644 --- a/Renci.SshClient/Renci.SshNet/Channels/ChannelForwardedTcpip.NET40.cs +++ b/Renci.SshClient/Renci.SshNet/Channels/ChannelForwardedTcpip.NET40.cs @@ -10,19 +10,19 @@ namespace Renci.SshNet.Channels { partial void OpenSocket(IPEndPoint remoteEndpoint) { - this._socket = new Socket(remoteEndpoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp); - this._socket.Connect(remoteEndpoint); - this._socket.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.NoDelay, 1); + _socket = new Socket(remoteEndpoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp); + _socket.Connect(remoteEndpoint); + _socket.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.NoDelay, 1); } partial void InternalSocketReceive(byte[] buffer, ref int read) { - read = this._socket.Receive(buffer); + read = _socket.Receive(buffer); } partial void InternalSocketSend(byte[] data) { - this._socket.Send(data); + _socket.Send(data); } } } diff --git a/Renci.SshClient/Renci.SshNet/CipherInfo.cs b/Renci.SshClient/Renci.SshNet/CipherInfo.cs index ddba7290..9d06dc0c 100644 --- a/Renci.SshClient/Renci.SshNet/CipherInfo.cs +++ b/Renci.SshClient/Renci.SshNet/CipherInfo.cs @@ -29,8 +29,8 @@ namespace Renci.SshNet /// The cipher. public CipherInfo(int keySize, Func cipher) { - this.KeySize = keySize; - this.Cipher = (key, iv) => (cipher(key.Take(this.KeySize / 8).ToArray(), iv)); + KeySize = keySize; + Cipher = (key, iv) => (cipher(key.Take(KeySize / 8).ToArray(), iv)); } } } diff --git a/Renci.SshClient/Renci.SshNet/Common/ASCIIEncoding.cs b/Renci.SshClient/Renci.SshNet/Common/ASCIIEncoding.cs index 0f62a115..eb0f5628 100644 --- a/Renci.SshClient/Renci.SshNet/Common/ASCIIEncoding.cs +++ b/Renci.SshClient/Renci.SshNet/Common/ASCIIEncoding.cs @@ -9,17 +9,17 @@ namespace Renci.SshNet.Common { private readonly char _fallbackChar; - private static readonly char[] _byteToChar; + private static readonly char[] ByteToChar; static ASCIIEncoding() { - if (_byteToChar == null) + if (ByteToChar == null) { - _byteToChar = new char[128]; + ByteToChar = new char[128]; var ch = '\0'; for (byte i = 0; i < 128; i++) { - _byteToChar[i] = ch++; + ByteToChar[i] = ch++; } } } @@ -29,7 +29,7 @@ namespace Renci.SshNet.Common /// public ASCIIEncoding() { - this._fallbackChar = '?'; + _fallbackChar = '?'; } /// @@ -76,12 +76,12 @@ namespace Renci.SshNet.Common /// A fallback occurred (see Understanding Encodings for complete explanation)-and- is set to . public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex) { - for (int i = 0; i < charCount && i < chars.Length; i++) + for (var i = 0; i < charCount && i < chars.Length; i++) { var b = (byte)chars[i + charIndex]; if (b > 127) - b = (byte)this._fallbackChar; + b = (byte) _fallbackChar; bytes[i + byteIndex] = b; } @@ -132,18 +132,18 @@ namespace Renci.SshNet.Common /// A fallback occurred (see Understanding Encodings for complete explanation)-and- is set to . public override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex) { - for (int i = 0; i < byteCount; i++) + for (var i = 0; i < byteCount; i++) { var b = bytes[i + byteIndex]; char ch; if (b > 127) { - ch = this._fallbackChar; + ch = _fallbackChar; } else { - ch = _byteToChar[b]; + ch = ByteToChar[b]; } chars[i + charIndex] = ch; diff --git a/Renci.SshClient/Renci.SshNet/Common/AsyncResult.cs b/Renci.SshClient/Renci.SshNet/Common/AsyncResult.cs index 34008cd7..f49058b3 100644 --- a/Renci.SshClient/Renci.SshNet/Common/AsyncResult.cs +++ b/Renci.SshClient/Renci.SshNet/Common/AsyncResult.cs @@ -14,13 +14,13 @@ namespace Renci.SshNet.Common private readonly Object _asyncState; // Field set at construction which do change after operation completes - private const Int32 _statePending = 0; + private const Int32 StatePending = 0; - private const Int32 _stateCompletedSynchronously = 1; + private const Int32 StateCompletedSynchronously = 1; - private const Int32 _stateCompletedAsynchronously = 2; + private const Int32 StateCompletedAsynchronously = 2; - private Int32 _completedState = _statePending; + private Int32 _completedState = StatePending; // Field that may or may not get set depending on usage private ManualResetEvent _asyncWaitHandle; @@ -41,10 +41,10 @@ namespace Renci.SshNet.Common /// /// The async callback. /// The state. - public AsyncResult(AsyncCallback asyncCallback, Object state) + protected AsyncResult(AsyncCallback asyncCallback, Object state) { - this._asyncCallback = asyncCallback; - this._asyncState = state; + _asyncCallback = asyncCallback; + _asyncState = state; } /// @@ -55,21 +55,21 @@ namespace Renci.SshNet.Common public void SetAsCompleted(Exception exception, Boolean completedSynchronously) { // Passing null for exception means no error occurred; this is the common case - this._exception = exception; + _exception = exception; // The m_CompletedState field MUST be set prior calling the callback - Int32 prevState = Interlocked.Exchange(ref this._completedState, - completedSynchronously ? _stateCompletedSynchronously : _stateCompletedAsynchronously); - if (prevState != _statePending) + var prevState = Interlocked.Exchange(ref _completedState, + completedSynchronously ? StateCompletedSynchronously : StateCompletedAsynchronously); + if (prevState != StatePending) throw new InvalidOperationException("You can set a result only once"); // If the event exists, set it - if (this._asyncWaitHandle != null) - this._asyncWaitHandle.Set(); + if (_asyncWaitHandle != null) + _asyncWaitHandle.Set(); // If a callback method was set, call it - if (this._asyncCallback != null) - this._asyncCallback(this); + if (_asyncCallback != null) + _asyncCallback(this); } /// @@ -78,19 +78,19 @@ namespace Renci.SshNet.Common public void EndInvoke() { // This method assumes that only 1 thread calls EndInvoke for this object - if (!this.IsCompleted) + if (!IsCompleted) { // If the operation isn't done, wait for it AsyncWaitHandle.WaitOne(); AsyncWaitHandle.Close(); - this._asyncWaitHandle = null; // Allow early GC + _asyncWaitHandle = null; // Allow early GC } - this.EndInvokeCalled = true; + EndInvokeCalled = true; // Operation is done: if an exception occurred, throw it - if (this._exception != null) - throw new SshException(this._exception.Message, this._exception); + if (_exception != null) + throw new SshException(_exception.Message, _exception); } #region Implementation of IAsyncResult @@ -99,7 +99,7 @@ namespace Renci.SshNet.Common /// Gets a user-defined object that qualifies or contains information about an asynchronous operation. /// /// A user-defined object that qualifies or contains information about an asynchronous operation. - public Object AsyncState { get { return this._asyncState; } } + public Object AsyncState { get { return _asyncState; } } /// /// Gets a value that indicates whether the asynchronous operation completed synchronously. @@ -107,7 +107,7 @@ namespace Renci.SshNet.Common /// true if the asynchronous operation completed synchronously; otherwise, false. public Boolean CompletedSynchronously { - get { return this._completedState == _stateCompletedSynchronously; } + get { return _completedState == StateCompletedSynchronously; } } /// @@ -118,26 +118,26 @@ namespace Renci.SshNet.Common { get { - if (this._asyncWaitHandle == null) + if (_asyncWaitHandle == null) { - var done = this.IsCompleted; + var done = IsCompleted; var mre = new ManualResetEvent(done); - if (Interlocked.CompareExchange(ref this._asyncWaitHandle, mre, null) != null) + if (Interlocked.CompareExchange(ref _asyncWaitHandle, mre, null) != null) { // Another thread created this object's event; dispose the event we just created mre.Close(); } else { - if (!done && this.IsCompleted) + if (!done && IsCompleted) { // If the operation wasn't done when we created // the event but now it is done, set the event - this._asyncWaitHandle.Set(); + _asyncWaitHandle.Set(); } } } - return this._asyncWaitHandle; + return _asyncWaitHandle; } } @@ -147,7 +147,7 @@ namespace Renci.SshNet.Common /// true if the operation is complete; otherwise, false. public Boolean IsCompleted { - get { return this._completedState != _statePending; } + get { return _completedState != StatePending; } } #endregion } @@ -159,7 +159,7 @@ namespace Renci.SshNet.Common public abstract class AsyncResult : AsyncResult { // Field set when operation completes - private TResult _result = default(TResult); + private TResult _result; /// /// Initializes a new instance of the class. @@ -179,7 +179,7 @@ namespace Renci.SshNet.Common public void SetAsCompleted(TResult result, Boolean completedSynchronously) { // Save the asynchronous operation's result - this._result = result; + _result = result; // Tell the base class that the operation completed successfully (no exception) base.SetAsCompleted(null, completedSynchronously); diff --git a/Renci.SshClient/Renci.SshNet/Common/AuthenticationBannerEventArgs.cs b/Renci.SshClient/Renci.SshNet/Common/AuthenticationBannerEventArgs.cs index 55d32550..8e890544 100644 --- a/Renci.SshClient/Renci.SshNet/Common/AuthenticationBannerEventArgs.cs +++ b/Renci.SshClient/Renci.SshNet/Common/AuthenticationBannerEventArgs.cs @@ -24,8 +24,8 @@ public AuthenticationBannerEventArgs(string username, string message, string language) : base(username) { - this.BannerMessage = message; - this.Language = language; + BannerMessage = message; + Language = language; } } } diff --git a/Renci.SshClient/Renci.SshNet/Common/AuthenticationEventArgs.cs b/Renci.SshClient/Renci.SshNet/Common/AuthenticationEventArgs.cs index eda9630e..fb0a2608 100644 --- a/Renci.SshClient/Renci.SshNet/Common/AuthenticationEventArgs.cs +++ b/Renci.SshClient/Renci.SshNet/Common/AuthenticationEventArgs.cs @@ -16,9 +16,9 @@ namespace Renci.SshNet.Common /// Initializes a new instance of the class. /// /// The username. - public AuthenticationEventArgs(string username) + protected AuthenticationEventArgs(string username) { - this.Username = username; + Username = username; } } } diff --git a/Renci.SshClient/Renci.SshNet/Common/AuthenticationPrompt.cs b/Renci.SshClient/Renci.SshNet/Common/AuthenticationPrompt.cs index acef773f..1d97725a 100644 --- a/Renci.SshClient/Renci.SshNet/Common/AuthenticationPrompt.cs +++ b/Renci.SshClient/Renci.SshNet/Common/AuthenticationPrompt.cs @@ -39,9 +39,9 @@ /// The request. public AuthenticationPrompt(int id, bool isEchoed, string request) { - this.Id = id; - this.IsEchoed = isEchoed; - this.Request = request; + Id = id; + IsEchoed = isEchoed; + Request = request; } } } diff --git a/Renci.SshClient/Renci.SshNet/Common/AuthenticationPromptEventArgs.cs b/Renci.SshClient/Renci.SshNet/Common/AuthenticationPromptEventArgs.cs index 43d7e593..8cdb6693 100644 --- a/Renci.SshClient/Renci.SshNet/Common/AuthenticationPromptEventArgs.cs +++ b/Renci.SshClient/Renci.SshNet/Common/AuthenticationPromptEventArgs.cs @@ -32,9 +32,9 @@ namespace Renci.SshNet.Common public AuthenticationPromptEventArgs(string username, string instruction, string language, IEnumerable prompts) : base(username) { - this.Instruction = instruction; - this.Language = language; - this.Prompts = prompts; + Instruction = instruction; + Language = language; + Prompts = prompts; } } } diff --git a/Renci.SshClient/Renci.SshNet/Common/ChannelDataEventArgs.cs b/Renci.SshClient/Renci.SshNet/Common/ChannelDataEventArgs.cs index 8f220032..5da8ddda 100644 --- a/Renci.SshClient/Renci.SshNet/Common/ChannelDataEventArgs.cs +++ b/Renci.SshClient/Renci.SshNet/Common/ChannelDataEventArgs.cs @@ -23,7 +23,7 @@ public ChannelDataEventArgs(uint channelNumber, byte[] data) : base(channelNumber) { - this.Data = data; + Data = data; } /// @@ -35,7 +35,7 @@ public ChannelDataEventArgs(uint channelNumber, byte[] data, uint dataTypeCode) : this(channelNumber, data) { - this.DataTypeCode = dataTypeCode; + DataTypeCode = dataTypeCode; } } } diff --git a/Renci.SshClient/Renci.SshNet/Common/ChannelEventArgs.cs b/Renci.SshClient/Renci.SshNet/Common/ChannelEventArgs.cs index 085a73ef..e64f7a4f 100644 --- a/Renci.SshClient/Renci.SshNet/Common/ChannelEventArgs.cs +++ b/Renci.SshClient/Renci.SshNet/Common/ChannelEventArgs.cs @@ -18,7 +18,7 @@ namespace Renci.SshNet.Common /// The channel number. public ChannelEventArgs(uint channelNumber) { - this.ChannelNumber = channelNumber; + ChannelNumber = channelNumber; } } } diff --git a/Renci.SshClient/Renci.SshNet/Common/ChannelOpenFailedEventArgs.cs b/Renci.SshClient/Renci.SshNet/Common/ChannelOpenFailedEventArgs.cs index bf7d2219..3080d2d8 100644 --- a/Renci.SshClient/Renci.SshNet/Common/ChannelOpenFailedEventArgs.cs +++ b/Renci.SshClient/Renci.SshNet/Common/ChannelOpenFailedEventArgs.cs @@ -30,9 +30,9 @@ public ChannelOpenFailedEventArgs(uint channelNumber, uint reasonCode, string description, string language) : base(channelNumber) { - this.ReasonCode = reasonCode; - this.Description = description; - this.Language = language; + ReasonCode = reasonCode; + Description = description; + Language = language; } } } diff --git a/Renci.SshClient/Renci.SshNet/Common/ChannelRequestEventArgs.cs b/Renci.SshClient/Renci.SshNet/Common/ChannelRequestEventArgs.cs index 1d390dd9..d973c6b1 100644 --- a/Renci.SshClient/Renci.SshNet/Common/ChannelRequestEventArgs.cs +++ b/Renci.SshClient/Renci.SshNet/Common/ChannelRequestEventArgs.cs @@ -19,7 +19,7 @@ namespace Renci.SshNet.Common /// Request information. public ChannelRequestEventArgs(RequestInfo info) { - this.Info = info; + Info = info; } } } diff --git a/Renci.SshClient/Renci.SshNet/Common/DerData.cs b/Renci.SshClient/Renci.SshNet/Common/DerData.cs index d2840578..b4feba19 100644 --- a/Renci.SshClient/Renci.SshNet/Common/DerData.cs +++ b/Renci.SshClient/Renci.SshNet/Common/DerData.cs @@ -9,17 +9,17 @@ namespace Renci.SshNet.Common /// public class DerData { - private const byte CONSTRUCTED = 0x20; + private const byte Constructed = 0x20; - private const byte BOOLEAN = 0x01; - private const byte INTEGER = 0x02; + private const byte Boolean = 0x01; + private const byte Integer = 0x02; //private const byte BITSTRING = 0x03; - private const byte OCTETSTRING = 0x04; - private const byte NULL = 0x05; - private const byte OBJECTIDENTIFIER = 0x06; + private const byte Octetstring = 0x04; + private const byte Null = 0x05; + private const byte Objectidentifier = 0x06; //private const byte EXTERNAL = 0x08; //private const byte ENUMERATED = 0x0a; - private const byte SEQUENCE = 0x10; + private const byte Sequence = 0x10; //private const byte SEQUENCEOF = 0x10; // for completeness //private const byte SET = 0x11; //private const byte SETOF = 0x11; // for completeness @@ -55,7 +55,7 @@ namespace Renci.SshNet.Common { get { - return this._readerIndex >= this._lastIndex; + return _readerIndex >= _lastIndex; } } @@ -64,7 +64,7 @@ namespace Renci.SshNet.Common /// public DerData() { - this._data = new List(); + _data = new List(); } /// @@ -73,10 +73,10 @@ namespace Renci.SshNet.Common /// DER encoded data. public DerData(byte[] data) { - this._data = new List(data); - var dataType = this.ReadByte(); - var length = this.ReadLength(); - this._lastIndex = this._readerIndex + length; + _data = new List(data); + var dataType = ReadByte(); + var length = ReadLength(); + _lastIndex = _readerIndex + length; } /// @@ -85,13 +85,13 @@ namespace Renci.SshNet.Common /// DER Encoded array. public byte[] Encode() { - var length = this._data.Count(); - var lengthBytes = this.GetLength(length); + var length = _data.Count(); + var lengthBytes = GetLength(length); - this._data.InsertRange(0, lengthBytes); - this._data.Insert(0, CONSTRUCTED | SEQUENCE); + _data.InsertRange(0, lengthBytes); + _data.Insert(0, Constructed | Sequence); - return this._data.ToArray(); + return _data.ToArray(); } /// @@ -100,13 +100,13 @@ namespace Renci.SshNet.Common /// mpint read. public BigInteger ReadBigInteger() { - var type = this.ReadByte(); - if (type != INTEGER) + var type = ReadByte(); + if (type != Integer) throw new InvalidOperationException("Invalid data type, INTEGER(02) is expected."); - var length = this.ReadLength(); + var length = ReadLength(); - var data = this.ReadBytes(length); + var data = ReadBytes(length); return new BigInteger(data.Reverse().ToArray()); } @@ -117,20 +117,20 @@ namespace Renci.SshNet.Common /// int read. public int ReadInteger() { - var type = this.ReadByte(); - if (type != INTEGER) + var type = ReadByte(); + if (type != Integer) throw new InvalidOperationException("Invalid data type, INTEGER(02) is expected."); - var length = this.ReadLength(); + var length = ReadLength(); - var data = this.ReadBytes(length); + var data = ReadBytes(length); if (length > 4) throw new InvalidOperationException("Integer type cannot occupy more then 4 bytes"); var result = 0; var shift = (length - 1) * 8; - for (int i = 0; i < length; i++) + for (var i = 0; i < length; i++) { result |= data[i] << shift; shift -= 8; @@ -147,9 +147,9 @@ namespace Renci.SshNet.Common /// UInt32 data to write. public void Write(bool data) { - this._data.Add(BOOLEAN); - this._data.Add(1); - this._data.Add((byte)(data ? 1 : 0)); + _data.Add(Boolean); + _data.Add(1); + _data.Add((byte)(data ? 1 : 0)); } /// @@ -159,10 +159,10 @@ namespace Renci.SshNet.Common public void Write(UInt32 data) { var bytes = data.GetBytes(); - this._data.Add(INTEGER); - var length = this.GetLength(bytes.Length); - this.WriteBytes(length); - this.WriteBytes(bytes); + _data.Add(Integer); + var length = GetLength(bytes.Length); + WriteBytes(length); + WriteBytes(bytes); } /// @@ -172,10 +172,10 @@ namespace Renci.SshNet.Common public void Write(BigInteger data) { var bytes = data.ToByteArray().Reverse().ToList(); - this._data.Add(INTEGER); - var length = this.GetLength(bytes.Count); - this.WriteBytes(length); - this.WriteBytes(bytes); + _data.Add(Integer); + var length = GetLength(bytes.Count); + WriteBytes(length); + WriteBytes(bytes); } /// @@ -184,10 +184,10 @@ namespace Renci.SshNet.Common /// The data. public void Write(byte[] data) { - this._data.Add(OCTETSTRING); - var length = this.GetLength(data.Length); - this.WriteBytes(length); - this.WriteBytes(data); + _data.Add(Octetstring); + var length = GetLength(data.Length); + WriteBytes(length); + WriteBytes(data); } /// @@ -212,23 +212,23 @@ namespace Renci.SshNet.Common { buffer[bufferIndex] = current; if (bufferIndex < buffer.Length - 1) - buffer[bufferIndex] |= (byte)0x80; + buffer[bufferIndex] |= 0x80; item >>= 7; current = (byte)(item & 0x7F); bufferIndex--; } while (current > 0); - for (int i = bufferIndex + 1; i < buffer.Length; i++) + for (var i = bufferIndex + 1; i < buffer.Length; i++) { bytes.Add(buffer[i]); } } - this._data.Add(OBJECTIDENTIFIER); - var length = this.GetLength(bytes.Count); - this.WriteBytes(length); - this.WriteBytes(bytes); + _data.Add(Objectidentifier); + var length = GetLength(bytes.Count); + WriteBytes(length); + WriteBytes(bytes); } /// @@ -236,8 +236,8 @@ namespace Renci.SshNet.Common /// public void WriteNull() { - this._data.Add(NULL); - this._data.Add(0); + _data.Add(Null); + _data.Add(0); } /// @@ -247,15 +247,15 @@ namespace Renci.SshNet.Common public void Write(DerData data) { var bytes = data.Encode(); - this._data.AddRange(bytes); + _data.AddRange(bytes); } - private byte[] GetLength(int length) + private static IEnumerable GetLength(int length) { if (length > 127) { - int size = 1; - int val = length; + var size = 1; + var val = length; while ((val >>= 8) != 0) size++; @@ -270,12 +270,12 @@ namespace Renci.SshNet.Common return data; } - return new byte[] { (byte)length }; + return new[] {(byte) length}; } private int ReadLength() { - int length = this.ReadByte(); + int length = ReadByte(); if (length == 0x80) { @@ -284,16 +284,16 @@ namespace Renci.SshNet.Common if (length > 127) { - int size = length & 0x7f; + var size = length & 0x7f; // Note: The invalid long form "0xff" (see X.690 8.1.3.5c) will be caught here if (size > 4) throw new InvalidOperationException(string.Format("DER length is '{0}' and cannot be more than 4 bytes.", size)); length = 0; - for (int i = 0; i < size; i++) + for (var i = 0; i < size; i++) { - int next = this.ReadByte(); + int next = ReadByte(); length = (length << 8) + next; } @@ -310,25 +310,25 @@ namespace Renci.SshNet.Common private void WriteBytes(IEnumerable data) { - this._data.AddRange(data); + _data.AddRange(data); } private byte ReadByte() { - if (this._readerIndex > this._data.Count) + if (_readerIndex > _data.Count) throw new InvalidOperationException("Read out of boundaries."); - return this._data[this._readerIndex++]; + return _data[_readerIndex++]; } private byte[] ReadBytes(int length) { - if (this._readerIndex + length > this._data.Count) + if (_readerIndex + length > _data.Count) throw new InvalidOperationException("Read out of boundaries."); var result = new byte[length]; - this._data.CopyTo(this._readerIndex, result, 0, length); - this._readerIndex += length; + _data.CopyTo(_readerIndex, result, 0, length); + _readerIndex += length; return result; } } diff --git a/Renci.SshClient/Renci.SshNet/Common/ExceptionEventArgs.cs b/Renci.SshClient/Renci.SshNet/Common/ExceptionEventArgs.cs index e2ff4a76..9530b244 100644 --- a/Renci.SshClient/Renci.SshNet/Common/ExceptionEventArgs.cs +++ b/Renci.SshClient/Renci.SshNet/Common/ExceptionEventArgs.cs @@ -18,7 +18,7 @@ namespace Renci.SshNet.Common /// An System.Exception that represents the error that occurred. public ExceptionEventArgs(Exception exception) { - this.Exception = exception; + Exception = exception; } } } diff --git a/Renci.SshClient/Renci.SshNet/Common/Extensions.NET.cs b/Renci.SshClient/Renci.SshNet/Common/Extensions.NET.cs index fc3c18d8..5c5319e5 100644 --- a/Renci.SshClient/Renci.SshNet/Common/Extensions.NET.cs +++ b/Renci.SshClient/Renci.SshNet/Common/Extensions.NET.cs @@ -2,12 +2,12 @@ using System.Linq; using System.Net; using System.Net.Sockets; -namespace Renci.SshNet +namespace Renci.SshNet.Common { /// /// Collection of different extension method specific for .NET 4.0 /// - public static partial class Extensions + internal static partial class Extensions { /// /// Determines whether [is null or white space] [the specified value]. diff --git a/Renci.SshClient/Renci.SshNet/Common/Extensions.cs b/Renci.SshClient/Renci.SshNet/Common/Extensions.cs index dba598dc..a9a010a5 100644 --- a/Renci.SshClient/Renci.SshNet/Common/Extensions.cs +++ b/Renci.SshClient/Renci.SshNet/Common/Extensions.cs @@ -1,16 +1,15 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Diagnostics; -using System; using System.Globalization; -using System.Text.RegularExpressions; using System.Net; -namespace Renci.SshNet +namespace Renci.SshNet.Common { /// /// Collection of different extension method /// - public static partial class Extensions + internal static partial class Extensions { /// /// Checks whether a collection is the same as another collection @@ -34,8 +33,8 @@ namespace Renci.SshNet var enumerator1 = value.GetEnumerator(); var enumerator2 = compareList.GetEnumerator(); - bool enum1HasValue = enumerator1.MoveNext(); - bool enum2HasValue = enumerator2.MoveNext(); + var enum1HasValue = enumerator1.MoveNext(); + var enum2HasValue = enumerator2.MoveNext(); try { @@ -94,7 +93,7 @@ namespace Renci.SshNet /// Data without leading zeros. internal static IEnumerable TrimLeadingZero(this IEnumerable data) { - bool leadingZero = true; + var leadingZero = true; foreach (var item in data) { if (item == 0 & leadingZero) @@ -127,7 +126,7 @@ namespace Renci.SshNet /// An array of bytes with length 2. internal static byte[] GetBytes(this UInt16 value) { - return new byte[] { (byte)(value >> 8), (byte)(value & 0xFF) }; + return new[] {(byte) (value >> 8), (byte) (value & 0xFF)}; } /// @@ -137,7 +136,7 @@ namespace Renci.SshNet /// An array of bytes with length 4. internal static byte[] GetBytes(this UInt32 value) { - return new byte[] { (byte)(value >> 24), (byte)(value >> 16), (byte)(value >> 8), (byte)(value & 0xFF) }; + return new[] {(byte) (value >> 24), (byte) (value >> 16), (byte) (value >> 8), (byte) (value & 0xFF)}; } /// @@ -147,7 +146,11 @@ namespace Renci.SshNet /// An array of bytes with length 8. internal static byte[] GetBytes(this UInt64 value) { - return new byte[] { (byte)(value >> 56), (byte)(value >> 48), (byte)(value >> 40), (byte)(value >> 32), (byte)(value >> 24), (byte)(value >> 16), (byte)(value >> 8), (byte)(value & 0xFF) }; + return new[] + { + (byte) (value >> 56), (byte) (value >> 48), (byte) (value >> 40), (byte) (value >> 32), + (byte) (value >> 24), (byte) (value >> 16), (byte) (value >> 8), (byte) (value & 0xFF) + }; } /// @@ -157,7 +160,11 @@ namespace Renci.SshNet /// An array of bytes with length 8. internal static byte[] GetBytes(this Int64 value) { - return new byte[] { (byte)(value >> 56), (byte)(value >> 48), (byte)(value >> 40), (byte)(value >> 32), (byte)(value >> 24), (byte)(value >> 16), (byte)(value >> 8), (byte)(value & 0xFF) }; + return new[] + { + (byte) (value >> 56), (byte) (value >> 48), (byte) (value >> 40), (byte) (value >> 32), + (byte) (value >> 24), (byte) (value >> 16), (byte) (value >> 8), (byte) (value & 0xFF) + }; } internal static void ValidatePort(this uint value, string argument) diff --git a/Renci.SshClient/Renci.SshNet/Common/HostKeyEventArgs.cs b/Renci.SshClient/Renci.SshNet/Common/HostKeyEventArgs.cs index 004133af..28219ce6 100644 --- a/Renci.SshClient/Renci.SshNet/Common/HostKeyEventArgs.cs +++ b/Renci.SshClient/Renci.SshNet/Common/HostKeyEventArgs.cs @@ -46,17 +46,17 @@ namespace Renci.SshNet.Common /// The host. public HostKeyEventArgs(KeyHostAlgorithm host) { - this.CanTrust = true; // Set default value + CanTrust = true; // Set default value - this.HostKey = host.Data; + HostKey = host.Data; - this.HostKeyName = host.Name; + HostKeyName = host.Name; - this.KeyLength = host.Key.KeyLength; + KeyLength = host.Key.KeyLength; using (var md5 = new MD5Hash()) { - this.FingerPrint = md5.ComputeHash(host.Data); + FingerPrint = md5.ComputeHash(host.Data); } } } diff --git a/Renci.SshClient/Renci.SshNet/Common/NetConfServerException.NET40.cs b/Renci.SshClient/Renci.SshNet/Common/NetConfServerException.NET40.cs index 081d687e..2fa15a5d 100644 --- a/Renci.SshClient/Renci.SshNet/Common/NetConfServerException.NET40.cs +++ b/Renci.SshClient/Renci.SshNet/Common/NetConfServerException.NET40.cs @@ -7,7 +7,7 @@ namespace Renci.SshNet.Common /// The exception that is thrown when there is something wrong with the server capabilities. /// [Serializable] - public partial class NetConfServerException : SshException + public partial class NetConfServerException { /// /// Initializes a new instance of the class. diff --git a/Renci.SshClient/Renci.SshNet/Common/ObjectIdentifier.cs b/Renci.SshClient/Renci.SshNet/Common/ObjectIdentifier.cs index f2f87479..e1d51d94 100644 --- a/Renci.SshClient/Renci.SshNet/Common/ObjectIdentifier.cs +++ b/Renci.SshClient/Renci.SshNet/Common/ObjectIdentifier.cs @@ -22,7 +22,7 @@ namespace Renci.SshNet.Common if (identifiers.Length < 2) throw new ArgumentException("identifiers"); - this.Identifiers = identifiers; + Identifiers = identifiers; } } } diff --git a/Renci.SshClient/Renci.SshNet/Common/ProxyException.NET40.cs b/Renci.SshClient/Renci.SshNet/Common/ProxyException.NET40.cs index 74c6b8fe..4dae4582 100644 --- a/Renci.SshClient/Renci.SshNet/Common/ProxyException.NET40.cs +++ b/Renci.SshClient/Renci.SshNet/Common/ProxyException.NET40.cs @@ -4,7 +4,7 @@ using System.Runtime.Serialization; namespace Renci.SshNet.Common { [Serializable] - public partial class ProxyException : SshException + public partial class ProxyException { /// /// Initializes a new instance of the class. diff --git a/Renci.SshClient/Renci.SshNet/Common/ScpDownloadEventArgs.cs b/Renci.SshClient/Renci.SshNet/Common/ScpDownloadEventArgs.cs index 38a8cbcc..ae72e731 100644 --- a/Renci.SshClient/Renci.SshNet/Common/ScpDownloadEventArgs.cs +++ b/Renci.SshClient/Renci.SshNet/Common/ScpDownloadEventArgs.cs @@ -30,9 +30,9 @@ namespace Renci.SshNet.Common /// The number of downloaded bytes so far. public ScpDownloadEventArgs(string filename, long size, long downloaded) { - this.Filename = filename; - this.Size = size; - this.Downloaded = downloaded; + Filename = filename; + Size = size; + Downloaded = downloaded; } } } diff --git a/Renci.SshClient/Renci.SshNet/Common/ScpException.NET40.cs b/Renci.SshClient/Renci.SshNet/Common/ScpException.NET40.cs index 3d95c6d9..151469a0 100644 --- a/Renci.SshClient/Renci.SshNet/Common/ScpException.NET40.cs +++ b/Renci.SshClient/Renci.SshNet/Common/ScpException.NET40.cs @@ -4,7 +4,7 @@ using System.Runtime.Serialization; namespace Renci.SshNet.Common { [Serializable] - public partial class ScpException : SshException + public partial class ScpException { /// /// Initializes a new instance of the class. diff --git a/Renci.SshClient/Renci.SshNet/Common/ScpUploadEventArgs.cs b/Renci.SshClient/Renci.SshNet/Common/ScpUploadEventArgs.cs index eada16e3..18e5522c 100644 --- a/Renci.SshClient/Renci.SshNet/Common/ScpUploadEventArgs.cs +++ b/Renci.SshClient/Renci.SshNet/Common/ScpUploadEventArgs.cs @@ -30,9 +30,9 @@ namespace Renci.SshNet.Common /// The number of uploaded bytes so far. public ScpUploadEventArgs(string filename, long size, long uploaded) { - this.Filename = filename; - this.Size = size; - this.Uploaded = uploaded; + Filename = filename; + Size = size; + Uploaded = uploaded; } } } diff --git a/Renci.SshClient/Renci.SshNet/Common/SemaphoreLight.cs b/Renci.SshClient/Renci.SshNet/Common/SemaphoreLight.cs index 153ec575..943c7310 100644 --- a/Renci.SshClient/Renci.SshNet/Common/SemaphoreLight.cs +++ b/Renci.SshClient/Renci.SshNet/Common/SemaphoreLight.cs @@ -23,13 +23,13 @@ namespace Renci.SshNet.Common if (initialCount < 0 ) throw new ArgumentOutOfRangeException("initialCount", "The value cannot be negative."); - this._currentCount = initialCount; + _currentCount = initialCount; } /// /// Gets the current count of the . /// - public int CurrentCount { get { return this._currentCount; } } + public int CurrentCount { get { return _currentCount; } } /// /// Exits the once. @@ -37,7 +37,7 @@ namespace Renci.SshNet.Common /// The previous count of the . public int Release() { - return this.Release(1); + return Release(1); } /// @@ -47,13 +47,13 @@ namespace Renci.SshNet.Common /// The previous count of the . public int Release(int releaseCount) { - var oldCount = this._currentCount; + var oldCount = _currentCount; - lock (this._lock) + lock (_lock) { - this._currentCount += releaseCount; + _currentCount += releaseCount; - Monitor.Pulse(this._lock); + Monitor.Pulse(_lock); } return oldCount; @@ -65,16 +65,16 @@ namespace Renci.SshNet.Common public void Wait() { - lock (this._lock) + lock (_lock) { - while (this._currentCount < 1) + while (_currentCount < 1) { - Monitor.Wait(this._lock); + Monitor.Wait(_lock); } - this._currentCount--; + _currentCount--; - Monitor.Pulse(this._lock); + Monitor.Pulse(_lock); } } } diff --git a/Renci.SshClient/Renci.SshNet/Common/SftpPathNotFoundException.NET40.cs b/Renci.SshClient/Renci.SshNet/Common/SftpPathNotFoundException.NET40.cs index cc3f6e08..e68aea9f 100644 --- a/Renci.SshClient/Renci.SshNet/Common/SftpPathNotFoundException.NET40.cs +++ b/Renci.SshClient/Renci.SshNet/Common/SftpPathNotFoundException.NET40.cs @@ -7,7 +7,7 @@ namespace Renci.SshNet.Common /// The exception that is thrown when file or directory is not found. /// [Serializable] - public partial class SftpPathNotFoundException : SshException + public partial class SftpPathNotFoundException { /// /// Initializes a new instance of the class. diff --git a/Renci.SshClient/Renci.SshNet/Common/SftpPermissionDeniedException.NET40.cs b/Renci.SshClient/Renci.SshNet/Common/SftpPermissionDeniedException.NET40.cs index 144f2c87..fc7ad9dd 100644 --- a/Renci.SshClient/Renci.SshNet/Common/SftpPermissionDeniedException.NET40.cs +++ b/Renci.SshClient/Renci.SshNet/Common/SftpPermissionDeniedException.NET40.cs @@ -7,7 +7,7 @@ namespace Renci.SshNet.Common /// The exception that is thrown when operation permission is denied. /// [Serializable] - public partial class SftpPermissionDeniedException : SshException + public partial class SftpPermissionDeniedException { /// /// Initializes a new instance of the class. diff --git a/Renci.SshClient/Renci.SshNet/Common/ShellDataEventArgs.cs b/Renci.SshClient/Renci.SshNet/Common/ShellDataEventArgs.cs index e2e1863c..703ea22b 100644 --- a/Renci.SshClient/Renci.SshNet/Common/ShellDataEventArgs.cs +++ b/Renci.SshClient/Renci.SshNet/Common/ShellDataEventArgs.cs @@ -23,7 +23,7 @@ namespace Renci.SshNet.Common /// The data. public ShellDataEventArgs(byte[] data) { - this.Data = data; + Data = data; } /// @@ -32,7 +32,7 @@ namespace Renci.SshNet.Common /// The line. public ShellDataEventArgs(string line) { - this.Line = line; + Line = line; } } } diff --git a/Renci.SshClient/Renci.SshNet/Common/SshAuthenticationException.NET40.cs b/Renci.SshClient/Renci.SshNet/Common/SshAuthenticationException.NET40.cs index 47266b83..fa484998 100644 --- a/Renci.SshClient/Renci.SshNet/Common/SshAuthenticationException.NET40.cs +++ b/Renci.SshClient/Renci.SshNet/Common/SshAuthenticationException.NET40.cs @@ -7,7 +7,7 @@ namespace Renci.SshNet.Common /// The exception that is thrown when authentication failed. /// [Serializable] - public partial class SshAuthenticationException : SshException + public partial class SshAuthenticationException { /// /// Initializes a new instance of the class. diff --git a/Renci.SshClient/Renci.SshNet/Common/SshConnectionException.NET40.cs b/Renci.SshClient/Renci.SshNet/Common/SshConnectionException.NET40.cs index 8f9a8aab..dee1aa01 100644 --- a/Renci.SshClient/Renci.SshNet/Common/SshConnectionException.NET40.cs +++ b/Renci.SshClient/Renci.SshNet/Common/SshConnectionException.NET40.cs @@ -7,7 +7,7 @@ namespace Renci.SshNet.Common /// The exception that is thrown when connection was terminated. /// [Serializable] - public partial class SshConnectionException : SshException + public partial class SshConnectionException { /// /// Initializes a new instance of the class. diff --git a/Renci.SshClient/Renci.SshNet/Common/SshConnectionException.cs b/Renci.SshClient/Renci.SshNet/Common/SshConnectionException.cs index dd74d427..f09d8e62 100644 --- a/Renci.SshClient/Renci.SshNet/Common/SshConnectionException.cs +++ b/Renci.SshClient/Renci.SshNet/Common/SshConnectionException.cs @@ -27,7 +27,7 @@ namespace Renci.SshNet.Common public SshConnectionException(string message) : base(message) { - this.DisconnectReason = DisconnectReason.None; + DisconnectReason = DisconnectReason.None; } /// @@ -38,7 +38,7 @@ namespace Renci.SshNet.Common public SshConnectionException(string message, DisconnectReason disconnectReasonCode) : base(message) { - this.DisconnectReason = disconnectReasonCode; + DisconnectReason = disconnectReasonCode; } /// @@ -50,7 +50,7 @@ namespace Renci.SshNet.Common public SshConnectionException(string message, DisconnectReason disconnectReasonCode, Exception inner) : base(message, inner) { - this.DisconnectReason = disconnectReasonCode; + DisconnectReason = disconnectReasonCode; } /// diff --git a/Renci.SshClient/Renci.SshNet/Common/SshData.cs b/Renci.SshClient/Renci.SshNet/Common/SshData.cs index 9e5d2bd0..f843a813 100644 --- a/Renci.SshClient/Renci.SshNet/Common/SshData.cs +++ b/Renci.SshClient/Renci.SshNet/Common/SshData.cs @@ -11,12 +11,12 @@ namespace Renci.SshNet.Common /// public abstract class SshData { - private static readonly Encoding _ascii = new ASCIIEncoding(); + private static readonly Encoding Ascii = new ASCIIEncoding(); #if SILVERLIGHT - private static readonly Encoding _utf8 = Encoding.UTF8; + private static readonly Encoding Utf8 = Encoding.UTF8; #else - private static readonly Encoding _utf8 = Encoding.Default; + private static readonly Encoding Utf8 = Encoding.Default; #endif /// @@ -36,7 +36,7 @@ namespace Renci.SshNet.Common { get { - return this._readerIndex >= this._data.Count(); + return _readerIndex >= _data.Count(); } } @@ -62,17 +62,17 @@ namespace Renci.SshNet.Common /// Byte array representation of data structure. public virtual byte[] GetBytes() { - this._data = new List(); + _data = new List(); - this.SaveData(); + SaveData(); - return this._data.ToArray(); + return _data.ToArray(); } internal T OfType() where T : SshData, new() { var result = new T(); - result.LoadBytes(this._loadedData); + result.LoadBytes(_loadedData); result.LoadData(); return result; } @@ -87,8 +87,8 @@ namespace Renci.SshNet.Common if (value == null) throw new ArgumentNullException("value"); - this.LoadBytes(value); - this.LoadData(); + LoadBytes(value); + LoadData(); } /// @@ -113,9 +113,9 @@ namespace Renci.SshNet.Common if (bytes == null) throw new ArgumentNullException("bytes"); - this.ResetReader(); - this._loadedData = bytes; - this._data = new List(bytes); + ResetReader(); + _loadedData = bytes; + _data = new List(bytes); } /// @@ -123,7 +123,7 @@ namespace Renci.SshNet.Common /// protected void ResetReader() { - this._readerIndex = this.ZeroReaderIndex; // Set to 1 to skip first byte which specifies message type + _readerIndex = ZeroReaderIndex; // Set to 1 to skip first byte which specifies message type } /// @@ -132,8 +132,8 @@ namespace Renci.SshNet.Common /// An array of bytes containing the remaining data in the internal buffer. protected byte[] ReadBytes() { - var data = new byte[this._data.Count - this._readerIndex]; - this._data.CopyTo(this._readerIndex, data, 0, data.Length); + var data = new byte[_data.Count - _readerIndex]; + _data.CopyTo(_readerIndex, data, 0, data.Length); return data; } @@ -148,12 +148,12 @@ namespace Renci.SshNet.Common // Note that this also prevents allocating non-relevant lengths, such as if length is greater than _data.Count but less than int.MaxValue. // For the nerds, the condition translates to: if (length > data.Count && length < int.MaxValue) // Which probably would cause all sorts of exception, most notably OutOfMemoryException. - if (length > this._data.Count) + if (length > _data.Count) throw new ArgumentOutOfRangeException("length"); var result = new byte[length]; - this._data.CopyTo(this._readerIndex, result, 0, length); - this._readerIndex += length; + _data.CopyTo(_readerIndex, result, 0, length); + _readerIndex += length; return result; } @@ -163,7 +163,7 @@ namespace Renci.SshNet.Common /// Byte read. protected byte ReadByte() { - return this.ReadBytes(1).FirstOrDefault(); + return ReadBytes(1).FirstOrDefault(); } /// @@ -172,16 +172,16 @@ namespace Renci.SshNet.Common /// Boolean read. protected bool ReadBoolean() { - return this.ReadByte() == 0 ? false : true; + return ReadByte() != 0; } /// /// Reads next uint16 data type from internal buffer. /// /// uint16 read - protected UInt16 ReadUInt16() + protected ushort ReadUInt16() { - var data = this.ReadBytes(2); + var data = ReadBytes(2); return (ushort)(data[0] << 8 | data[1]); } @@ -189,9 +189,9 @@ namespace Renci.SshNet.Common /// Reads next uint32 data type from internal buffer. /// /// uint32 read - protected UInt32 ReadUInt32() + protected uint ReadUInt32() { - var data = this.ReadBytes(4); + var data = ReadBytes(4); return (uint)(data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3]); } @@ -199,20 +199,22 @@ namespace Renci.SshNet.Common /// Reads next uint64 data type from internal buffer. /// /// uint64 read - protected UInt64 ReadUInt64() + protected ulong ReadUInt64() { - var data = this.ReadBytes(8); - return ((ulong)data[0] << 56 | (ulong)data[1] << 48 | (ulong)data[2] << 40 | (ulong)data[3] << 32 | (ulong)data[4] << 24 | (ulong)data[5] << 16 | (ulong)data[6] << 8 | data[7]); + var data = ReadBytes(8); + return ((ulong) data[0] << 56 | (ulong) data[1] << 48 | (ulong) data[2] << 40 | (ulong) data[3] << 32 | + (ulong) data[4] << 24 | (ulong) data[5] << 16 | (ulong) data[6] << 8 | data[7]); } /// /// Reads next int64 data type from internal buffer. /// /// int64 read - protected Int64 ReadInt64() + protected long ReadInt64() { - var data = this.ReadBytes(8); - return (int)(data[0] << 56 | data[1] << 48 | data[2] << 40 | data[3] << 32 | data[4] << 24 | data[5] << 16 | data[6] << 8 | data[7]); + var data = ReadBytes(8); + return data[0] << 56 | data[1] << 48 | data[2] << 40 | data[3] << 32 | data[4] << 24 | data[5] << 16 | + data[6] << 8 | data[7]; } /// @@ -221,13 +223,13 @@ namespace Renci.SshNet.Common /// string read protected string ReadAsciiString() { - var length = this.ReadUInt32(); + var length = ReadUInt32(); - if (length > (uint)int.MaxValue) + if (length > int.MaxValue) { throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Strings longer than {0} is not supported.", int.MaxValue)); } - return _ascii.GetString(this.ReadBytes((int)length), 0, (int)length); + return Ascii.GetString(ReadBytes((int)length), 0, (int)length); } /// @@ -236,7 +238,7 @@ namespace Renci.SshNet.Common /// string read protected string ReadString() { - return this.ReadString(SshData._utf8); + return ReadString(Utf8); } /// @@ -245,13 +247,13 @@ namespace Renci.SshNet.Common /// string read protected string ReadString(Encoding encoding) { - var length = this.ReadUInt32(); + var length = ReadUInt32(); - if (length > (uint)int.MaxValue) + if (length > int.MaxValue) { throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Strings longer than {0} is not supported.", int.MaxValue)); } - return encoding.GetString(this.ReadBytes((int)length), 0, (int)length); + return encoding.GetString(ReadBytes((int)length), 0, (int)length); } @@ -261,14 +263,14 @@ namespace Renci.SshNet.Common /// string read protected byte[] ReadBinaryString() { - var length = this.ReadUInt32(); + var length = ReadUInt32(); - if (length > (uint)int.MaxValue) + if (length > int.MaxValue) { throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Strings longer than {0} is not supported.", int.MaxValue)); } - return this.ReadBytes((int)length); + return ReadBytes((int)length); } /// @@ -277,9 +279,9 @@ namespace Renci.SshNet.Common /// mpint read. protected BigInteger ReadBigInt() { - var length = this.ReadUInt32(); + var length = ReadUInt32(); - var data = this.ReadBytes((int)length); + var data = ReadBytes((int)length); return new BigInteger(data.Reverse().ToArray()); } @@ -290,7 +292,7 @@ namespace Renci.SshNet.Common /// String array or read data.. protected string[] ReadNamesList() { - var namesList = this.ReadString(); + var namesList = ReadString(); return namesList.Split(','); } @@ -300,11 +302,11 @@ namespace Renci.SshNet.Common /// Extensions pair dictionary. protected IDictionary ReadExtensionPair() { - Dictionary result = new Dictionary(); - while (this._readerIndex < this._data.Count) + var result = new Dictionary(); + while (_readerIndex < _data.Count) { - var extensionName = this.ReadString(); - var extensionData = this.ReadString(); + var extensionName = ReadString(); + var extensionData = ReadString(); result.Add(extensionName, extensionData); } return result; @@ -317,7 +319,7 @@ namespace Renci.SshNet.Common /// is null. protected void Write(IEnumerable data) { - this._data.AddRange(data); + _data.AddRange(data); } /// @@ -326,7 +328,7 @@ namespace Renci.SshNet.Common /// Byte data to write. protected void Write(byte data) { - this._data.Add(data); + _data.Add(data); } /// @@ -335,14 +337,7 @@ namespace Renci.SshNet.Common /// Boolean data to write. protected void Write(bool data) { - if (data) - { - this.Write(1); - } - else - { - this.Write(0); - } + Write(data ? 1 : 0); } /// @@ -351,7 +346,7 @@ namespace Renci.SshNet.Common /// uint16 data to write. protected void Write(UInt16 data) { - this.Write(data.GetBytes()); + Write(data.GetBytes()); } /// @@ -360,7 +355,7 @@ namespace Renci.SshNet.Common /// uint32 data to write. protected void Write(UInt32 data) { - this.Write(data.GetBytes()); + Write(data.GetBytes()); } /// @@ -369,7 +364,7 @@ namespace Renci.SshNet.Common /// uint64 data to write. protected void Write(UInt64 data) { - this.Write(data.GetBytes()); + Write(data.GetBytes()); } /// @@ -378,7 +373,7 @@ namespace Renci.SshNet.Common /// int64 data to write. protected void Write(Int64 data) { - this.Write(data.GetBytes()); + Write(data.GetBytes()); } @@ -388,7 +383,7 @@ namespace Renci.SshNet.Common /// string data to write. protected void WriteAscii(string data) { - this.Write(data, SshData._ascii); + Write(data, Ascii); } /// @@ -398,7 +393,7 @@ namespace Renci.SshNet.Common /// is null. protected void Write(string data) { - this.Write(data, SshData._utf8); + Write(data, Utf8); } /// @@ -416,8 +411,8 @@ namespace Renci.SshNet.Common throw new ArgumentNullException("encoding"); var bytes = encoding.GetBytes(data); - this.Write((uint)bytes.Length); - this.Write(bytes); + Write((uint)bytes.Length); + Write(bytes); } /// @@ -430,8 +425,8 @@ namespace Renci.SshNet.Common if (data == null) throw new ArgumentNullException("data"); - this.Write((uint)data.Length); - this._data.AddRange(data); + Write((uint)data.Length); + _data.AddRange(data); } /// @@ -441,8 +436,8 @@ namespace Renci.SshNet.Common protected void Write(BigInteger data) { var bytes = data.ToByteArray().Reverse().ToList(); - this.Write((uint)bytes.Count); - this.Write(bytes); + Write((uint)bytes.Count); + Write(bytes); } /// @@ -451,7 +446,7 @@ namespace Renci.SshNet.Common /// name-list data to write. protected void Write(string[] data) { - this.WriteAscii(string.Join(",", data)); + WriteAscii(string.Join(",", data)); } /// @@ -462,8 +457,8 @@ namespace Renci.SshNet.Common { foreach (var item in data) { - this.WriteAscii(item.Key); - this.WriteAscii(item.Value); + WriteAscii(item.Key); + WriteAscii(item.Value); } } } diff --git a/Renci.SshClient/Renci.SshNet/Common/SshException.NET40.cs b/Renci.SshClient/Renci.SshNet/Common/SshException.NET40.cs index fa4e2fe3..df1ee759 100644 --- a/Renci.SshClient/Renci.SshNet/Common/SshException.NET40.cs +++ b/Renci.SshClient/Renci.SshNet/Common/SshException.NET40.cs @@ -7,7 +7,7 @@ namespace Renci.SshNet.Common /// The exception that is thrown when SSH exception occurs. /// [Serializable] - public partial class SshException : Exception + public partial class SshException { /// /// Initializes a new instance of the class. diff --git a/Renci.SshClient/Renci.SshNet/Common/SshOperationTimeoutException.NET40.cs b/Renci.SshClient/Renci.SshNet/Common/SshOperationTimeoutException.NET40.cs index 27ddfc1d..a4486b8f 100644 --- a/Renci.SshClient/Renci.SshNet/Common/SshOperationTimeoutException.NET40.cs +++ b/Renci.SshClient/Renci.SshNet/Common/SshOperationTimeoutException.NET40.cs @@ -4,7 +4,7 @@ using System.Runtime.Serialization; namespace Renci.SshNet.Common { [Serializable] - public partial class SshOperationTimeoutException : SshException + public partial class SshOperationTimeoutException { /// /// Initializes a new instance of the class. diff --git a/Renci.SshClient/Renci.SshNet/Common/SshPassPhraseNullOrEmptyException.NET40.cs b/Renci.SshClient/Renci.SshNet/Common/SshPassPhraseNullOrEmptyException.NET40.cs index 36102f6d..76a826b4 100644 --- a/Renci.SshClient/Renci.SshNet/Common/SshPassPhraseNullOrEmptyException.NET40.cs +++ b/Renci.SshClient/Renci.SshNet/Common/SshPassPhraseNullOrEmptyException.NET40.cs @@ -7,7 +7,7 @@ namespace Renci.SshNet.Common /// The exception that is thrown when pass phrase for key file is empty or null /// [Serializable] - public partial class SshPassPhraseNullOrEmptyException : SshException + public partial class SshPassPhraseNullOrEmptyException { /// /// Initializes a new instance of the class. diff --git a/Renci.SshClient/Renci.SshNet/Compression/Compressor.cs b/Renci.SshClient/Renci.SshNet/Compression/Compressor.cs index 705e7807..b26b09ef 100644 --- a/Renci.SshClient/Renci.SshNet/Compression/Compressor.cs +++ b/Renci.SshClient/Renci.SshNet/Compression/Compressor.cs @@ -31,13 +31,13 @@ namespace Renci.SshNet.Compression /// /// Initializes a new instance of the class. /// - public Compressor() + protected Compressor() { - this._compressorStream = new MemoryStream(); - this._decompressorStream = new MemoryStream(); + _compressorStream = new MemoryStream(); + _decompressorStream = new MemoryStream(); - this._compressor = new ZlibStream(this._compressorStream, CompressionMode.Compress); - this._decompressor = new ZlibStream(this._decompressorStream, CompressionMode.Decompress); + _compressor = new ZlibStream(_compressorStream, CompressionMode.Compress); + _decompressor = new ZlibStream(_decompressorStream, CompressionMode.Decompress); } /// @@ -46,7 +46,7 @@ namespace Renci.SshNet.Compression /// The session. public virtual void Init(Session session) { - this.Session = session; + Session = session; } /// @@ -56,16 +56,16 @@ namespace Renci.SshNet.Compression /// Compressed data public virtual byte[] Compress(byte[] data) { - if (!this.IsActive) + if (!IsActive) { return data; } - this._compressorStream.SetLength(0); + _compressorStream.SetLength(0); - this._compressor.Write(data, 0, data.Length); + _compressor.Write(data, 0, data.Length); - return this._compressorStream.ToArray(); + return _compressorStream.ToArray(); } /// @@ -75,16 +75,16 @@ namespace Renci.SshNet.Compression /// Decompressed data. public virtual byte[] Decompress(byte[] data) { - if (!this.IsActive) + if (!IsActive) { return data; } - this._decompressorStream.SetLength(0); + _decompressorStream.SetLength(0); - this._decompressor.Write(data, 0, data.Length); + _decompressor.Write(data, 0, data.Length); - return this._decompressorStream.ToArray(); + return _decompressorStream.ToArray(); } #region IDisposable Members @@ -108,28 +108,28 @@ namespace Renci.SshNet.Compression protected virtual void Dispose(bool disposing) { // Check to see if Dispose has already been called. - if (!this._isDisposed) + if (!_isDisposed) { // If disposing equals true, dispose all managed // and unmanaged ResourceMessages. if (disposing) { // Dispose managed ResourceMessages. - if (this._compressorStream != null) + if (_compressorStream != null) { - this._compressorStream.Dispose(); - this._compressorStream = null; + _compressorStream.Dispose(); + _compressorStream = null; } - if (this._decompressorStream != null) + if (_decompressorStream != null) { - this._decompressorStream.Dispose(); - this._decompressorStream = null; + _decompressorStream.Dispose(); + _decompressorStream = null; } } // Note disposing has been done. - this._isDisposed = true; + _isDisposed = true; } } diff --git a/Renci.SshClient/Renci.SshNet/Compression/Zlib.cs b/Renci.SshClient/Renci.SshNet/Compression/Zlib.cs index eacb9d45..15ce4eb7 100644 --- a/Renci.SshClient/Renci.SshNet/Compression/Zlib.cs +++ b/Renci.SshClient/Renci.SshNet/Compression/Zlib.cs @@ -20,7 +20,7 @@ public override void Init(Session session) { base.Init(session); - this.IsActive = true; + IsActive = true; } } } \ No newline at end of file diff --git a/Renci.SshClient/Renci.SshNet/Compression/ZlibOpenSsh.cs b/Renci.SshClient/Renci.SshNet/Compression/ZlibOpenSsh.cs index c8f51241..7b4fa88e 100644 --- a/Renci.SshClient/Renci.SshNet/Compression/ZlibOpenSsh.cs +++ b/Renci.SshClient/Renci.SshNet/Compression/ZlibOpenSsh.cs @@ -1,4 +1,6 @@ -namespace Renci.SshNet.Compression +using Renci.SshNet.Messages.Authentication; + +namespace Renci.SshNet.Compression { /// /// Represents "zlib@openssh.org" compression implementation @@ -24,10 +26,10 @@ session.UserAuthenticationSuccessReceived += Session_UserAuthenticationSuccessReceived; } - private void Session_UserAuthenticationSuccessReceived(object sender, MessageEventArgs e) + private void Session_UserAuthenticationSuccessReceived(object sender, MessageEventArgs e) { - this.IsActive = true; - this.Session.UserAuthenticationSuccessReceived -= Session_UserAuthenticationSuccessReceived; + IsActive = true; + Session.UserAuthenticationSuccessReceived -= Session_UserAuthenticationSuccessReceived; } } } \ No newline at end of file diff --git a/Renci.SshClient/Renci.SshNet/ConnectionInfo.cs b/Renci.SshClient/Renci.SshNet/ConnectionInfo.cs index 77f13b70..772b80fb 100644 --- a/Renci.SshClient/Renci.SshNet/ConnectionInfo.cs +++ b/Renci.SshClient/Renci.SshNet/ConnectionInfo.cs @@ -21,7 +21,7 @@ namespace Renci.SshNet /// public class ConnectionInfo : IConnectionInfoInternal { - internal static int DEFAULT_PORT = 22; + internal static int DefaultPort = 22; /// /// Gets supported key exchange algorithms for this connection. @@ -222,7 +222,7 @@ namespace Renci.SshNet /// is null. /// No specified. public ConnectionInfo(string host, string username, params AuthenticationMethod[] authenticationMethods) - : this(host, DEFAULT_PORT, username, ProxyTypes.None, null, 0, null, null, authenticationMethods) + : this(host, DefaultPort, username, ProxyTypes.None, null, 0, null, null, authenticationMethods) { } @@ -288,12 +288,12 @@ namespace Renci.SshNet throw new ArgumentException("At least one authentication method should be specified.", "authenticationMethods"); // Set default connection values - this.Timeout = TimeSpan.FromSeconds(30); - this.RetryAttempts = 10; - this.MaxSessions = 10; - this.Encoding = Encoding.UTF8; + Timeout = TimeSpan.FromSeconds(30); + RetryAttempts = 10; + MaxSessions = 10; + Encoding = Encoding.UTF8; - this.KeyExchangeAlgorithms = new Dictionary + KeyExchangeAlgorithms = new Dictionary { {"diffie-hellman-group-exchange-sha256", typeof (KeyExchangeDiffieHellmanGroupExchangeSha256)}, {"diffie-hellman-group-exchange-sha1", typeof (KeyExchangeDiffieHellmanGroupExchangeSha1)}, @@ -307,7 +307,7 @@ namespace Renci.SshNet //"gss-gex-sha1-toWM5Slw5Ew8Mqkay+al2g==" - WinSSHD }; - this.Encryptions = new Dictionary + Encryptions = new Dictionary { {"aes256-ctr", new CipherInfo(256, (key, iv) => new AesCipher(key, new CtrCipherMode(iv), null))}, {"3des-cbc", new CipherInfo(192, (key, iv) => new TripleDesCipher(key, new CbcCipherMode(iv), null))}, @@ -332,7 +332,7 @@ namespace Renci.SshNet {"aes192-ctr", new CipherInfo(192, (key, iv) => new AesCipher(key, new CtrCipherMode(iv), null))}, }; - this.HmacAlgorithms = new Dictionary + HmacAlgorithms = new Dictionary { {"hmac-md5", new HashInfo(16*8, key => new HMac(key))}, {"hmac-sha1", new HashInfo(20*8, key => new HMac(key))}, @@ -348,7 +348,7 @@ namespace Renci.SshNet //{"none", typeof(...)}, }; - this.HostKeyAlgorithms = new Dictionary> + HostKeyAlgorithms = new Dictionary> { {"ssh-rsa", data => new KeyHostAlgorithm("ssh-rsa", new RsaKey(), data)}, {"ssh-dss", data => new KeyHostAlgorithm("ssh-dss", new DsaKey(), data)}, @@ -361,14 +361,14 @@ namespace Renci.SshNet //{"pgp-sign-dss", () => { ... }, }; - this.CompressionAlgorithms = new Dictionary + CompressionAlgorithms = new Dictionary { //{"zlib@openssh.com", typeof(ZlibOpenSsh)}, //{"zlib", typeof(Zlib)}, {"none", null}, }; - this.ChannelRequests = new Dictionary + ChannelRequests = new Dictionary { {EnvironmentVariableRequestInfo.NAME, new EnvironmentVariableRequestInfo()}, {ExecRequestInfo.NAME, new ExecRequestInfo()}, @@ -385,17 +385,17 @@ namespace Renci.SshNet {KeepAliveRequestInfo.NAME, new KeepAliveRequestInfo()}, }; - this.Host = host; - this.Port = port; - this.Username = username; + Host = host; + Port = port; + Username = username; - this.ProxyType = proxyType; - this.ProxyHost = proxyHost; - this.ProxyPort = proxyPort; - this.ProxyUsername = proxyUsername; - this.ProxyPassword = proxyPassword; + ProxyType = proxyType; + ProxyHost = proxyHost; + ProxyPort = proxyPort; + ProxyUsername = proxyUsername; + ProxyPassword = proxyPassword; - this.AuthenticationMethods = authenticationMethods; + AuthenticationMethods = authenticationMethods; } /// diff --git a/Renci.SshClient/Renci.SshNet/ExpectAction.cs b/Renci.SshClient/Renci.SshNet/ExpectAction.cs index 10f5fd19..023d1f87 100644 --- a/Renci.SshClient/Renci.SshNet/ExpectAction.cs +++ b/Renci.SshClient/Renci.SshNet/ExpectAction.cs @@ -32,8 +32,8 @@ namespace Renci.SshNet if (action == null) throw new ArgumentNullException("action"); - this.Expect = expect; - this.Action = action; + Expect = expect; + Action = action; } /// @@ -50,8 +50,8 @@ namespace Renci.SshNet if (action == null) throw new ArgumentNullException("action"); - this.Expect = new Regex(Regex.Escape(expect)); - this.Action = action; + Expect = new Regex(Regex.Escape(expect)); + Action = action; } } } diff --git a/Renci.SshClient/Renci.SshNet/ForwardedPortDynamic.NET.cs b/Renci.SshClient/Renci.SshNet/ForwardedPortDynamic.NET.cs index aec5c09f..8103ca54 100644 --- a/Renci.SshClient/Renci.SshNet/ForwardedPortDynamic.NET.cs +++ b/Renci.SshClient/Renci.SshNet/ForwardedPortDynamic.NET.cs @@ -8,6 +8,7 @@ using System.Net.Sockets; using System.Threading; using Renci.SshNet.Channels; using Renci.SshNet.Common; +using ASCIIEncoding = Renci.SshNet.Common.ASCIIEncoding; namespace Renci.SshNet { @@ -130,11 +131,11 @@ namespace Renci.SshNet if (version[0] == 4) { - this.HandleSocks4(clientSocket, channel); + HandleSocks4(clientSocket, channel); } else if (version[0] == 5) { - this.HandleSocks5(clientSocket, channel); + HandleSocks5(clientSocket, channel); } else { @@ -259,7 +260,7 @@ namespace Renci.SshNet var host = ipAddress.ToString(); - this.RaiseRequestReceived(host, port); + RaiseRequestReceived(host, port); channel.Open(host, port, this, socket); @@ -337,7 +338,7 @@ namespace Renci.SshNet addressBuffer = new byte[length]; stream.Read(addressBuffer, 0, addressBuffer.Length); - ipAddress = IPAddress.Parse(new Common.ASCIIEncoding().GetString(addressBuffer)); + ipAddress = IPAddress.Parse(new ASCIIEncoding().GetString(addressBuffer)); //var hostName = new Common.ASCIIEncoding().GetString(addressBuffer); @@ -361,7 +362,7 @@ namespace Renci.SshNet var port = (uint)(portBuffer[0] * 256 + portBuffer[1]); var host = ipAddress.ToString(); - this.RaiseRequestReceived(host, port); + RaiseRequestReceived(host, port); channel.Open(host, port, this, socket); diff --git a/Renci.SshClient/Renci.SshNet/ForwardedPortLocal.NET.cs b/Renci.SshClient/Renci.SshNet/ForwardedPortLocal.NET.cs index dc5d34ee..ea1e7352 100644 --- a/Renci.SshClient/Renci.SshNet/ForwardedPortLocal.NET.cs +++ b/Renci.SshClient/Renci.SshNet/ForwardedPortLocal.NET.cs @@ -165,7 +165,7 @@ namespace Renci.SshNet _listenerTaskCompleted.WaitOne(); } - private void Session_ErrorOccured(object sender, Common.ExceptionEventArgs e) + private void Session_ErrorOccured(object sender, ExceptionEventArgs e) { StopListener(); } diff --git a/Renci.SshClient/Renci.SshNet/ForwardedPortLocal.cs b/Renci.SshClient/Renci.SshNet/ForwardedPortLocal.cs index f9d8561f..26566172 100644 --- a/Renci.SshClient/Renci.SshNet/ForwardedPortLocal.cs +++ b/Renci.SshClient/Renci.SshNet/ForwardedPortLocal.cs @@ -1,5 +1,6 @@ using System; using System.Threading; +using Renci.SshNet.Common; namespace Renci.SshNet { @@ -94,10 +95,10 @@ namespace Renci.SshNet boundPort.ValidatePort("boundPort"); port.ValidatePort("port"); - this.BoundHost = boundHost; - this.BoundPort = boundPort; - this.Host = host; - this.Port = port; + BoundHost = boundHost; + BoundPort = boundPort; + Host = host; + Port = port; } /// @@ -105,7 +106,7 @@ namespace Renci.SshNet /// protected override void StartPort() { - this.InternalStart(); + InternalStart(); } /// diff --git a/Renci.SshClient/Renci.SshNet/ForwardedPortRemote.cs b/Renci.SshClient/Renci.SshNet/ForwardedPortRemote.cs index c84c7bb8..2c16fde7 100644 --- a/Renci.SshClient/Renci.SshNet/ForwardedPortRemote.cs +++ b/Renci.SshClient/Renci.SshNet/ForwardedPortRemote.cs @@ -1,5 +1,4 @@ using System; -using System.Diagnostics; using System.Threading; using Renci.SshNet.Messages.Connection; using Renci.SshNet.Common; diff --git a/Renci.SshClient/Renci.SshNet/HashInfo.cs b/Renci.SshClient/Renci.SshNet/HashInfo.cs index 6405def5..05923a81 100644 --- a/Renci.SshClient/Renci.SshNet/HashInfo.cs +++ b/Renci.SshClient/Renci.SshNet/HashInfo.cs @@ -29,8 +29,8 @@ namespace Renci.SshNet /// The hash algorithm to use for a given key. public HashInfo(int keySize, Func hash) { - this.KeySize = keySize; - this.HashAlgorithm = key => (hash(key.Take(this.KeySize / 8).ToArray())); + KeySize = keySize; + HashAlgorithm = key => (hash(key.Take(KeySize / 8).ToArray())); } } } diff --git a/Renci.SshClient/Renci.SshNet/KeyboardInteractiveConnectionInfo.cs b/Renci.SshClient/Renci.SshNet/KeyboardInteractiveConnectionInfo.cs index f31cb842..19105ad9 100644 --- a/Renci.SshClient/Renci.SshNet/KeyboardInteractiveConnectionInfo.cs +++ b/Renci.SshClient/Renci.SshNet/KeyboardInteractiveConnectionInfo.cs @@ -28,7 +28,7 @@ namespace Renci.SshNet /// The host. /// The username. public KeyboardInteractiveConnectionInfo(string host, string username) - : this(host, ConnectionInfo.DEFAULT_PORT, username, ProxyTypes.None, string.Empty, 0, string.Empty, string.Empty) + : this(host, ConnectionInfo.DefaultPort, username, ProxyTypes.None, string.Empty, 0, string.Empty, string.Empty) { } @@ -83,7 +83,7 @@ namespace Renci.SshNet /// The proxy host. /// The proxy port. public KeyboardInteractiveConnectionInfo(string host, string username, ProxyTypes proxyType, string proxyHost, int proxyPort) - : this(host, ConnectionInfo.DEFAULT_PORT, username, proxyType, proxyHost, proxyPort, string.Empty, string.Empty) + : this(host, ConnectionInfo.DefaultPort, username, proxyType, proxyHost, proxyPort, string.Empty, string.Empty) { } @@ -97,7 +97,7 @@ namespace Renci.SshNet /// The proxy port. /// The proxy username. public KeyboardInteractiveConnectionInfo(string host, string username, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername) - : this(host, ConnectionInfo.DEFAULT_PORT, username, proxyType, proxyHost, proxyPort, proxyUsername, string.Empty) + : this(host, ConnectionInfo.DefaultPort, username, proxyType, proxyHost, proxyPort, proxyUsername, string.Empty) { } @@ -112,7 +112,7 @@ namespace Renci.SshNet /// The proxy username. /// The proxy password. public KeyboardInteractiveConnectionInfo(string host, string username, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername, string proxyPassword) - : this(host, ConnectionInfo.DEFAULT_PORT, username, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword) + : this(host, ConnectionInfo.DefaultPort, username, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword) { } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Authentication/BannerMessage.cs b/Renci.SshClient/Renci.SshNet/Messages/Authentication/BannerMessage.cs index ca87762e..51fdfba4 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Authentication/BannerMessage.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Authentication/BannerMessage.cs @@ -21,8 +21,8 @@ /// protected override void LoadData() { - this.Message = this.ReadString(); - this.Language = this.ReadString(); + Message = ReadString(); + Language = ReadString(); } /// @@ -30,8 +30,8 @@ /// protected override void SaveData() { - this.Write(this.Message); - this.Write(this.Language); + Write(Message); + Write(Language); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Authentication/FailureMessage.cs b/Renci.SshClient/Renci.SshNet/Messages/Authentication/FailureMessage.cs index 513e4425..5a9b6b98 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Authentication/FailureMessage.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Authentication/FailureMessage.cs @@ -34,11 +34,11 @@ namespace Renci.SshNet.Messages.Authentication /// protected override void LoadData() { - this.AllowedAuthentications = this.ReadNamesList(); - this.PartialSuccess = this.ReadBoolean(); - if (this.PartialSuccess) + AllowedAuthentications = ReadNamesList(); + PartialSuccess = ReadBoolean(); + if (PartialSuccess) { - this.Message = string.Join(",", this.AllowedAuthentications); + Message = string.Join(",", AllowedAuthentications); } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Authentication/InformationRequestMessage.cs b/Renci.SshClient/Renci.SshNet/Messages/Authentication/InformationRequestMessage.cs index 7c1bde39..cc6baede 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Authentication/InformationRequestMessage.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Authentication/InformationRequestMessage.cs @@ -35,21 +35,21 @@ namespace Renci.SshNet.Messages.Authentication /// protected override void LoadData() { - this.Name = this.ReadString(); - this.Instruction = this.ReadString(); - this.Language = this.ReadString(); + Name = ReadString(); + Instruction = ReadString(); + Language = ReadString(); - var numOfPrompts = this.ReadUInt32(); + var numOfPrompts = ReadUInt32(); var prompts = new List(); - for (int i = 0; i < numOfPrompts; i++) + for (var i = 0; i < numOfPrompts; i++) { - var prompt = this.ReadString(); - var echo = this.ReadBoolean(); + var prompt = ReadString(); + var echo = ReadBoolean(); prompts.Add(new AuthenticationPrompt(i, echo, prompt)); } - this.Prompts = prompts; + Prompts = prompts; } /// diff --git a/Renci.SshClient/Renci.SshNet/Messages/Authentication/InformationResponseMessage.cs b/Renci.SshClient/Renci.SshNet/Messages/Authentication/InformationResponseMessage.cs index b1c19a98..5e19f9f7 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Authentication/InformationResponseMessage.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Authentication/InformationResponseMessage.cs @@ -19,7 +19,7 @@ namespace Renci.SshNet.Messages.Authentication /// public InformationResponseMessage() { - this.Responses = new List(); + Responses = new List(); } /// @@ -35,10 +35,10 @@ namespace Renci.SshNet.Messages.Authentication /// protected override void SaveData() { - this.Write((UInt32)this.Responses.Count); - foreach (var response in this.Responses) + Write((UInt32)Responses.Count); + foreach (var response in Responses) { - this.Write(response); + Write(response); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Authentication/PasswordChangeRequiredMessage.cs b/Renci.SshClient/Renci.SshNet/Messages/Authentication/PasswordChangeRequiredMessage.cs index 8a4d8f65..fb6d7f20 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Authentication/PasswordChangeRequiredMessage.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Authentication/PasswordChangeRequiredMessage.cs @@ -21,8 +21,8 @@ /// protected override void LoadData() { - this.Message = this.ReadString(); - this.Language = this.ReadString(); + Message = ReadString(); + Language = ReadString(); } /// @@ -30,8 +30,8 @@ /// protected override void SaveData() { - this.Write(this.Message); - this.Write(this.Language); + Write(Message); + Write(Language); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Authentication/PublicKeyMessage.cs b/Renci.SshClient/Renci.SshNet/Messages/Authentication/PublicKeyMessage.cs index 8ca725c3..6b475610 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Authentication/PublicKeyMessage.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Authentication/PublicKeyMessage.cs @@ -24,8 +24,8 @@ /// protected override void LoadData() { - this.PublicKeyAlgorithmName = this.ReadAsciiString(); - this.PublicKeyData = this.ReadBinaryString(); + PublicKeyAlgorithmName = ReadAsciiString(); + PublicKeyData = ReadBinaryString(); } /// @@ -33,8 +33,8 @@ /// protected override void SaveData() { - this.WriteAscii(this.PublicKeyAlgorithmName); - this.WriteBinaryString(this.PublicKeyData); + WriteAscii(PublicKeyAlgorithmName); + WriteBinaryString(PublicKeyData); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Authentication/RequestMessage.cs b/Renci.SshClient/Renci.SshNet/Messages/Authentication/RequestMessage.cs index 1d9c042e..9d63eb47 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Authentication/RequestMessage.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Authentication/RequestMessage.cs @@ -36,8 +36,8 @@ namespace Renci.SshNet.Messages.Authentication /// Authentication username. public RequestMessage(ServiceName serviceName, string username) { - this.ServiceName = serviceName; - this.Username = username; + ServiceName = serviceName; + Username = username; } /// @@ -53,19 +53,19 @@ namespace Renci.SshNet.Messages.Authentication /// protected override void SaveData() { - this.Write(this.Username); - switch (this.ServiceName) + Write(Username); + switch (ServiceName) { case ServiceName.UserAuthentication: - this.WriteAscii("ssh-userauth"); + WriteAscii("ssh-userauth"); break; case ServiceName.Connection: - this.WriteAscii("ssh-connection"); + WriteAscii("ssh-connection"); break; default: throw new NotSupportedException("Not supported service name"); } - this.WriteAscii(this.MethodName); + WriteAscii(MethodName); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Authentication/RequestMessageHost.cs b/Renci.SshClient/Renci.SshNet/Messages/Authentication/RequestMessageHost.cs index 08af7ac3..12758c9b 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Authentication/RequestMessageHost.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Authentication/RequestMessageHost.cs @@ -68,10 +68,10 @@ public RequestMessageHost(ServiceName serviceName, string username, string publicKeyAlgorithm, byte[] publicHostKey, string clientHostName, string clientUsername) : base(serviceName, username) { - this.PublicKeyAlgorithm = publicKeyAlgorithm; - this.PublicHostKey = publicHostKey; - this.ClientHostName = clientHostName; - this.ClientUsername = clientUsername; + PublicKeyAlgorithm = publicKeyAlgorithm; + PublicHostKey = publicHostKey; + ClientHostName = clientHostName; + ClientUsername = clientUsername; } /// @@ -81,13 +81,13 @@ { base.SaveData(); - this.WriteAscii(this.PublicKeyAlgorithm); - this.WriteBinaryString(this.PublicHostKey); - this.Write(this.ClientHostName); - this.Write(this.ClientUsername); + WriteAscii(PublicKeyAlgorithm); + WriteBinaryString(PublicHostKey); + Write(ClientHostName); + Write(ClientUsername); - if (this.Signature != null) - this.WriteBinaryString(this.Signature); + if (Signature != null) + WriteBinaryString(Signature); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Authentication/RequestMessageKeyboardInteractive.cs b/Renci.SshClient/Renci.SshNet/Messages/Authentication/RequestMessageKeyboardInteractive.cs index f08d00db..4be9d825 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Authentication/RequestMessageKeyboardInteractive.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Authentication/RequestMessageKeyboardInteractive.cs @@ -37,8 +37,8 @@ public RequestMessageKeyboardInteractive(ServiceName serviceName, string username) : base(serviceName, username) { - this.Language = string.Empty; - this.SubMethods = string.Empty; + Language = string.Empty; + SubMethods = string.Empty; } /// @@ -48,9 +48,9 @@ { base.SaveData(); - this.Write(this.Language); + Write(Language); - this.Write(this.SubMethods); + Write(SubMethods); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Authentication/RequestMessagePassword.cs b/Renci.SshClient/Renci.SshNet/Messages/Authentication/RequestMessagePassword.cs index e490a7c0..71b9beff 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Authentication/RequestMessagePassword.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Authentication/RequestMessagePassword.cs @@ -38,7 +38,7 @@ public RequestMessagePassword(ServiceName serviceName, string username, byte[] password) : base(serviceName, username) { - this.Password = password; + Password = password; } /// @@ -51,7 +51,7 @@ public RequestMessagePassword(ServiceName serviceName, string username, byte[] password, byte[] newPassword) : this(serviceName, username, password) { - this.NewPassword = newPassword; + NewPassword = newPassword; } /// @@ -61,15 +61,15 @@ { base.SaveData(); - this.Write(this.NewPassword != null); + Write(NewPassword != null); - this.Write((uint)this.Password.Length); - this.Write(this.Password); + Write((uint)Password.Length); + Write(Password); - if (this.NewPassword != null) + if (NewPassword != null) { - this.Write((uint)this.NewPassword.Length); - this.Write(this.NewPassword); + Write((uint)NewPassword.Length); + Write(NewPassword); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Authentication/RequestMessagePublicKey.cs b/Renci.SshClient/Renci.SshNet/Messages/Authentication/RequestMessagePublicKey.cs index a5a74aa4..7720d078 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Authentication/RequestMessagePublicKey.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Authentication/RequestMessagePublicKey.cs @@ -50,8 +50,8 @@ public RequestMessagePublicKey(ServiceName serviceName, string username, string keyAlgorithmName, byte[] keyData) : base(serviceName, username) { - this.PublicKeyAlgorithmName = keyAlgorithmName; - this.PublicKeyData = keyData; + PublicKeyAlgorithmName = keyAlgorithmName; + PublicKeyData = keyData; } /// @@ -65,7 +65,7 @@ public RequestMessagePublicKey(ServiceName serviceName, string username, string keyAlgorithmName, byte[] keyData, byte[] signature) : this(serviceName, username, keyAlgorithmName, keyData) { - this.Signature = signature; + Signature = signature; } /// @@ -75,18 +75,18 @@ { base.SaveData(); - if (this.Signature == null) + if (Signature == null) { - this.Write(false); + Write(false); } else { - this.Write(true); + Write(true); } - this.WriteAscii(this.PublicKeyAlgorithmName); - this.WriteBinaryString(this.PublicKeyData); - if (this.Signature != null) - this.WriteBinaryString(this.Signature); + WriteAscii(PublicKeyAlgorithmName); + WriteBinaryString(PublicKeyData); + if (Signature != null) + WriteBinaryString(Signature); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelDataMessage.cs b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelDataMessage.cs index b6d67184..df63224a 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelDataMessage.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelDataMessage.cs @@ -28,8 +28,8 @@ /// Message data. public ChannelDataMessage(uint localChannelNumber, byte[] data) { - this.LocalChannelNumber = localChannelNumber; - this.Data = data; + LocalChannelNumber = localChannelNumber; + Data = data; } /// @@ -38,7 +38,7 @@ protected override void LoadData() { base.LoadData(); - this.Data = this.ReadBinaryString(); + Data = ReadBinaryString(); } /// @@ -47,7 +47,7 @@ protected override void SaveData() { base.SaveData(); - this.WriteBinaryString(this.Data); + WriteBinaryString(Data); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelEofMessage.cs b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelEofMessage.cs index 64a5ee03..2029525c 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelEofMessage.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelEofMessage.cs @@ -20,7 +20,7 @@ /// The local channel number. public ChannelEofMessage(uint localChannelNumber) { - this.LocalChannelNumber = localChannelNumber; + LocalChannelNumber = localChannelNumber; } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelExtendedDataMessage.cs b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelExtendedDataMessage.cs index 7f67cee1..658efa36 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelExtendedDataMessage.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelExtendedDataMessage.cs @@ -32,9 +32,9 @@ /// The message data. public ChannelExtendedDataMessage(uint localChannelNumber, uint dataTypeCode, byte[] data) { - this.LocalChannelNumber = localChannelNumber; - this.DataTypeCode = dataTypeCode; - this.Data = data; + LocalChannelNumber = localChannelNumber; + DataTypeCode = dataTypeCode; + Data = data; } /// @@ -43,8 +43,8 @@ protected override void LoadData() { base.LoadData(); - this.DataTypeCode = this.ReadUInt32(); - this.Data = this.ReadBinaryString(); + DataTypeCode = ReadUInt32(); + Data = ReadBinaryString(); } /// @@ -53,8 +53,8 @@ protected override void SaveData() { base.SaveData(); - this.Write(this.DataTypeCode); - this.WriteBinaryString(this.Data); + Write(DataTypeCode); + WriteBinaryString(Data); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelFailureMessage.cs b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelFailureMessage.cs index 222b59a0..0613ddbd 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelFailureMessage.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelFailureMessage.cs @@ -20,7 +20,7 @@ /// The local channel number. public ChannelFailureMessage(uint localChannelNumber) { - this.LocalChannelNumber = localChannelNumber; + LocalChannelNumber = localChannelNumber; } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelMessage.cs b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelMessage.cs index ee221cb2..51c6ab36 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelMessage.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelMessage.cs @@ -19,7 +19,7 @@ namespace Renci.SshNet.Messages.Connection /// protected override void LoadData() { - this.LocalChannelNumber = this.ReadUInt32(); + LocalChannelNumber = ReadUInt32(); } /// @@ -27,7 +27,7 @@ namespace Renci.SshNet.Messages.Connection /// protected override void SaveData() { - this.Write(this.LocalChannelNumber); + Write(LocalChannelNumber); } /// @@ -38,7 +38,7 @@ namespace Renci.SshNet.Messages.Connection /// public override string ToString() { - return string.Format(CultureInfo.CurrentCulture, "{0} : #{1}", base.ToString(), this.LocalChannelNumber); + return string.Format(CultureInfo.CurrentCulture, "{0} : #{1}", base.ToString(), LocalChannelNumber); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelOpen/ChannelOpenMessage.cs b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelOpen/ChannelOpenMessage.cs index 2ef899a7..21fdbd54 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelOpen/ChannelOpenMessage.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelOpen/ChannelOpenMessage.cs @@ -19,7 +19,7 @@ namespace Renci.SshNet.Messages.Connection { get { - return this.Info.ChannelType; + return Info.ChannelType; } } @@ -61,10 +61,10 @@ namespace Renci.SshNet.Messages.Connection /// The info. public ChannelOpenMessage(uint channelNumber, uint initialWindowSize, uint maximumPacketSize, ChannelOpenInfo info) { - this.LocalChannelNumber = channelNumber; - this.InitialWindowSize = initialWindowSize; - this.MaximumPacketSize = maximumPacketSize; - this.Info = info; + LocalChannelNumber = channelNumber; + InitialWindowSize = initialWindowSize; + MaximumPacketSize = maximumPacketSize; + Info = info; } /// @@ -72,34 +72,34 @@ namespace Renci.SshNet.Messages.Connection /// protected override void LoadData() { - var channelName = this.ReadAsciiString(); - this.LocalChannelNumber = this.ReadUInt32(); - this.InitialWindowSize = this.ReadUInt32(); - this.MaximumPacketSize = this.ReadUInt32(); - var bytes = this.ReadBytes(); + var channelName = ReadAsciiString(); + LocalChannelNumber = ReadUInt32(); + InitialWindowSize = ReadUInt32(); + MaximumPacketSize = ReadUInt32(); + var bytes = ReadBytes(); if (channelName == SessionChannelOpenInfo.NAME) { - this.Info = new SessionChannelOpenInfo(); + Info = new SessionChannelOpenInfo(); } else if (channelName == X11ChannelOpenInfo.NAME) { - this.Info = new X11ChannelOpenInfo(); + Info = new X11ChannelOpenInfo(); } else if (channelName == DirectTcpipChannelInfo.NAME) { - this.Info = new DirectTcpipChannelInfo(); + Info = new DirectTcpipChannelInfo(); } else if (channelName == ForwardedTcpipChannelInfo.NAME) { - this.Info = new ForwardedTcpipChannelInfo(); + Info = new ForwardedTcpipChannelInfo(); } else { throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Channel type '{0}' is not supported.", channelName)); } - this.Info.Load(bytes); + Info.Load(bytes); } @@ -108,11 +108,11 @@ namespace Renci.SshNet.Messages.Connection /// protected override void SaveData() { - this.WriteAscii(this.ChannelType); - this.Write(this.LocalChannelNumber); - this.Write(this.InitialWindowSize); - this.Write(this.MaximumPacketSize); - this.Write(this.Info.GetBytes()); + WriteAscii(ChannelType); + Write(LocalChannelNumber); + Write(InitialWindowSize); + Write(MaximumPacketSize); + Write(Info.GetBytes()); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelOpen/DirectTcpipChannelInfo.cs b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelOpen/DirectTcpipChannelInfo.cs index 491b29f1..5052ecf2 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelOpen/DirectTcpipChannelInfo.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelOpen/DirectTcpipChannelInfo.cs @@ -58,10 +58,10 @@ /// The originator port. public DirectTcpipChannelInfo(string hostToConnect, uint portToConnect, string originatorAddress, uint originatorPort) { - this.HostToConnect = hostToConnect; - this.PortToConnect = portToConnect; - this.OriginatorAddress = originatorAddress; - this.OriginatorPort = originatorPort; + HostToConnect = hostToConnect; + PortToConnect = portToConnect; + OriginatorAddress = originatorAddress; + OriginatorPort = originatorPort; } /// @@ -71,10 +71,10 @@ { base.LoadData(); - this.HostToConnect = this.ReadString(); - this.PortToConnect = this.ReadUInt32(); - this.OriginatorAddress = this.ReadString(); - this.OriginatorPort = this.ReadUInt32(); + HostToConnect = ReadString(); + PortToConnect = ReadUInt32(); + OriginatorAddress = ReadString(); + OriginatorPort = ReadUInt32(); } /// @@ -84,10 +84,10 @@ { base.SaveData(); - this.Write(this.HostToConnect); - this.Write(this.PortToConnect); - this.Write(this.OriginatorAddress); - this.Write(this.OriginatorPort); + Write(HostToConnect); + Write(PortToConnect); + Write(OriginatorAddress); + Write(OriginatorPort); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelOpen/ForwardedTcpipChannelInfo.cs b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelOpen/ForwardedTcpipChannelInfo.cs index 022e9bfe..7fcb8827 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelOpen/ForwardedTcpipChannelInfo.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelOpen/ForwardedTcpipChannelInfo.cs @@ -67,10 +67,10 @@ { base.LoadData(); - this.ConnectedAddress = this.ReadString(); - this.ConnectedPort = this.ReadUInt32(); - this.OriginatorAddress = this.ReadString(); - this.OriginatorPort = this.ReadUInt32(); + ConnectedAddress = ReadString(); + ConnectedPort = ReadUInt32(); + OriginatorAddress = ReadString(); + OriginatorPort = ReadUInt32(); } /// @@ -80,10 +80,10 @@ { base.SaveData(); - this.Write(this.ConnectedAddress); - this.Write(this.ConnectedPort); - this.Write(this.OriginatorAddress); - this.Write(this.OriginatorPort); + Write(ConnectedAddress); + Write(ConnectedPort); + Write(OriginatorAddress); + Write(OriginatorPort); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelOpen/X11ChannelOpenInfo.cs b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelOpen/X11ChannelOpenInfo.cs index 95178d95..05394af8 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelOpen/X11ChannelOpenInfo.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelOpen/X11ChannelOpenInfo.cs @@ -38,8 +38,8 @@ { base.LoadData(); - this.OriginatorAddress = this.ReadString(); - this.OriginatorPort = this.ReadUInt32(); + OriginatorAddress = ReadString(); + OriginatorPort = ReadUInt32(); } /// @@ -49,8 +49,8 @@ { base.SaveData(); - this.Write(this.OriginatorAddress); - this.Write(this.OriginatorPort); + Write(OriginatorAddress); + Write(OriginatorPort); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelOpenConfirmationMessage.cs b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelOpenConfirmationMessage.cs index a1eca397..1777fd37 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelOpenConfirmationMessage.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelOpenConfirmationMessage.cs @@ -44,10 +44,10 @@ /// The remote channel number. public ChannelOpenConfirmationMessage(uint localChannelNumber, uint initialWindowSize, uint maximumPacketSize, uint remoteChannelNumber) { - this.LocalChannelNumber = localChannelNumber; - this.InitialWindowSize = initialWindowSize; - this.MaximumPacketSize = maximumPacketSize; - this.RemoteChannelNumber = remoteChannelNumber; + LocalChannelNumber = localChannelNumber; + InitialWindowSize = initialWindowSize; + MaximumPacketSize = maximumPacketSize; + RemoteChannelNumber = remoteChannelNumber; } /// @@ -56,9 +56,9 @@ protected override void LoadData() { base.LoadData(); - this.RemoteChannelNumber = this.ReadUInt32(); - this.InitialWindowSize = this.ReadUInt32(); - this.MaximumPacketSize = this.ReadUInt32(); + RemoteChannelNumber = ReadUInt32(); + InitialWindowSize = ReadUInt32(); + MaximumPacketSize = ReadUInt32(); } /// @@ -67,9 +67,9 @@ protected override void SaveData() { base.SaveData(); - this.Write(this.RemoteChannelNumber); - this.Write(this.InitialWindowSize); - this.Write(this.MaximumPacketSize); + Write(RemoteChannelNumber); + Write(InitialWindowSize); + Write(MaximumPacketSize); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelOpenFailureMessage.cs b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelOpenFailureMessage.cs index 396afb4a..04aca3ec 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelOpenFailureMessage.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelOpenFailureMessage.cs @@ -42,9 +42,9 @@ /// The reason code. public ChannelOpenFailureMessage(uint localChannelNumber, string description, uint reasonCode) { - this.LocalChannelNumber = localChannelNumber; - this.Description = description; - this.ReasonCode = reasonCode; + LocalChannelNumber = localChannelNumber; + Description = description; + ReasonCode = reasonCode; } /// @@ -68,9 +68,9 @@ protected override void LoadData() { base.LoadData(); - this.ReasonCode = this.ReadUInt32(); - this.Description = this.ReadString(); - this.Language = this.ReadString(); + ReasonCode = ReadUInt32(); + Description = ReadString(); + Language = ReadString(); } /// @@ -79,9 +79,9 @@ protected override void SaveData() { base.SaveData(); - this.Write(this.ReasonCode); - this.Write(this.Description ?? string.Empty); - this.Write(this.Language ?? "en"); + Write(ReasonCode); + Write(Description ?? string.Empty); + Write(Language ?? "en"); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/BreakRequestInfo.cs b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/BreakRequestInfo.cs index bde3d665..50fbebea 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/BreakRequestInfo.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/BreakRequestInfo.cs @@ -33,7 +33,7 @@ namespace Renci.SshNet.Messages.Connection /// public BreakRequestInfo() { - this.WantReply = true; + WantReply = true; } /// @@ -43,7 +43,7 @@ namespace Renci.SshNet.Messages.Connection public BreakRequestInfo(UInt32 breakLength) : this() { - this.BreakLength = breakLength; + BreakLength = breakLength; } /// @@ -53,7 +53,7 @@ namespace Renci.SshNet.Messages.Connection { base.LoadData(); - this.BreakLength = this.ReadUInt32(); + BreakLength = ReadUInt32(); } /// @@ -63,7 +63,7 @@ namespace Renci.SshNet.Messages.Connection { base.SaveData(); - this.Write(this.BreakLength); + Write(BreakLength); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/ChannelRequestMessage.cs b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/ChannelRequestMessage.cs index e2a61708..121da75a 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/ChannelRequestMessage.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/ChannelRequestMessage.cs @@ -34,9 +34,9 @@ /// The info. public ChannelRequestMessage(uint localChannelName, RequestInfo info) { - this.LocalChannelNumber = localChannelName; - this.RequestName = info.RequestName; - this.RequestData = info.GetBytes(); + LocalChannelNumber = localChannelName; + RequestName = info.RequestName; + RequestData = info.GetBytes(); } /// @@ -46,8 +46,8 @@ { base.LoadData(); - this.RequestName = this.ReadAsciiString(); - this.RequestData = this.ReadBytes(); + RequestName = ReadAsciiString(); + RequestData = ReadBytes(); } /// @@ -57,8 +57,8 @@ { base.SaveData(); - this.WriteAscii(this.RequestName); - this.Write(this.RequestData); + WriteAscii(RequestName); + Write(RequestData); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/EndOfWriteRequestInfo.cs b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/EndOfWriteRequestInfo.cs index c72cc01c..8b382fd5 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/EndOfWriteRequestInfo.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/EndOfWriteRequestInfo.cs @@ -26,7 +26,7 @@ /// public EndOfWriteRequestInfo() { - this.WantReply = false; + WantReply = false; } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/EnvironmentVariableRequestInfo.cs b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/EnvironmentVariableRequestInfo.cs index 27380504..a43369d9 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/EnvironmentVariableRequestInfo.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/EnvironmentVariableRequestInfo.cs @@ -42,7 +42,7 @@ /// public EnvironmentVariableRequestInfo() { - this.WantReply = true; + WantReply = true; } /// @@ -53,8 +53,8 @@ public EnvironmentVariableRequestInfo(string variableName, string variableValue) : this() { - this.VariableName = variableName; - this.VariableValue = variableValue; + VariableName = variableName; + VariableValue = variableValue; } /// @@ -64,8 +64,8 @@ { base.LoadData(); - this.VariableName = this.ReadString(); - this.VariableValue = this.ReadString(); + VariableName = ReadString(); + VariableValue = ReadString(); } /// @@ -75,8 +75,8 @@ { base.SaveData(); - this.Write(this.VariableName); - this.Write(this.VariableValue); + Write(VariableName); + Write(VariableValue); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/ExecRequestInfo.cs b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/ExecRequestInfo.cs index 69d213e9..e7a44065 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/ExecRequestInfo.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/ExecRequestInfo.cs @@ -1,4 +1,5 @@ -using System.Text; +using System; +using System.Text; namespace Renci.SshNet.Messages.Connection { @@ -44,7 +45,7 @@ namespace Renci.SshNet.Messages.Connection /// public ExecRequestInfo() { - this.WantReply = true; + WantReply = true; } /// @@ -57,12 +58,12 @@ namespace Renci.SshNet.Messages.Connection : this() { if (command == null) - throw new System.ArgumentNullException("command"); + throw new ArgumentNullException("command"); if (encoding == null) - throw new System.ArgumentNullException("encoding"); + throw new ArgumentNullException("encoding"); - this.Command = command; - this.Encoding = encoding; + Command = command; + Encoding = encoding; } /// @@ -72,7 +73,7 @@ namespace Renci.SshNet.Messages.Connection { base.LoadData(); - this.Command = this.ReadString(); + Command = ReadString(); } /// @@ -82,7 +83,7 @@ namespace Renci.SshNet.Messages.Connection { base.SaveData(); - this.Write(this.Command, this.Encoding); + Write(Command, Encoding); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/ExitSignalRequestInfo.cs b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/ExitSignalRequestInfo.cs index 6be4a777..49b62c9b 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/ExitSignalRequestInfo.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/ExitSignalRequestInfo.cs @@ -52,7 +52,7 @@ /// public ExitSignalRequestInfo() { - this.WantReply = false; + WantReply = false; } /// @@ -65,10 +65,10 @@ public ExitSignalRequestInfo(string signalName, bool coreDumped, string errorMessage, string language) : this() { - this.SignalName = signalName; - this.CoreDumped = coreDumped; - this.ErrorMessage = errorMessage; - this.Language = language; + SignalName = signalName; + CoreDumped = coreDumped; + ErrorMessage = errorMessage; + Language = language; } /// @@ -78,10 +78,10 @@ { base.LoadData(); - this.SignalName = this.ReadAsciiString(); - this.CoreDumped = this.ReadBoolean(); - this.ErrorMessage = this.ReadString(); - this.Language = this.ReadString(); + SignalName = ReadAsciiString(); + CoreDumped = ReadBoolean(); + ErrorMessage = ReadString(); + Language = ReadString(); } /// @@ -91,10 +91,10 @@ { base.SaveData(); - this.WriteAscii(this.SignalName); - this.Write(this.CoreDumped); - this.Write(this.ErrorMessage); - this.Write(this.Language); + WriteAscii(SignalName); + Write(CoreDumped); + Write(ErrorMessage); + Write(Language); } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/ExitStatusRequestInfo.cs b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/ExitStatusRequestInfo.cs index e9e612d4..bfcd77da 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/ExitStatusRequestInfo.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/ExitStatusRequestInfo.cs @@ -31,7 +31,7 @@ /// public ExitStatusRequestInfo() { - this.WantReply = false; + WantReply = false; } /// @@ -41,7 +41,7 @@ public ExitStatusRequestInfo(uint exitStatus) : this() { - this.ExitStatus = exitStatus; + ExitStatus = exitStatus; } /// @@ -51,7 +51,7 @@ { base.LoadData(); - this.ExitStatus = this.ReadUInt32(); + ExitStatus = ReadUInt32(); } /// @@ -61,7 +61,7 @@ { base.SaveData(); - this.Write(this.ExitStatus); + Write(ExitStatus); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/KeepAliveRequestInfo.cs b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/KeepAliveRequestInfo.cs index c1837cca..24952588 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/KeepAliveRequestInfo.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/KeepAliveRequestInfo.cs @@ -26,7 +26,7 @@ /// public KeepAliveRequestInfo() { - this.WantReply = false; + WantReply = false; } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/PseudoTerminalInfo.cs b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/PseudoTerminalInfo.cs index c499887e..c4e824a4 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/PseudoTerminalInfo.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/PseudoTerminalInfo.cs @@ -77,7 +77,7 @@ namespace Renci.SshNet.Messages.Connection /// public PseudoTerminalRequestInfo() { - this.WantReply = true; + WantReply = true; } /// @@ -92,12 +92,12 @@ namespace Renci.SshNet.Messages.Connection public PseudoTerminalRequestInfo(string environmentVariable, uint columns, uint rows, uint width, uint height, IDictionary terminalModeValues) : this() { - this.EnvironmentVariable = environmentVariable; - this.Columns = columns; - this.Rows = rows; - this.PixelWidth = width; - this.PixelHeight = height; - this.TerminalModeValues = terminalModeValues; + EnvironmentVariable = environmentVariable; + Columns = columns; + Rows = rows; + PixelWidth = width; + PixelHeight = height; + TerminalModeValues = terminalModeValues; } /// @@ -107,26 +107,26 @@ namespace Renci.SshNet.Messages.Connection { base.SaveData(); - this.Write(this.EnvironmentVariable); - this.Write(this.Columns); - this.Write(this.Rows); - this.Write(this.Rows); - this.Write(this.PixelHeight); + Write(EnvironmentVariable); + Write(Columns); + Write(Rows); + Write(Rows); + Write(PixelHeight); - if (this.TerminalModeValues != null) + if (TerminalModeValues != null) { - this.Write((uint)this.TerminalModeValues.Count * (1 + 4) + 1); + Write((uint)TerminalModeValues.Count * (1 + 4) + 1); - foreach (var item in this.TerminalModeValues) + foreach (var item in TerminalModeValues) { - this.Write((byte)item.Key); - this.Write(item.Value); + Write((byte)item.Key); + Write(item.Value); } - this.Write((byte)0); + Write((byte)0); } else { - this.Write((uint)0); + Write((uint)0); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/RequestInfo.cs b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/RequestInfo.cs index 194d14fe..6e866e6c 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/RequestInfo.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/RequestInfo.cs @@ -28,7 +28,7 @@ namespace Renci.SshNet.Messages.Connection /// protected override void LoadData() { - this.WantReply = this.ReadBoolean(); + WantReply = ReadBoolean(); } /// @@ -36,7 +36,7 @@ namespace Renci.SshNet.Messages.Connection /// protected override void SaveData() { - this.Write(this.WantReply); + Write(WantReply); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/ShellRequestInfo.cs b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/ShellRequestInfo.cs index 480a0a1e..bd96028b 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/ShellRequestInfo.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/ShellRequestInfo.cs @@ -26,7 +26,7 @@ /// public ShellRequestInfo() { - this.WantReply = true; + WantReply = true; } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/SignalRequestInfo.cs b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/SignalRequestInfo.cs index 8e31fb59..a180f7b1 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/SignalRequestInfo.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/SignalRequestInfo.cs @@ -34,7 +34,7 @@ /// public SignalRequestInfo() { - this.WantReply = false; + WantReply = false; } /// @@ -44,7 +44,7 @@ public SignalRequestInfo(string signalName) : this() { - this.SignalName = signalName; + SignalName = signalName; } /// @@ -54,7 +54,7 @@ { base.LoadData(); - this.SignalName = this.ReadAsciiString(); + SignalName = ReadAsciiString(); } /// @@ -64,7 +64,7 @@ { base.SaveData(); - this.WriteAscii(this.SignalName); + WriteAscii(SignalName); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/SubsystemRequestInfo.cs b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/SubsystemRequestInfo.cs index 0dd48c9f..948e91fb 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/SubsystemRequestInfo.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/SubsystemRequestInfo.cs @@ -34,7 +34,7 @@ /// public SubsystemRequestInfo() { - this.WantReply = true; + WantReply = true; } /// @@ -44,7 +44,7 @@ public SubsystemRequestInfo(string subsystem) : this() { - this.SubsystemName = subsystem; + SubsystemName = subsystem; } /// @@ -54,7 +54,7 @@ { base.LoadData(); - this.SubsystemName = this.ReadAsciiString(); + SubsystemName = ReadAsciiString(); } /// @@ -64,7 +64,7 @@ { base.SaveData(); - this.WriteAscii(this.SubsystemName); + WriteAscii(SubsystemName); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/WindowChangeRequestInfo.cs b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/WindowChangeRequestInfo.cs index 51afe671..2a217113 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/WindowChangeRequestInfo.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/WindowChangeRequestInfo.cs @@ -46,7 +46,7 @@ /// public WindowChangeRequestInfo() { - this.WantReply = false; + WantReply = false; } /// @@ -59,10 +59,10 @@ public WindowChangeRequestInfo(uint columns, uint rows, uint width, uint height) : this() { - this.Columns = columns; - this.Rows = rows; - this.Width = width; - this.Height = height; + Columns = columns; + Rows = rows; + Width = width; + Height = height; } /// @@ -72,10 +72,10 @@ { base.LoadData(); - this.Columns = this.ReadUInt32(); - this.Rows = this.ReadUInt32(); - this.Width = this.ReadUInt32(); - this.Height = this.ReadUInt32(); + Columns = ReadUInt32(); + Rows = ReadUInt32(); + Width = ReadUInt32(); + Height = ReadUInt32(); } /// @@ -85,10 +85,10 @@ { base.SaveData(); - this.Write(this.Columns); - this.Write(this.Rows); - this.Write(this.Width); - this.Write(this.Height); + Write(Columns); + Write(Rows); + Write(Width); + Write(Height); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/X11ForwardingRequestInfo.cs b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/X11ForwardingRequestInfo.cs index 8bff3569..61132a62 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/X11ForwardingRequestInfo.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/X11ForwardingRequestInfo.cs @@ -58,7 +58,7 @@ /// public X11ForwardingRequestInfo() { - this.WantReply = true; + WantReply = true; } /// @@ -71,10 +71,10 @@ public X11ForwardingRequestInfo(bool isSingleConnection, string protocol, byte[] cookie, uint screenNumber) : this() { - this.IsSingleConnection = isSingleConnection; - this.AuthenticationProtocol = protocol; - this.AuthenticationCookie = cookie; - this.ScreenNumber = screenNumber; + IsSingleConnection = isSingleConnection; + AuthenticationProtocol = protocol; + AuthenticationCookie = cookie; + ScreenNumber = screenNumber; } /// @@ -84,10 +84,10 @@ { base.LoadData(); - this.IsSingleConnection = this.ReadBoolean(); - this.AuthenticationProtocol = this.ReadAsciiString(); - this.AuthenticationCookie = this.ReadBinaryString(); - this.ScreenNumber = this.ReadUInt32(); + IsSingleConnection = ReadBoolean(); + AuthenticationProtocol = ReadAsciiString(); + AuthenticationCookie = ReadBinaryString(); + ScreenNumber = ReadUInt32(); } /// @@ -97,10 +97,10 @@ { base.SaveData(); - this.Write(this.IsSingleConnection); - this.WriteAscii(this.AuthenticationProtocol); - this.WriteBinaryString(this.AuthenticationCookie); - this.Write(this.ScreenNumber); + Write(IsSingleConnection); + WriteAscii(AuthenticationProtocol); + WriteBinaryString(AuthenticationCookie); + Write(ScreenNumber); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/XonXoffRequestInfo.cs b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/XonXoffRequestInfo.cs index ebe2adfc..50888267 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/XonXoffRequestInfo.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelRequest/XonXoffRequestInfo.cs @@ -34,7 +34,7 @@ /// public XonXoffRequestInfo() { - this.WantReply = false; + WantReply = false; } /// @@ -44,7 +44,7 @@ public XonXoffRequestInfo(bool clientCanDo) : this() { - this.ClientCanDo = clientCanDo; + ClientCanDo = clientCanDo; } /// @@ -54,7 +54,7 @@ { base.LoadData(); - this.ClientCanDo = this.ReadBoolean(); + ClientCanDo = ReadBoolean(); } /// @@ -64,7 +64,7 @@ { base.SaveData(); - this.Write(this.ClientCanDo); + Write(ClientCanDo); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelSuccessMessage.cs b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelSuccessMessage.cs index c5c4a6f7..ea18e0a1 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelSuccessMessage.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelSuccessMessage.cs @@ -20,7 +20,7 @@ /// The local channel number. public ChannelSuccessMessage(uint localChannelNumber) { - this.LocalChannelNumber = localChannelNumber; + LocalChannelNumber = localChannelNumber; } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelWindowAdjustMessage.cs b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelWindowAdjustMessage.cs index bb8bdec9..dfa4d307 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelWindowAdjustMessage.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Connection/ChannelWindowAdjustMessage.cs @@ -26,8 +26,8 @@ /// The bytes to add. public ChannelWindowAdjustMessage(uint localChannelNumber, uint bytesToAdd) { - this.LocalChannelNumber = localChannelNumber; - this.BytesToAdd = bytesToAdd; + LocalChannelNumber = localChannelNumber; + BytesToAdd = bytesToAdd; } /// @@ -36,7 +36,7 @@ protected override void LoadData() { base.LoadData(); - this.BytesToAdd = this.ReadUInt32(); + BytesToAdd = ReadUInt32(); } /// @@ -45,7 +45,7 @@ protected override void SaveData() { base.SaveData(); - this.Write(this.BytesToAdd); + Write(BytesToAdd); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Connection/GlobalRequestMessage.cs b/Renci.SshClient/Renci.SshNet/Messages/Connection/GlobalRequestMessage.cs index 99568b25..0d8c3e90 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Connection/GlobalRequestMessage.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Connection/GlobalRequestMessage.cs @@ -50,8 +50,8 @@ namespace Renci.SshNet.Messages.Connection /// if set to true [want reply]. public GlobalRequestMessage(GlobalRequestName requestName, bool wantReply) { - this.RequestName = requestName; - this.WantReply = wantReply; + RequestName = requestName; + WantReply = wantReply; } /// @@ -64,8 +64,8 @@ namespace Renci.SshNet.Messages.Connection public GlobalRequestMessage(GlobalRequestName requestName, bool wantReply, string addressToBind, uint portToBind) : this(requestName, wantReply) { - this.AddressToBind = addressToBind; - this.PortToBind = portToBind; + AddressToBind = addressToBind; + PortToBind = portToBind; } /// @@ -73,21 +73,21 @@ namespace Renci.SshNet.Messages.Connection /// protected override void LoadData() { - var requestName = this.ReadAsciiString(); + var requestName = ReadAsciiString(); - this.WantReply = this.ReadBoolean(); + WantReply = ReadBoolean(); switch (requestName) { case "tcpip-forward": - this.RequestName = GlobalRequestName.TcpIpForward; - this.AddressToBind = this.ReadString(); - this.PortToBind = this.ReadUInt32(); + RequestName = GlobalRequestName.TcpIpForward; + AddressToBind = ReadString(); + PortToBind = ReadUInt32(); break; case "cancel-tcpip-forward": - this.RequestName = GlobalRequestName.CancelTcpIpForward; - this.AddressToBind = this.ReadString(); - this.PortToBind = this.ReadUInt32(); + RequestName = GlobalRequestName.CancelTcpIpForward; + AddressToBind = ReadString(); + PortToBind = ReadUInt32(); break; } } @@ -97,24 +97,24 @@ namespace Renci.SshNet.Messages.Connection /// protected override void SaveData() { - switch (this.RequestName) + switch (RequestName) { case GlobalRequestName.TcpIpForward: - this.WriteAscii("tcpip-forward"); + WriteAscii("tcpip-forward"); break; case GlobalRequestName.CancelTcpIpForward: - this.WriteAscii("cancel-tcpip-forward"); + WriteAscii("cancel-tcpip-forward"); break; } - this.Write(this.WantReply); + Write(WantReply); - switch (this.RequestName) + switch (RequestName) { case GlobalRequestName.TcpIpForward: case GlobalRequestName.CancelTcpIpForward: - this.Write(this.AddressToBind); - this.Write(this.PortToBind); + Write(AddressToBind); + Write(PortToBind); break; } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Connection/RequestSuccessMessage.cs b/Renci.SshClient/Renci.SshNet/Messages/Connection/RequestSuccessMessage.cs index 694c76fd..19df4fed 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Connection/RequestSuccessMessage.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Connection/RequestSuccessMessage.cs @@ -25,7 +25,7 @@ /// The bound port. public RequestSuccessMessage(uint boundPort) { - this.BoundPort = boundPort; + BoundPort = boundPort; } /// @@ -33,8 +33,8 @@ /// protected override void LoadData() { - if (!this.IsEndOfData) - this.BoundPort = this.ReadUInt32(); + if (!IsEndOfData) + BoundPort = ReadUInt32(); } /// @@ -42,8 +42,8 @@ /// protected override void SaveData() { - if (this.BoundPort != null) - this.Write(this.BoundPort.Value); + if (BoundPort != null) + Write(BoundPort.Value); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Message.cs b/Renci.SshClient/Renci.SshNet/Messages/Message.cs index f0ceb547..95b21f3a 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Message.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Message.cs @@ -30,10 +30,10 @@ namespace Renci.SshNet.Messages /// Byte array representation of the message public override byte[] GetBytes() { - var messageAttribute = this.GetType().GetCustomAttributes(typeof(MessageAttribute), true).SingleOrDefault() as MessageAttribute; + var messageAttribute = GetType().GetCustomAttributes(typeof(MessageAttribute), true).SingleOrDefault() as MessageAttribute; if (messageAttribute == null) - throw new SshException(string.Format(CultureInfo.CurrentCulture, "Type '{0}' is not a valid message type.", this.GetType().AssemblyQualifiedName)); + throw new SshException(string.Format(CultureInfo.CurrentCulture, "Type '{0}' is not a valid message type.", GetType().AssemblyQualifiedName)); var data = new List(base.GetBytes()); @@ -50,10 +50,10 @@ namespace Renci.SshNet.Messages /// public override string ToString() { - var messageAttribute = this.GetType().GetCustomAttributes(typeof(MessageAttribute), true).SingleOrDefault() as MessageAttribute; + var messageAttribute = GetType().GetCustomAttributes(typeof(MessageAttribute), true).SingleOrDefault() as MessageAttribute; if (messageAttribute == null) - return string.Format(CultureInfo.CurrentCulture, "'{0}' without Message attribute.", this.GetType().FullName); + return string.Format(CultureInfo.CurrentCulture, "'{0}' without Message attribute.", GetType().FullName); return messageAttribute.Name; } diff --git a/Renci.SshClient/Renci.SshNet/Messages/MessageAttribute.cs b/Renci.SshClient/Renci.SshNet/Messages/MessageAttribute.cs index 91a928e4..b6082a7a 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/MessageAttribute.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/MessageAttribute.cs @@ -32,8 +32,8 @@ namespace Renci.SshNet.Messages /// The number. public MessageAttribute(string name, byte number) { - this.Name = name; - this.Number = number; + Name = name; + Number = number; } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Transport/DebugMessage.cs b/Renci.SshClient/Renci.SshNet/Messages/Transport/DebugMessage.cs index 25ec7fb5..6ffab157 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Transport/DebugMessage.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Transport/DebugMessage.cs @@ -30,9 +30,9 @@ namespace Renci.SshNet.Messages.Transport /// protected override void LoadData() { - this.IsAlwaysDisplay = this.ReadBoolean(); - this.Message = this.ReadString(); - this.Language = this.ReadString(); + IsAlwaysDisplay = ReadBoolean(); + Message = ReadString(); + Language = ReadString(); } /// @@ -40,9 +40,9 @@ namespace Renci.SshNet.Messages.Transport /// protected override void SaveData() { - this.Write(this.IsAlwaysDisplay); - this.Write(this.Message); - this.Write(this.Language); + Write(IsAlwaysDisplay); + Write(Message); + Write(Language); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Transport/DisconnectMessage.cs b/Renci.SshClient/Renci.SshNet/Messages/Transport/DisconnectMessage.cs index 3b1d2494..e4de4f7b 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Transport/DisconnectMessage.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Transport/DisconnectMessage.cs @@ -26,7 +26,6 @@ /// public DisconnectMessage() { - } /// @@ -36,8 +35,8 @@ /// The message. public DisconnectMessage(DisconnectReason reasonCode, string message) { - this.ReasonCode = reasonCode; - this.Description = message; + ReasonCode = reasonCode; + Description = message; } /// @@ -45,9 +44,9 @@ /// protected override void LoadData() { - this.ReasonCode = (DisconnectReason)this.ReadUInt32(); - this.Description = this.ReadString(); - this.Language = this.ReadString(); + ReasonCode = (DisconnectReason)ReadUInt32(); + Description = ReadString(); + Language = ReadString(); } /// @@ -55,9 +54,9 @@ /// protected override void SaveData() { - this.Write((uint)this.ReasonCode); - this.Write(this.Description); - this.Write(this.Language ?? "en"); + Write((uint)ReasonCode); + Write(Description); + Write(Language ?? "en"); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Transport/IgnoreMessage.cs b/Renci.SshClient/Renci.SshNet/Messages/Transport/IgnoreMessage.cs index 09c63dcf..01a4be03 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Transport/IgnoreMessage.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Transport/IgnoreMessage.cs @@ -16,7 +16,7 @@ /// public IgnoreMessage() { - this.Data = new byte[] { }; + Data = new byte[] { }; } /// @@ -25,7 +25,7 @@ /// The data. public IgnoreMessage(byte[] data) { - this.Data = data; + Data = data; } /// @@ -33,7 +33,7 @@ /// protected override void LoadData() { - this.Data = this.ReadBinaryString(); + Data = ReadBinaryString(); } /// @@ -41,7 +41,7 @@ /// protected override void SaveData() { - this.WriteBinaryString(this.Data); + WriteBinaryString(Data); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Transport/KeyExchangeDhGroupExchangeGroup.cs b/Renci.SshClient/Renci.SshNet/Messages/Transport/KeyExchangeDhGroupExchangeGroup.cs index 2c0211d0..d0ba2619 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Transport/KeyExchangeDhGroupExchangeGroup.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Transport/KeyExchangeDhGroupExchangeGroup.cs @@ -29,8 +29,8 @@ namespace Renci.SshNet.Messages.Transport /// protected override void LoadData() { - this.SafePrime = this.ReadBigInt(); - this.SubGroup = this.ReadBigInt(); + SafePrime = ReadBigInt(); + SubGroup = ReadBigInt(); } /// @@ -38,8 +38,8 @@ namespace Renci.SshNet.Messages.Transport /// protected override void SaveData() { - this.Write(this.SafePrime); - this.Write(this.SubGroup); + Write(SafePrime); + Write(SubGroup); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Transport/KeyExchangeDhGroupExchangeInit.cs b/Renci.SshClient/Renci.SshNet/Messages/Transport/KeyExchangeDhGroupExchangeInit.cs index aa14aaaf..9dc27e63 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Transport/KeyExchangeDhGroupExchangeInit.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Transport/KeyExchangeDhGroupExchangeInit.cs @@ -19,7 +19,7 @@ namespace Renci.SshNet.Messages.Transport /// The client exchange value. public KeyExchangeDhGroupExchangeInit(BigInteger clientExchangeValue) { - this.E = clientExchangeValue; + E = clientExchangeValue; } /// @@ -27,7 +27,7 @@ namespace Renci.SshNet.Messages.Transport /// protected override void LoadData() { - this.E = this.ReadBigInt(); + E = ReadBigInt(); } /// @@ -35,7 +35,7 @@ namespace Renci.SshNet.Messages.Transport /// protected override void SaveData() { - this.Write(this.E); + Write(E); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Transport/KeyExchangeDhGroupExchangeReply.cs b/Renci.SshClient/Renci.SshNet/Messages/Transport/KeyExchangeDhGroupExchangeReply.cs index c3147853..3b93a5a4 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Transport/KeyExchangeDhGroupExchangeReply.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Transport/KeyExchangeDhGroupExchangeReply.cs @@ -30,9 +30,9 @@ namespace Renci.SshNet.Messages.Transport /// protected override void LoadData() { - this.HostKey = this.ReadBinaryString(); - this.F = this.ReadBigInt(); - this.Signature = this.ReadBinaryString(); + HostKey = ReadBinaryString(); + F = ReadBigInt(); + Signature = ReadBinaryString(); } /// @@ -40,9 +40,9 @@ namespace Renci.SshNet.Messages.Transport /// protected override void SaveData() { - this.WriteBinaryString(this.HostKey); - this.Write(this.F); - this.WriteBinaryString(this.Signature); + WriteBinaryString(HostKey); + Write(F); + WriteBinaryString(Signature); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Transport/KeyExchangeDhGroupExchangeRequest.cs b/Renci.SshClient/Renci.SshNet/Messages/Transport/KeyExchangeDhGroupExchangeRequest.cs index fe36991f..7d27ee33 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Transport/KeyExchangeDhGroupExchangeRequest.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Transport/KeyExchangeDhGroupExchangeRequest.cs @@ -40,9 +40,9 @@ namespace Renci.SshNet.Messages.Transport /// The maximum. public KeyExchangeDhGroupExchangeRequest(uint minimum, uint preferred, uint maximum) { - this.Minimum = minimum; - this.Preferred = preferred; - this.Maximum = maximum; + Minimum = minimum; + Preferred = preferred; + Maximum = maximum; } /// @@ -50,9 +50,9 @@ namespace Renci.SshNet.Messages.Transport /// protected override void LoadData() { - this.Minimum = this.ReadUInt32(); - this.Preferred = this.ReadUInt32(); - this.Maximum = this.ReadUInt32(); + Minimum = ReadUInt32(); + Preferred = ReadUInt32(); + Maximum = ReadUInt32(); } /// @@ -60,9 +60,9 @@ namespace Renci.SshNet.Messages.Transport /// protected override void SaveData() { - this.Write(this.Minimum); - this.Write(this.Preferred); - this.Write(this.Maximum); + Write(Minimum); + Write(Preferred); + Write(Maximum); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Transport/KeyExchangeDhInitMessage.cs b/Renci.SshClient/Renci.SshNet/Messages/Transport/KeyExchangeDhInitMessage.cs index 011c5b48..fdac7a95 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Transport/KeyExchangeDhInitMessage.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Transport/KeyExchangeDhInitMessage.cs @@ -19,7 +19,7 @@ namespace Renci.SshNet.Messages.Transport /// The client exchange value. public KeyExchangeDhInitMessage(BigInteger clientExchangeValue) { - this.E = clientExchangeValue; + E = clientExchangeValue; } /// @@ -27,8 +27,8 @@ namespace Renci.SshNet.Messages.Transport /// protected override void LoadData() { - this.ResetReader(); - this.E = this.ReadBigInt(); + ResetReader(); + E = ReadBigInt(); } /// @@ -36,7 +36,7 @@ namespace Renci.SshNet.Messages.Transport /// protected override void SaveData() { - this.Write(this.E); + Write(E); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Transport/KeyExchangeDhReplyMessage.cs b/Renci.SshClient/Renci.SshNet/Messages/Transport/KeyExchangeDhReplyMessage.cs index 1ac2186c..04873bfc 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Transport/KeyExchangeDhReplyMessage.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Transport/KeyExchangeDhReplyMessage.cs @@ -30,10 +30,10 @@ namespace Renci.SshNet.Messages.Transport /// protected override void LoadData() { - this.ResetReader(); - this.HostKey = this.ReadBinaryString(); - this.F = this.ReadBigInt(); - this.Signature = this.ReadBinaryString(); + ResetReader(); + HostKey = ReadBinaryString(); + F = ReadBigInt(); + Signature = ReadBinaryString(); } /// @@ -41,9 +41,9 @@ namespace Renci.SshNet.Messages.Transport /// protected override void SaveData() { - this.WriteBinaryString(this.HostKey); - this.Write(this.F); - this.WriteBinaryString(this.Signature); + WriteBinaryString(HostKey); + Write(F); + WriteBinaryString(Signature); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Transport/KeyExchangeEcdhInitMessage.cs b/Renci.SshClient/Renci.SshNet/Messages/Transport/KeyExchangeEcdhInitMessage.cs index 8701cdf2..515c97cb 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Transport/KeyExchangeEcdhInitMessage.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Transport/KeyExchangeEcdhInitMessage.cs @@ -24,7 +24,7 @@ namespace Renci.SshNet.Messages.Transport data.Add(0x04); data.AddRange(d.ToByteArray().Reverse()); data.AddRange(q.ToByteArray().Reverse()); - this.QC = data.ToArray(); + QC = data.ToArray(); } /// @@ -32,8 +32,8 @@ namespace Renci.SshNet.Messages.Transport /// protected override void LoadData() { - this.ResetReader(); - this.QC = this.ReadBinaryString(); + ResetReader(); + QC = ReadBinaryString(); } /// @@ -41,7 +41,7 @@ namespace Renci.SshNet.Messages.Transport /// protected override void SaveData() { - this.WriteBinaryString(this.QC); + WriteBinaryString(QC); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Transport/KeyExchangeEcdhReplyMessage.cs b/Renci.SshClient/Renci.SshNet/Messages/Transport/KeyExchangeEcdhReplyMessage.cs index 8b67f73e..0e6589a4 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Transport/KeyExchangeEcdhReplyMessage.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Transport/KeyExchangeEcdhReplyMessage.cs @@ -28,10 +28,10 @@ /// protected override void LoadData() { - this.ResetReader(); - this.KS = this.ReadBinaryString(); - this.QS = this.ReadBinaryString(); - this.Signature = this.ReadBinaryString(); + ResetReader(); + KS = ReadBinaryString(); + QS = ReadBinaryString(); + Signature = ReadBinaryString(); } /// @@ -39,9 +39,9 @@ /// protected override void SaveData() { - this.WriteBinaryString(this.KS); - this.WriteBinaryString(this.QS); - this.WriteBinaryString(this.Signature); + WriteBinaryString(KS); + WriteBinaryString(QS); + WriteBinaryString(Signature); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Transport/KeyExchangeInitMessage.cs b/Renci.SshClient/Renci.SshNet/Messages/Transport/KeyExchangeInitMessage.cs index 9527d284..1efad5d7 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Transport/KeyExchangeInitMessage.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Transport/KeyExchangeInitMessage.cs @@ -9,7 +9,7 @@ namespace Renci.SshNet.Messages.Transport [Message("SSH_MSG_KEXINIT", 20)] public class KeyExchangeInitMessage : Message, IKeyExchangedAllowed { - private static readonly RNGCryptoServiceProvider _randomizer = new RNGCryptoServiceProvider(); + private static readonly RNGCryptoServiceProvider Randomizer = new RNGCryptoServiceProvider(); /// /// Initializes a new instance of the class. @@ -17,8 +17,8 @@ namespace Renci.SshNet.Messages.Transport public KeyExchangeInitMessage() { var cookie = new byte[16]; - _randomizer.GetBytes(cookie); - this.Cookie = cookie; + Randomizer.GetBytes(cookie); + Cookie = cookie; } #region Message Properties @@ -131,21 +131,21 @@ namespace Renci.SshNet.Messages.Transport /// protected override void LoadData() { - this.ResetReader(); + ResetReader(); - this.Cookie = this.ReadBytes(16); - this.KeyExchangeAlgorithms = this.ReadNamesList(); - this.ServerHostKeyAlgorithms = this.ReadNamesList(); - this.EncryptionAlgorithmsClientToServer = this.ReadNamesList(); - this.EncryptionAlgorithmsServerToClient = this.ReadNamesList(); - this.MacAlgorithmsClientToServer = this.ReadNamesList(); - this.MacAlgorithmsServerToClient = this.ReadNamesList(); - this.CompressionAlgorithmsClientToServer = this.ReadNamesList(); - this.CompressionAlgorithmsServerToClient = this.ReadNamesList(); - this.LanguagesClientToServer = this.ReadNamesList(); - this.LanguagesServerToClient = this.ReadNamesList(); - this.FirstKexPacketFollows = this.ReadBoolean(); - this.Reserved = this.ReadUInt32(); + Cookie = ReadBytes(16); + KeyExchangeAlgorithms = ReadNamesList(); + ServerHostKeyAlgorithms = ReadNamesList(); + EncryptionAlgorithmsClientToServer = ReadNamesList(); + EncryptionAlgorithmsServerToClient = ReadNamesList(); + MacAlgorithmsClientToServer = ReadNamesList(); + MacAlgorithmsServerToClient = ReadNamesList(); + CompressionAlgorithmsClientToServer = ReadNamesList(); + CompressionAlgorithmsServerToClient = ReadNamesList(); + LanguagesClientToServer = ReadNamesList(); + LanguagesServerToClient = ReadNamesList(); + FirstKexPacketFollows = ReadBoolean(); + Reserved = ReadUInt32(); } /// @@ -153,19 +153,19 @@ namespace Renci.SshNet.Messages.Transport /// protected override void SaveData() { - this.Write(this.Cookie); - this.Write(this.KeyExchangeAlgorithms); - this.Write(this.ServerHostKeyAlgorithms); - this.Write(this.EncryptionAlgorithmsClientToServer); - this.Write(this.EncryptionAlgorithmsServerToClient); - this.Write(this.MacAlgorithmsClientToServer); - this.Write(this.MacAlgorithmsServerToClient); - this.Write(this.CompressionAlgorithmsClientToServer); - this.Write(this.CompressionAlgorithmsServerToClient); - this.Write(this.LanguagesClientToServer); - this.Write(this.LanguagesServerToClient); - this.Write(this.FirstKexPacketFollows); - this.Write(this.Reserved); + Write(Cookie); + Write(KeyExchangeAlgorithms); + Write(ServerHostKeyAlgorithms); + Write(EncryptionAlgorithmsClientToServer); + Write(EncryptionAlgorithmsServerToClient); + Write(MacAlgorithmsClientToServer); + Write(MacAlgorithmsServerToClient); + Write(CompressionAlgorithmsClientToServer); + Write(CompressionAlgorithmsServerToClient); + Write(LanguagesClientToServer); + Write(LanguagesServerToClient); + Write(FirstKexPacketFollows); + Write(Reserved); } } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Transport/ServiceAcceptMessage.cs b/Renci.SshClient/Renci.SshNet/Messages/Transport/ServiceAcceptMessage.cs index c4811c8e..1f1b2af6 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Transport/ServiceAcceptMessage.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Transport/ServiceAcceptMessage.cs @@ -21,14 +21,14 @@ namespace Renci.SshNet.Messages.Transport /// protected override void LoadData() { - var serviceName = this.ReadAsciiString(); + var serviceName = ReadAsciiString(); switch (serviceName) { case "ssh-userauth": - this.ServiceName = ServiceName.UserAuthentication; + ServiceName = ServiceName.UserAuthentication; break; case "ssh-connection": - this.ServiceName = ServiceName.Connection; + ServiceName = ServiceName.Connection; break; } } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Transport/ServiceRequestMessage.cs b/Renci.SshClient/Renci.SshNet/Messages/Transport/ServiceRequestMessage.cs index d2743170..f6c4fd8d 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Transport/ServiceRequestMessage.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Transport/ServiceRequestMessage.cs @@ -22,7 +22,7 @@ namespace Renci.SshNet.Messages.Transport /// Name of the service. public ServiceRequestMessage(ServiceName serviceName) { - this.ServiceName = serviceName; + ServiceName = serviceName; } /// @@ -38,13 +38,13 @@ namespace Renci.SshNet.Messages.Transport /// protected override void SaveData() { - switch (this.ServiceName) + switch (ServiceName) { case ServiceName.UserAuthentication: - this.WriteAscii("ssh-userauth"); + WriteAscii("ssh-userauth"); break; case ServiceName.Connection: - this.WriteAscii("ssh-connection"); + WriteAscii("ssh-connection"); break; default: throw new NotSupportedException("Not supported service name"); diff --git a/Renci.SshClient/Renci.SshNet/NetConfClient.cs b/Renci.SshClient/Renci.SshNet/NetConfClient.cs index abb2fe91..3d4ccbdc 100644 --- a/Renci.SshClient/Renci.SshNet/NetConfClient.cs +++ b/Renci.SshClient/Renci.SshNet/NetConfClient.cs @@ -63,7 +63,7 @@ namespace Renci.SshNet /// is null. /// is invalid, or is null or contains whitespace characters. public NetConfClient(string host, string username, string password) - : this(host, ConnectionInfo.DEFAULT_PORT, username, password) + : this(host, ConnectionInfo.DefaultPort, username, password) { } @@ -92,7 +92,7 @@ namespace Renci.SshNet /// is null. /// is invalid, -or- is null or contains whitespace characters. public NetConfClient(string host, string username, params PrivateKeyFile[] keyFiles) - : this(host, ConnectionInfo.DEFAULT_PORT, username, keyFiles) + : this(host, ConnectionInfo.DefaultPort, username, keyFiles) { } diff --git a/Renci.SshClient/Renci.SshNet/Netconf/NetConfSession.cs b/Renci.SshClient/Renci.SshNet/Netconf/NetConfSession.cs index baf738c7..d7fe945b 100644 --- a/Renci.SshClient/Renci.SshNet/Netconf/NetConfSession.cs +++ b/Renci.SshClient/Renci.SshNet/Netconf/NetConfSession.cs @@ -137,7 +137,7 @@ namespace Renci.SshNet.NetConf } else if (_usingFramingProtocol) { - int position = 0; + var position = 0; for (; ; ) { diff --git a/Renci.SshClient/Renci.SshNet/NoneAuthenticationMethod.cs b/Renci.SshClient/Renci.SshNet/NoneAuthenticationMethod.cs index fb294c60..8f2f88bd 100644 --- a/Renci.SshClient/Renci.SshNet/NoneAuthenticationMethod.cs +++ b/Renci.SshClient/Renci.SshNet/NoneAuthenticationMethod.cs @@ -50,34 +50,34 @@ namespace Renci.SshNet session.UserAuthenticationSuccessReceived += Session_UserAuthenticationSuccessReceived; session.UserAuthenticationFailureReceived += Session_UserAuthenticationFailureReceived; - session.SendMessage(new RequestMessageNone(ServiceName.Connection, this.Username)); + session.SendMessage(new RequestMessageNone(ServiceName.Connection, Username)); - session.WaitOnHandle(this._authenticationCompleted); + session.WaitOnHandle(_authenticationCompleted); session.UserAuthenticationSuccessReceived -= Session_UserAuthenticationSuccessReceived; session.UserAuthenticationFailureReceived -= Session_UserAuthenticationFailureReceived; - return this._authenticationResult; + return _authenticationResult; } private void Session_UserAuthenticationSuccessReceived(object sender, MessageEventArgs e) { - this._authenticationResult = AuthenticationResult.Success; + _authenticationResult = AuthenticationResult.Success; - this._authenticationCompleted.Set(); + _authenticationCompleted.Set(); } private void Session_UserAuthenticationFailureReceived(object sender, MessageEventArgs e) { if (e.Message.PartialSuccess) - this._authenticationResult = AuthenticationResult.PartialSuccess; + _authenticationResult = AuthenticationResult.PartialSuccess; else - this._authenticationResult = AuthenticationResult.Failure; + _authenticationResult = AuthenticationResult.Failure; // Copy allowed authentication methods - this.AllowedAuthentications = e.Message.AllowedAuthentications.ToList(); + AllowedAuthentications = e.Message.AllowedAuthentications.ToList(); - this._authenticationCompleted.Set(); + _authenticationCompleted.Set(); } #region IDisposable Members @@ -101,17 +101,17 @@ namespace Renci.SshNet protected virtual void Dispose(bool disposing) { // Check to see if Dispose has already been called. - if (!this._isDisposed) + if (!_isDisposed) { // If disposing equals true, dispose all managed // and unmanaged resources. if (disposing) { // Dispose managed resources. - if (this._authenticationCompleted != null) + if (_authenticationCompleted != null) { - this._authenticationCompleted.Dispose(); - this._authenticationCompleted = null; + _authenticationCompleted.Dispose(); + _authenticationCompleted = null; } } diff --git a/Renci.SshClient/Renci.SshNet/PasswordAuthenticationMethod.NET40.cs b/Renci.SshClient/Renci.SshNet/PasswordAuthenticationMethod.NET40.cs index 2242c4bb..6429b9bd 100644 --- a/Renci.SshClient/Renci.SshNet/PasswordAuthenticationMethod.NET40.cs +++ b/Renci.SshClient/Renci.SshNet/PasswordAuthenticationMethod.NET40.cs @@ -3,7 +3,7 @@ using System.Threading; namespace Renci.SshNet { - public partial class PasswordAuthenticationMethod : AuthenticationMethod + public partial class PasswordAuthenticationMethod { /// /// Executes the specified action in a separate thread. diff --git a/Renci.SshClient/Renci.SshNet/PasswordAuthenticationMethod.cs b/Renci.SshClient/Renci.SshNet/PasswordAuthenticationMethod.cs index e7849a5f..1a85892c 100644 --- a/Renci.SshClient/Renci.SshNet/PasswordAuthenticationMethod.cs +++ b/Renci.SshClient/Renci.SshNet/PasswordAuthenticationMethod.cs @@ -30,7 +30,7 @@ namespace Renci.SshNet /// public override string Name { - get { return this._requestMessage.MethodName; } + get { return _requestMessage.MethodName; } } /// @@ -63,9 +63,9 @@ namespace Renci.SshNet if (password == null) throw new ArgumentNullException("password"); - this._password = password; + _password = password; - this._requestMessage = new RequestMessagePassword(ServiceName.Connection, this.Username, this._password); + _requestMessage = new RequestMessagePassword(ServiceName.Connection, Username, _password); } /// @@ -81,7 +81,7 @@ namespace Renci.SshNet if (session == null) throw new ArgumentNullException("session"); - this._session = session; + _session = session; session.UserAuthenticationSuccessReceived += Session_UserAuthenticationSuccessReceived; session.UserAuthenticationFailureReceived += Session_UserAuthenticationFailureReceived; @@ -89,68 +89,68 @@ namespace Renci.SshNet session.RegisterMessage("SSH_MSG_USERAUTH_PASSWD_CHANGEREQ"); - session.SendMessage(this._requestMessage); + session.SendMessage(_requestMessage); - session.WaitOnHandle(this._authenticationCompleted); + session.WaitOnHandle(_authenticationCompleted); session.UserAuthenticationSuccessReceived -= Session_UserAuthenticationSuccessReceived; session.UserAuthenticationFailureReceived -= Session_UserAuthenticationFailureReceived; session.MessageReceived -= Session_MessageReceived; - if (this._exception != null) + if (_exception != null) { - throw this._exception; + throw _exception; } - return this._authenticationResult; + return _authenticationResult; } private void Session_UserAuthenticationSuccessReceived(object sender, MessageEventArgs e) { - this._authenticationResult = AuthenticationResult.Success; + _authenticationResult = AuthenticationResult.Success; - this._authenticationCompleted.Set(); + _authenticationCompleted.Set(); } private void Session_UserAuthenticationFailureReceived(object sender, MessageEventArgs e) { if (e.Message.PartialSuccess) - this._authenticationResult = AuthenticationResult.PartialSuccess; + _authenticationResult = AuthenticationResult.PartialSuccess; else - this._authenticationResult = AuthenticationResult.Failure; + _authenticationResult = AuthenticationResult.Failure; // Copy allowed authentication methods - this.AllowedAuthentications = e.Message.AllowedAuthentications.ToList(); + AllowedAuthentications = e.Message.AllowedAuthentications.ToList(); - this._authenticationCompleted.Set(); + _authenticationCompleted.Set(); } private void Session_MessageReceived(object sender, MessageEventArgs e) { if (e.Message is PasswordChangeRequiredMessage) { - this._session.UnRegisterMessage("SSH_MSG_USERAUTH_PASSWD_CHANGEREQ"); + _session.UnRegisterMessage("SSH_MSG_USERAUTH_PASSWD_CHANGEREQ"); - this.ExecuteThread(() => + ExecuteThread(() => { try { - var eventArgs = new AuthenticationPasswordChangeEventArgs(this.Username); + var eventArgs = new AuthenticationPasswordChangeEventArgs(Username); // Raise an event to allow user to supply a new password - if (this.PasswordExpired != null) + if (PasswordExpired != null) { - this.PasswordExpired(this, eventArgs); + PasswordExpired(this, eventArgs); } // Send new authentication request with new password - this._session.SendMessage(new RequestMessagePassword(ServiceName.Connection, this.Username, this._password, eventArgs.NewPassword)); + _session.SendMessage(new RequestMessagePassword(ServiceName.Connection, Username, _password, eventArgs.NewPassword)); } catch (Exception exp) { - this._exception = exp; - this._authenticationCompleted.Set(); + _exception = exp; + _authenticationCompleted.Set(); } }); } @@ -179,17 +179,17 @@ namespace Renci.SshNet protected virtual void Dispose(bool disposing) { // Check to see if Dispose has already been called. - if (!this._isDisposed) + if (!_isDisposed) { // If disposing equals true, dispose all managed // and unmanaged resources. if (disposing) { // Dispose managed resources. - if (this._authenticationCompleted != null) + if (_authenticationCompleted != null) { - this._authenticationCompleted.Dispose(); - this._authenticationCompleted = null; + _authenticationCompleted.Dispose(); + _authenticationCompleted = null; } } diff --git a/Renci.SshClient/Renci.SshNet/PasswordConnectionInfo.cs b/Renci.SshClient/Renci.SshNet/PasswordConnectionInfo.cs index 602b1108..f70d5fcf 100644 --- a/Renci.SshClient/Renci.SshNet/PasswordConnectionInfo.cs +++ b/Renci.SshClient/Renci.SshNet/PasswordConnectionInfo.cs @@ -35,7 +35,7 @@ namespace Renci.SshNet /// is null. /// is invalid, or is null or contains whitespace characters. public PasswordConnectionInfo(string host, string username, string password) - : this(host, ConnectionInfo.DEFAULT_PORT, username, Encoding.UTF8.GetBytes(password)) + : this(host, DefaultPort, username, Encoding.UTF8.GetBytes(password)) { } @@ -96,7 +96,7 @@ namespace Renci.SshNet /// The proxy host. /// The proxy port. public PasswordConnectionInfo(string host, string username, string password, ProxyTypes proxyType, string proxyHost, int proxyPort) - : this(host, ConnectionInfo.DEFAULT_PORT, username, Encoding.UTF8.GetBytes(password), proxyType, proxyHost, proxyPort, string.Empty, string.Empty) + : this(host, DefaultPort, username, Encoding.UTF8.GetBytes(password), proxyType, proxyHost, proxyPort, string.Empty, string.Empty) { } @@ -111,7 +111,7 @@ namespace Renci.SshNet /// The proxy port. /// The proxy username. public PasswordConnectionInfo(string host, string username, string password, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername) - : this(host, ConnectionInfo.DEFAULT_PORT, username, Encoding.UTF8.GetBytes(password), proxyType, proxyHost, proxyPort, proxyUsername, string.Empty) + : this(host, DefaultPort, username, Encoding.UTF8.GetBytes(password), proxyType, proxyHost, proxyPort, proxyUsername, string.Empty) { } @@ -127,7 +127,7 @@ namespace Renci.SshNet /// The proxy username. /// The proxy password. public PasswordConnectionInfo(string host, string username, string password, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername, string proxyPassword) - : this(host, ConnectionInfo.DEFAULT_PORT, username, Encoding.UTF8.GetBytes(password), proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword) + : this(host, DefaultPort, username, Encoding.UTF8.GetBytes(password), proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword) { } @@ -138,7 +138,7 @@ namespace Renci.SshNet /// Connection username. /// Connection password. public PasswordConnectionInfo(string host, string username, byte[] password) - : this(host, ConnectionInfo.DEFAULT_PORT, username, password) + : this(host, DefaultPort, username, password) { } @@ -199,7 +199,7 @@ namespace Renci.SshNet /// The proxy host. /// The proxy port. public PasswordConnectionInfo(string host, string username, byte[] password, ProxyTypes proxyType, string proxyHost, int proxyPort) - : this(host, ConnectionInfo.DEFAULT_PORT, username, password, proxyType, proxyHost, proxyPort, string.Empty, string.Empty) + : this(host, DefaultPort, username, password, proxyType, proxyHost, proxyPort, string.Empty, string.Empty) { } @@ -214,7 +214,7 @@ namespace Renci.SshNet /// The proxy port. /// The proxy username. public PasswordConnectionInfo(string host, string username, byte[] password, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername) - : this(host, ConnectionInfo.DEFAULT_PORT, username, password, proxyType, proxyHost, proxyPort, proxyUsername, string.Empty) + : this(host, DefaultPort, username, password, proxyType, proxyHost, proxyPort, proxyUsername, string.Empty) { } @@ -230,7 +230,7 @@ namespace Renci.SshNet /// The proxy username. /// The proxy password. public PasswordConnectionInfo(string host, string username, byte[] password, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername, string proxyPassword) - : this(host, ConnectionInfo.DEFAULT_PORT, username, password, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword) + : this(host, DefaultPort, username, password, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword) { } @@ -249,7 +249,7 @@ namespace Renci.SshNet public PasswordConnectionInfo(string host, int port, string username, byte[] password, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername, string proxyPassword) : base(host, port, username, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword, new PasswordAuthenticationMethod(username, password)) { - foreach (var authenticationMethod in this.AuthenticationMethods.OfType()) + foreach (var authenticationMethod in AuthenticationMethods.OfType()) { authenticationMethod.PasswordExpired += AuthenticationMethod_PasswordExpired; } @@ -257,9 +257,9 @@ namespace Renci.SshNet private void AuthenticationMethod_PasswordExpired(object sender, AuthenticationPasswordChangeEventArgs e) { - if (this.PasswordExpired != null) + if (PasswordExpired != null) { - this.PasswordExpired(sender, e); + PasswordExpired(sender, e); } } @@ -284,16 +284,16 @@ namespace Renci.SshNet protected virtual void Dispose(bool disposing) { // Check to see if Dispose has already been called. - if (!this._isDisposed) + if (!_isDisposed) { // If disposing equals true, dispose all managed // and unmanaged resources. if (disposing) { // Dispose managed resources. - if (this.AuthenticationMethods != null) + if (AuthenticationMethods != null) { - foreach (var authenticationMethods in this.AuthenticationMethods.OfType()) + foreach (var authenticationMethods in AuthenticationMethods.OfType()) { authenticationMethods.Dispose(); } diff --git a/Renci.SshClient/Renci.SshNet/PrivateKeyAuthenticationMethod.cs b/Renci.SshClient/Renci.SshNet/PrivateKeyAuthenticationMethod.cs index 3fd7c4d7..f5095643 100644 --- a/Renci.SshClient/Renci.SshNet/PrivateKeyAuthenticationMethod.cs +++ b/Renci.SshClient/Renci.SshNet/PrivateKeyAuthenticationMethod.cs @@ -45,7 +45,7 @@ namespace Renci.SshNet if (keyFiles == null) throw new ArgumentNullException("keyFiles"); - this.KeyFiles = new Collection(keyFiles); + KeyFiles = new Collection(keyFiles); } /// @@ -63,14 +63,14 @@ namespace Renci.SshNet session.RegisterMessage("SSH_MSG_USERAUTH_PK_OK"); - foreach (var keyFile in this.KeyFiles) + foreach (var keyFile in KeyFiles) { - this._authenticationCompleted.Reset(); - this._isSignatureRequired = false; + _authenticationCompleted.Reset(); + _isSignatureRequired = false; - var message = new RequestMessagePublicKey(ServiceName.Connection, this.Username, keyFile.HostKey.Name, keyFile.HostKey.Data); + var message = new RequestMessagePublicKey(ServiceName.Connection, Username, keyFile.HostKey.Name, keyFile.HostKey.Data); - if (this.KeyFiles.Count < 2) + if (KeyFiles.Count < 2) { // If only one key file provided then send signature for very first request var signatureData = new SignatureData(message, session.SessionId).GetBytes(); @@ -81,13 +81,13 @@ namespace Renci.SshNet // Send public key authentication request session.SendMessage(message); - session.WaitOnHandle(this._authenticationCompleted); + session.WaitOnHandle(_authenticationCompleted); - if (this._isSignatureRequired) + if (_isSignatureRequired) { - this._authenticationCompleted.Reset(); + _authenticationCompleted.Reset(); - var signatureMessage = new RequestMessagePublicKey(ServiceName.Connection, this.Username, keyFile.HostKey.Name, keyFile.HostKey.Data); + var signatureMessage = new RequestMessagePublicKey(ServiceName.Connection, Username, keyFile.HostKey.Name, keyFile.HostKey.Data); var signatureData = new SignatureData(message, session.SessionId).GetBytes(); @@ -97,9 +97,9 @@ namespace Renci.SshNet session.SendMessage(signatureMessage); } - session.WaitOnHandle(this._authenticationCompleted); + session.WaitOnHandle(_authenticationCompleted); - if (this._authenticationResult == AuthenticationResult.Success) + if (_authenticationResult == AuthenticationResult.Success) { break; } @@ -111,27 +111,27 @@ namespace Renci.SshNet session.UnRegisterMessage("SSH_MSG_USERAUTH_PK_OK"); - return this._authenticationResult; + return _authenticationResult; } private void Session_UserAuthenticationSuccessReceived(object sender, MessageEventArgs e) { - this._authenticationResult = AuthenticationResult.Success; + _authenticationResult = AuthenticationResult.Success; - this._authenticationCompleted.Set(); + _authenticationCompleted.Set(); } private void Session_UserAuthenticationFailureReceived(object sender, MessageEventArgs e) { if (e.Message.PartialSuccess) - this._authenticationResult = AuthenticationResult.PartialSuccess; + _authenticationResult = AuthenticationResult.PartialSuccess; else - this._authenticationResult = AuthenticationResult.Failure; + _authenticationResult = AuthenticationResult.Failure; // Copy allowed authentication methods - this.AllowedAuthentications = e.Message.AllowedAuthentications.ToList(); + AllowedAuthentications = e.Message.AllowedAuthentications.ToList(); - this._authenticationCompleted.Set(); + _authenticationCompleted.Set(); } private void Session_MessageReceived(object sender, MessageEventArgs e) @@ -139,8 +139,8 @@ namespace Renci.SshNet var publicKeyMessage = e.Message as PublicKeyMessage; if (publicKeyMessage != null) { - this._isSignatureRequired = true; - this._authenticationCompleted.Set(); + _isSignatureRequired = true; + _authenticationCompleted.Set(); } } @@ -165,17 +165,17 @@ namespace Renci.SshNet protected virtual void Dispose(bool disposing) { // Check to see if Dispose has already been called. - if (!this._isDisposed) + if (!_isDisposed) { // If disposing equals true, dispose all managed // and unmanaged resources. if (disposing) { // Dispose managed resources. - if (this._authenticationCompleted != null) + if (_authenticationCompleted != null) { - this._authenticationCompleted.Dispose(); - this._authenticationCompleted = null; + _authenticationCompleted.Dispose(); + _authenticationCompleted = null; } } @@ -206,8 +206,8 @@ namespace Renci.SshNet public SignatureData(RequestMessagePublicKey message, byte[] sessionId) { - this._message = message; - this._sessionId = sessionId; + _message = message; + _sessionId = sessionId; } protected override void LoadData() @@ -217,14 +217,14 @@ namespace Renci.SshNet protected override void SaveData() { - this.WriteBinaryString(this._sessionId); - this.Write((byte)50); - this.Write(this._message.Username); - this.WriteAscii("ssh-connection"); - this.WriteAscii("publickey"); - this.Write((byte)1); - this.WriteAscii(this._message.PublicKeyAlgorithmName); - this.WriteBinaryString(this._message.PublicKeyData); + WriteBinaryString(_sessionId); + Write((byte)50); + Write(_message.Username); + WriteAscii("ssh-connection"); + WriteAscii("publickey"); + Write((byte)1); + WriteAscii(_message.PublicKeyAlgorithmName); + WriteBinaryString(_message.PublicKeyData); } } diff --git a/Renci.SshClient/Renci.SshNet/PrivateKeyConnectionInfo.cs b/Renci.SshClient/Renci.SshNet/PrivateKeyConnectionInfo.cs index 1c441cb3..96799f57 100644 --- a/Renci.SshClient/Renci.SshNet/PrivateKeyConnectionInfo.cs +++ b/Renci.SshClient/Renci.SshNet/PrivateKeyConnectionInfo.cs @@ -29,7 +29,7 @@ namespace Renci.SshNet /// /// public PrivateKeyConnectionInfo(string host, string username, params PrivateKeyFile[] keyFiles) - : this(host, ConnectionInfo.DEFAULT_PORT, username, ProxyTypes.None, string.Empty, 0, string.Empty, string.Empty, keyFiles) + : this(host, ConnectionInfo.DefaultPort, username, ProxyTypes.None, string.Empty, 0, string.Empty, string.Empty, keyFiles) { } @@ -87,7 +87,7 @@ namespace Renci.SshNet /// The proxy port. /// The key files. public PrivateKeyConnectionInfo(string host, string username, ProxyTypes proxyType, string proxyHost, int proxyPort, params PrivateKeyFile[] keyFiles) - : this(host, ConnectionInfo.DEFAULT_PORT, username, proxyType, proxyHost, proxyPort, string.Empty, string.Empty, keyFiles) + : this(host, ConnectionInfo.DefaultPort, username, proxyType, proxyHost, proxyPort, string.Empty, string.Empty, keyFiles) { } @@ -102,7 +102,7 @@ namespace Renci.SshNet /// The proxy username. /// The key files. public PrivateKeyConnectionInfo(string host, string username, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername, params PrivateKeyFile[] keyFiles) - : this(host, ConnectionInfo.DEFAULT_PORT, username, proxyType, proxyHost, proxyPort, proxyUsername, string.Empty, keyFiles) + : this(host, ConnectionInfo.DefaultPort, username, proxyType, proxyHost, proxyPort, proxyUsername, string.Empty, keyFiles) { } @@ -118,7 +118,7 @@ namespace Renci.SshNet /// The proxy password. /// The key files. public PrivateKeyConnectionInfo(string host, string username, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername, string proxyPassword, params PrivateKeyFile[] keyFiles) - : this(host, ConnectionInfo.DEFAULT_PORT, username, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword, keyFiles) + : this(host, ConnectionInfo.DefaultPort, username, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword, keyFiles) { } diff --git a/Renci.SshClient/Renci.SshNet/PrivateKeyFile.cs b/Renci.SshClient/Renci.SshNet/PrivateKeyFile.cs index fd339b74..d549250a 100644 --- a/Renci.SshClient/Renci.SshNet/PrivateKeyFile.cs +++ b/Renci.SshClient/Renci.SshNet/PrivateKeyFile.cs @@ -71,7 +71,7 @@ namespace Renci.SshNet /// The private key. public PrivateKeyFile(Stream privateKey) { - this.Open(privateKey, null); + Open(privateKey, null); } /// @@ -99,7 +99,7 @@ namespace Renci.SshNet using (var keyFile = File.Open(fileName, FileMode.Open, FileAccess.Read, FileShare.Read)) { - this.Open(keyFile, passPhrase); + Open(keyFile, passPhrase); } } @@ -111,7 +111,7 @@ namespace Renci.SshNet /// or is null. public PrivateKeyFile(Stream privateKey, string passPhrase) { - this.Open(privateKey, passPhrase); + Open(privateKey, passPhrase); } /// @@ -191,12 +191,12 @@ namespace Renci.SshNet switch (keyName) { case "RSA": - this._key = new RsaKey(decryptedData.ToArray()); - this.HostKey = new KeyHostAlgorithm("ssh-rsa", this._key); + _key = new RsaKey(decryptedData.ToArray()); + HostKey = new KeyHostAlgorithm("ssh-rsa", _key); break; case "DSA": - this._key = new DsaKey(decryptedData.ToArray()); - this.HostKey = new KeyHostAlgorithm("ssh-dss", this._key); + _key = new DsaKey(decryptedData.ToArray()); + HostKey = new KeyHostAlgorithm("ssh-dss", _key); break; case "SSH2 ENCRYPTED": var reader = new SshDataReader(decryptedData); @@ -247,8 +247,8 @@ namespace Renci.SshNet var inverseQ = reader.ReadBigIntWithBits();//u var q = reader.ReadBigIntWithBits();//p var p = reader.ReadBigIntWithBits();//q - this._key = new RsaKey(modulus, exponent, d, p, q, inverseQ); - this.HostKey = new KeyHostAlgorithm("ssh-rsa", this._key); + _key = new RsaKey(modulus, exponent, d, p, q, inverseQ); + HostKey = new KeyHostAlgorithm("ssh-rsa", _key); } else if (keyType == "dl-modp{sign{dsa-nist-sha1},dh{plain}}") { @@ -262,8 +262,8 @@ namespace Renci.SshNet var q = reader.ReadBigIntWithBits(); var y = reader.ReadBigIntWithBits(); var x = reader.ReadBigIntWithBits(); - this._key = new DsaKey(p, q, g, y, x); - this.HostKey = new KeyHostAlgorithm("ssh-dss", this._key); + _key = new DsaKey(p, q, g, y, x); + HostKey = new KeyHostAlgorithm("ssh-dss", _key); } else { @@ -364,17 +364,17 @@ namespace Renci.SshNet protected virtual void Dispose(bool disposing) { // Check to see if Dispose has already been called. - if (!this._isDisposed) + if (!_isDisposed) { // If disposing equals true, dispose all managed // and unmanaged ResourceMessages. if (disposing) { // Dispose managed ResourceMessages. - if (this._key != null) + if (_key != null) { - ((IDisposable)this._key).Dispose(); - this._key = null; + ((IDisposable)_key).Dispose(); + _key = null; } } @@ -401,7 +401,7 @@ namespace Renci.SshNet { public SshDataReader(byte[] data) { - this.LoadBytes(data); + LoadBytes(data); } public new UInt32 ReadUInt32() diff --git a/Renci.SshClient/Renci.SshNet/ScpClient.NET.cs b/Renci.SshClient/Renci.SshNet/ScpClient.NET.cs index 06b0a61f..4a85bd96 100644 --- a/Renci.SshClient/Renci.SshNet/ScpClient.NET.cs +++ b/Renci.SshClient/Renci.SshNet/ScpClient.NET.cs @@ -1,4 +1,5 @@ using System; +using System.Text; using Renci.SshNet.Channels; using System.IO; using Renci.SshNet.Common; @@ -11,8 +12,8 @@ namespace Renci.SshNet /// public partial class ScpClient { - private static readonly Regex _directoryInfoRe = new Regex(@"D(?\d{4}) (?\d+) (?.+)"); - private static readonly Regex _timestampRe = new Regex(@"T(?\d+) 0 (?\d+) 0"); + private static readonly Regex DirectoryInfoRe = new Regex(@"D(?\d{4}) (?\d+) (?.+)"); + private static readonly Regex TimestampRe = new Regex(@"T(?\d+) 0 (?\d+) 0"); /// /// Uploads the specified file to the remote host. @@ -29,7 +30,7 @@ namespace Renci.SshNet throw new ArgumentException("path"); using (var input = ServiceFactory.CreatePipeStream()) - using (var channel = this.Session.CreateChannelSession()) + using (var channel = Session.CreateChannelSession()) { channel.DataReceived += delegate(object sender, ChannelDataEventArgs e) { @@ -42,9 +43,9 @@ namespace Renci.SshNet if (!channel.SendExecRequest(string.Format("scp -t \"{0}\"", path))) throw new SshException("Secure copy execution request was rejected by the server. Please consult the server logs."); - this.CheckReturnCode(input); + CheckReturnCode(input); - this.InternalUpload(channel, input, fileInfo, fileInfo.Name); + InternalUpload(channel, input, fileInfo, fileInfo.Name); channel.Close(); } @@ -65,7 +66,7 @@ namespace Renci.SshNet throw new ArgumentException("path"); using (var input = new PipeStream()) - using (var channel = this.Session.CreateChannelSession()) + using (var channel = Session.CreateChannelSession()) { channel.DataReceived += delegate(object sender, ChannelDataEventArgs e) { @@ -77,16 +78,16 @@ namespace Renci.SshNet // Send channel command request channel.SendExecRequest(string.Format("scp -rt \"{0}\"", path)); - this.CheckReturnCode(input); + CheckReturnCode(input); - this.InternalSetTimestamp(channel, input, directoryInfo.LastWriteTimeUtc, directoryInfo.LastAccessTimeUtc); - this.SendData(channel, string.Format("D0755 0 {0}\n", Path.GetFileName(path))); - this.CheckReturnCode(input); + InternalSetTimestamp(channel, input, directoryInfo.LastWriteTimeUtc, directoryInfo.LastAccessTimeUtc); + SendData(channel, string.Format("D0755 0 {0}\n", Path.GetFileName(path))); + CheckReturnCode(input); - this.InternalUpload(channel, input, directoryInfo); + InternalUpload(channel, input, directoryInfo); - this.SendData(channel, "E\n"); - this.CheckReturnCode(input); + SendData(channel, "E\n"); + CheckReturnCode(input); channel.Close(); } @@ -107,7 +108,7 @@ namespace Renci.SshNet throw new ArgumentNullException("fileInfo"); using (var input = new PipeStream()) - using (var channel = this.Session.CreateChannelSession()) + using (var channel = Session.CreateChannelSession()) { channel.DataReceived += delegate(object sender, ChannelDataEventArgs e) { @@ -119,9 +120,9 @@ namespace Renci.SshNet // Send channel command request channel.SendExecRequest(string.Format("scp -pf \"{0}\"", filename)); - this.SendConfirmation(channel); // Send reply + SendConfirmation(channel); // Send reply - this.InternalDownload(channel, input, fileInfo); + InternalDownload(channel, input, fileInfo); channel.Close(); } @@ -142,7 +143,7 @@ namespace Renci.SshNet throw new ArgumentNullException("directoryInfo"); using (var input = new PipeStream()) - using (var channel = this.Session.CreateChannelSession()) + using (var channel = Session.CreateChannelSession()) { channel.DataReceived += delegate(object sender, ChannelDataEventArgs e) { @@ -154,9 +155,9 @@ namespace Renci.SshNet // Send channel command request channel.SendExecRequest(string.Format("scp -prf \"{0}\"", directoryName)); - this.SendConfirmation(channel); // Send reply + SendConfirmation(channel); // Send reply - this.InternalDownload(channel, input, directoryInfo); + InternalDownload(channel, input, directoryInfo); channel.Close(); } @@ -164,10 +165,10 @@ namespace Renci.SshNet private void InternalUpload(IChannelSession channel, Stream input, FileInfo fileInfo, string filename) { - this.InternalSetTimestamp(channel, input, fileInfo.LastWriteTimeUtc, fileInfo.LastAccessTimeUtc); + InternalSetTimestamp(channel, input, fileInfo.LastWriteTimeUtc, fileInfo.LastAccessTimeUtc); using (var source = fileInfo.OpenRead()) { - this.InternalUpload(channel, input, source, filename); + InternalUpload(channel, input, source, filename); } } @@ -177,28 +178,28 @@ namespace Renci.SshNet var files = directoryInfo.GetFiles(); foreach (var file in files) { - this.InternalUpload(channel, input, file, file.Name); + InternalUpload(channel, input, file, file.Name); } // Upload directories var directories = directoryInfo.GetDirectories(); foreach (var directory in directories) { - this.InternalSetTimestamp(channel, input, directoryInfo.LastWriteTimeUtc, directoryInfo.LastAccessTimeUtc); - this.SendData(channel, string.Format("D0755 0 {0}\n", directory.Name)); - this.CheckReturnCode(input); + InternalSetTimestamp(channel, input, directoryInfo.LastWriteTimeUtc, directoryInfo.LastAccessTimeUtc); + SendData(channel, string.Format("D0755 0 {0}\n", directory.Name)); + CheckReturnCode(input); - this.InternalUpload(channel, input, directory); + InternalUpload(channel, input, directory); - this.SendData(channel, "E\n"); - this.CheckReturnCode(input); + SendData(channel, "E\n"); + CheckReturnCode(input); } } private void InternalDownload(IChannelSession channel, Stream input, FileSystemInfo fileSystemInfo) { - DateTime modifiedTime = DateTime.Now; - DateTime accessedTime = DateTime.Now; + var modifiedTime = DateTime.Now; + var accessedTime = DateTime.Now; var startDirectoryFullName = fileSystemInfo.FullName; var currentDirectoryFullName = startDirectoryFullName; @@ -210,7 +211,7 @@ namespace Renci.SshNet if (message == "E") { - this.SendConfirmation(channel); // Send reply + SendConfirmation(channel); // Send reply directoryCounter--; @@ -221,10 +222,10 @@ namespace Renci.SshNet continue; } - var match = _directoryInfoRe.Match(message); + var match = DirectoryInfoRe.Match(message); if (match.Success) { - this.SendConfirmation(channel); // Send reply + SendConfirmation(channel); // Send reply // Read directory var mode = long.Parse(match.Result("${mode}")); @@ -249,11 +250,11 @@ namespace Renci.SshNet continue; } - match = _fileInfoRe.Match(message); + match = FileInfoRe.Match(message); if (match.Success) { // Read file - this.SendConfirmation(channel); // Send reply + SendConfirmation(channel); // Send reply var mode = match.Result("${mode}"); var length = long.Parse(match.Result("${length}")); @@ -266,7 +267,7 @@ namespace Renci.SshNet using (var output = fileInfo.OpenWrite()) { - this.InternalDownload(channel, input, output, fileName, length); + InternalDownload(channel, input, output, fileName, length); } fileInfo.LastAccessTime = accessedTime; @@ -277,11 +278,11 @@ namespace Renci.SshNet continue; } - match = _timestampRe.Match(message); + match = TimestampRe.Match(message); if (match.Success) { // Read timestamp - this.SendConfirmation(channel); // Send reply + SendConfirmation(channel); // Send reply var mtime = long.Parse(match.Result("${mtime}")); var atime = long.Parse(match.Result("${atime}")); @@ -292,13 +293,13 @@ namespace Renci.SshNet continue; } - this.SendConfirmation(channel, 1, string.Format("\"{0}\" is not valid protocol message.", message)); + SendConfirmation(channel, 1, string.Format("\"{0}\" is not valid protocol message.", message)); } } partial void SendData(IChannelSession channel, string command) { - channel.SendData(System.Text.Encoding.Default.GetBytes(command)); + channel.SendData(Encoding.Default.GetBytes(command)); } } } diff --git a/Renci.SshClient/Renci.SshNet/ScpClient.cs b/Renci.SshClient/Renci.SshNet/ScpClient.cs index 781d4378..cf8310eb 100644 --- a/Renci.SshClient/Renci.SshNet/ScpClient.cs +++ b/Renci.SshClient/Renci.SshNet/ScpClient.cs @@ -15,7 +15,7 @@ namespace Renci.SshNet /// public partial class ScpClient : BaseClient { - private static readonly Regex _fileInfoRe = new Regex(@"C(?\d{4}) (?\d+) (?.+)"); + private static readonly Regex FileInfoRe = new Regex(@"C(?\d{4}) (?\d+) (?.+)"); private static char[] _byteToChar; /// @@ -82,7 +82,7 @@ namespace Renci.SshNet /// is null. /// is invalid, or is null or contains whitespace characters. public ScpClient(string host, string username, string password) - : this(host, ConnectionInfo.DEFAULT_PORT, username, password) + : this(host, ConnectionInfo.DefaultPort, username, password) { } @@ -111,7 +111,7 @@ namespace Renci.SshNet /// is null. /// is invalid, -or- is null or contains whitespace characters. public ScpClient(string host, string username, params PrivateKeyFile[] keyFiles) - : this(host, ConnectionInfo.DEFAULT_PORT, username, keyFiles) + : this(host, ConnectionInfo.DefaultPort, username, keyFiles) { } @@ -145,14 +145,14 @@ namespace Renci.SshNet internal ScpClient(ConnectionInfo connectionInfo, bool ownsConnectionInfo, IServiceFactory serviceFactory) : base(connectionInfo, ownsConnectionInfo, serviceFactory) { - this.OperationTimeout = new TimeSpan(0, 0, 0, 0, -1); - this.BufferSize = 1024 * 16; + OperationTimeout = new TimeSpan(0, 0, 0, 0, -1); + BufferSize = 1024 * 16; if (_byteToChar == null) { _byteToChar = new char[128]; var ch = '\0'; - for (int i = 0; i < 128; i++) + for (var i = 0; i < 128; i++) { _byteToChar[i] = ch++; } @@ -169,7 +169,7 @@ namespace Renci.SshNet public void Upload(Stream source, string path) { using (var input = ServiceFactory.CreatePipeStream()) - using (var channel = this.Session.CreateChannelSession()) + using (var channel = Session.CreateChannelSession()) { channel.DataReceived += delegate(object sender, ChannelDataEventArgs e) { @@ -179,20 +179,20 @@ namespace Renci.SshNet channel.Open(); - int pathEnd = path.LastIndexOfAny(new[] { '\\', '/' }); + var pathEnd = path.LastIndexOfAny(new[] { '\\', '/' }); if (pathEnd != -1) { // split the path from the file - string pathOnly = path.Substring(0, pathEnd); - string fileOnly = path.Substring(pathEnd + 1); + var pathOnly = path.Substring(0, pathEnd); + var fileOnly = path.Substring(pathEnd + 1); // Send channel command request channel.SendExecRequest(string.Format("scp -t \"{0}\"", pathOnly)); - this.CheckReturnCode(input); + CheckReturnCode(input); path = fileOnly; } - this.InternalUpload(channel, input, source, path); + InternalUpload(channel, input, source, path); channel.Close(); } @@ -215,7 +215,7 @@ namespace Renci.SshNet throw new ArgumentNullException("destination"); using (var input = new PipeStream()) - using (var channel = this.Session.CreateChannelSession()) + using (var channel = Session.CreateChannelSession()) { channel.DataReceived += delegate(object sender, ChannelDataEventArgs e) { @@ -227,25 +227,25 @@ namespace Renci.SshNet // Send channel command request channel.SendExecRequest(string.Format("scp -f \"{0}\"", filename)); - this.SendConfirmation(channel); // Send reply + SendConfirmation(channel); // Send reply var message = ReadString(input); - var match = _fileInfoRe.Match(message); + var match = FileInfoRe.Match(message); if (match.Success) { // Read file - this.SendConfirmation(channel); // Send reply + SendConfirmation(channel); // Send reply var mode = match.Result("${mode}"); var length = long.Parse(match.Result("${length}")); var fileName = match.Result("${filename}"); - this.InternalDownload(channel, input, destination, fileName, length); + InternalDownload(channel, input, destination, fileName, length); } else { - this.SendConfirmation(channel, 1, string.Format("\"{0}\" is not valid protocol message.", message)); + SendConfirmation(channel, 1, string.Format("\"{0}\" is not valid protocol message.", message)); } channel.Close(); @@ -257,18 +257,18 @@ namespace Renci.SshNet var zeroTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); var modificationSeconds = (long)(lastWriteTime - zeroTime).TotalSeconds; var accessSeconds = (long)(lastAccessime - zeroTime).TotalSeconds; - this.SendData(channel, string.Format("T{0} 0 {1} 0\n", modificationSeconds, accessSeconds)); - this.CheckReturnCode(input); + SendData(channel, string.Format("T{0} 0 {1} 0\n", modificationSeconds, accessSeconds)); + CheckReturnCode(input); } private void InternalUpload(IChannelSession channel, Stream input, Stream source, string filename) { var length = source.Length; - this.SendData(channel, string.Format("C0644 {0} {1}\n", length, Path.GetFileName(filename))); - this.CheckReturnCode(input); + SendData(channel, string.Format("C0644 {0} {1}\n", length, Path.GetFileName(filename))); + CheckReturnCode(input); - var buffer = new byte[this.BufferSize]; + var buffer = new byte[BufferSize]; var read = source.Read(buffer, 0, buffer.Length); @@ -276,31 +276,31 @@ namespace Renci.SshNet while (read > 0) { - this.SendData(channel, buffer, read); + SendData(channel, buffer, read); totalRead += read; - this.RaiseUploadingEvent(filename, length, totalRead); + RaiseUploadingEvent(filename, length, totalRead); read = source.Read(buffer, 0, buffer.Length); } - this.SendConfirmation(channel); - this.CheckReturnCode(input); + SendConfirmation(channel); + CheckReturnCode(input); } private void InternalDownload(IChannelSession channel, Stream input, Stream output, string filename, long length) { - var buffer = new byte[Math.Min(length, this.BufferSize)]; + var buffer = new byte[Math.Min(length, BufferSize)]; var needToRead = length; do { - var read = input.Read(buffer, 0, (int)Math.Min(needToRead, this.BufferSize)); + var read = input.Read(buffer, 0, (int)Math.Min(needToRead, BufferSize)); output.Write(buffer, 0, read); - this.RaiseDownloadingEvent(filename, length, length - needToRead); + RaiseDownloadingEvent(filename, length, length - needToRead); needToRead -= read; } @@ -309,39 +309,39 @@ namespace Renci.SshNet output.Flush(); // Raise one more time when file downloaded - this.RaiseDownloadingEvent(filename, length, length - needToRead); + RaiseDownloadingEvent(filename, length, length - needToRead); // Send confirmation byte after last data byte was read - this.SendConfirmation(channel); + SendConfirmation(channel); - this.CheckReturnCode(input); + CheckReturnCode(input); } private void RaiseDownloadingEvent(string filename, long size, long downloaded) { - if (this.Downloading != null) + if (Downloading != null) { - this.Downloading(this, new ScpDownloadEventArgs(filename, size, downloaded)); + Downloading(this, new ScpDownloadEventArgs(filename, size, downloaded)); } } private void RaiseUploadingEvent(string filename, long size, long uploaded) { - if (this.Uploading != null) + if (Uploading != null) { - this.Uploading(this, new ScpUploadEventArgs(filename, size, uploaded)); + Uploading(this, new ScpUploadEventArgs(filename, size, uploaded)); } } private void SendConfirmation(IChannelSession channel) { - this.SendData(channel, new byte[] { 0 }); + SendData(channel, new byte[] { 0 }); } private void SendConfirmation(IChannelSession channel, byte errorCode, string message) { - this.SendData(channel, new[] { errorCode }); - this.SendData(channel, string.Format("{0}\n", message)); + SendData(channel, new[] { errorCode }); + SendData(channel, string.Format("{0}\n", message)); } /// diff --git a/Renci.SshClient/Renci.SshNet/Session.NET40.cs b/Renci.SshClient/Renci.SshNet/Session.NET40.cs index 36ed2644..3f6f254d 100644 --- a/Renci.SshClient/Renci.SshNet/Session.NET40.cs +++ b/Renci.SshClient/Renci.SshNet/Session.NET40.cs @@ -13,7 +13,7 @@ namespace Renci.SshNet { partial void HandleMessageCore(Message message) { - this.HandleMessage((dynamic)message); + HandleMessage((dynamic)message); } /// @@ -27,20 +27,20 @@ namespace Renci.SshNet partial void InternalRegisterMessage(string messageName) { - lock (this._messagesMetadata) + lock (_messagesMetadata) { Parallel.ForEach( - from m in this._messagesMetadata where m.Name == messageName select m, + from m in _messagesMetadata where m.Name == messageName select m, item => { item.Enabled = true; item.Activated = true; }); } } partial void InternalUnRegisterMessage(string messageName) { - lock (this._messagesMetadata) + lock (_messagesMetadata) { Parallel.ForEach( - from m in this._messagesMetadata where m.Name == messageName select m, + from m in _messagesMetadata where m.Name == messageName select m, item => { item.Enabled = false; item.Activated = false; }); } } diff --git a/Renci.SshClient/Renci.SshNet/Sftp/SftpDataMessage.cs b/Renci.SshClient/Renci.SshNet/Sftp/SftpDataMessage.cs index bd29c798..8732b03e 100644 --- a/Renci.SshClient/Renci.SshNet/Sftp/SftpDataMessage.cs +++ b/Renci.SshClient/Renci.SshNet/Sftp/SftpDataMessage.cs @@ -1,4 +1,5 @@ -using Renci.SshNet.Messages.Connection; +using Renci.SshNet.Common; +using Renci.SshNet.Messages.Connection; namespace Renci.SshNet.Sftp { @@ -6,15 +7,15 @@ namespace Renci.SshNet.Sftp { public SftpDataMessage(uint localChannelNumber, SftpMessage sftpMessage) { - this.LocalChannelNumber = localChannelNumber; + LocalChannelNumber = localChannelNumber; var messageData = sftpMessage.GetBytes(); var data = new byte[4 + messageData.Length]; - ((uint)messageData.Length).GetBytes().CopyTo(data, 0); + ((uint) messageData.Length).GetBytes().CopyTo(data, 0); messageData.CopyTo(data, 4); - this.Data = data; + Data = data; } } } diff --git a/Renci.SshClient/Renci.SshNet/Sftp/SftpDownloadAsyncResult.cs b/Renci.SshClient/Renci.SshNet/Sftp/SftpDownloadAsyncResult.cs index 91e98c29..8ea757c3 100644 --- a/Renci.SshClient/Renci.SshNet/Sftp/SftpDownloadAsyncResult.cs +++ b/Renci.SshClient/Renci.SshNet/Sftp/SftpDownloadAsyncResult.cs @@ -40,7 +40,7 @@ namespace Renci.SshNet.Sftp /// Number of downloaded bytes. internal void Update(ulong downloadedBytes) { - this.DownloadedBytes = downloadedBytes; + DownloadedBytes = downloadedBytes; } } } diff --git a/Renci.SshClient/Renci.SshNet/Sftp/SftpFile.cs b/Renci.SshClient/Renci.SshNet/Sftp/SftpFile.cs index 870e7382..9b61049e 100644 --- a/Renci.SshClient/Renci.SshNet/Sftp/SftpFile.cs +++ b/Renci.SshClient/Renci.SshNet/Sftp/SftpFile.cs @@ -35,12 +35,12 @@ namespace Renci.SshNet.Sftp if (fullName == null) throw new ArgumentNullException("fullName"); - this._sftpSession = sftpSession; - this.Attributes = attributes; + _sftpSession = sftpSession; + Attributes = attributes; - this.Name = fullName.Substring(fullName.LastIndexOf('/') + 1); + Name = fullName.Substring(fullName.LastIndexOf('/') + 1); - this.FullName = fullName; + FullName = fullName; } /// @@ -64,11 +64,11 @@ namespace Renci.SshNet.Sftp { get { - return this.Attributes.LastAccessTime; + return Attributes.LastAccessTime; } set { - this.Attributes.LastAccessTime = value; + Attributes.LastAccessTime = value; } } @@ -82,11 +82,11 @@ namespace Renci.SshNet.Sftp { get { - return this.Attributes.LastWriteTime; + return Attributes.LastWriteTime; } set { - this.Attributes.LastWriteTime = value; + Attributes.LastWriteTime = value; } } @@ -100,11 +100,11 @@ namespace Renci.SshNet.Sftp { get { - return this.Attributes.LastAccessTime.ToUniversalTime(); + return Attributes.LastAccessTime.ToUniversalTime(); } set { - this.Attributes.LastAccessTime = value.ToLocalTime(); + Attributes.LastAccessTime = value.ToLocalTime(); } } @@ -118,11 +118,11 @@ namespace Renci.SshNet.Sftp { get { - return this.Attributes.LastWriteTime.ToUniversalTime(); + return Attributes.LastWriteTime.ToUniversalTime(); } set { - this.Attributes.LastWriteTime = value.ToLocalTime(); + Attributes.LastWriteTime = value.ToLocalTime(); } } @@ -136,7 +136,7 @@ namespace Renci.SshNet.Sftp { get { - return this.Attributes.Size; + return Attributes.Size; } } @@ -150,11 +150,11 @@ namespace Renci.SshNet.Sftp { get { - return this.Attributes.UserId; + return Attributes.UserId; } set { - this.Attributes.UserId = value; + Attributes.UserId = value; } } @@ -168,11 +168,11 @@ namespace Renci.SshNet.Sftp { get { - return this.Attributes.GroupId; + return Attributes.GroupId; } set { - this.Attributes.GroupId = value; + Attributes.GroupId = value; } } @@ -186,7 +186,7 @@ namespace Renci.SshNet.Sftp { get { - return this.Attributes.IsSocket; + return Attributes.IsSocket; } } @@ -200,7 +200,7 @@ namespace Renci.SshNet.Sftp { get { - return this.Attributes.IsSymbolicLink; + return Attributes.IsSymbolicLink; } } @@ -214,7 +214,7 @@ namespace Renci.SshNet.Sftp { get { - return this.Attributes.IsRegularFile; + return Attributes.IsRegularFile; } } @@ -228,7 +228,7 @@ namespace Renci.SshNet.Sftp { get { - return this.Attributes.IsBlockDevice; + return Attributes.IsBlockDevice; } } @@ -242,7 +242,7 @@ namespace Renci.SshNet.Sftp { get { - return this.Attributes.IsDirectory; + return Attributes.IsDirectory; } } @@ -256,7 +256,7 @@ namespace Renci.SshNet.Sftp { get { - return this.Attributes.IsCharacterDevice; + return Attributes.IsCharacterDevice; } } @@ -270,7 +270,7 @@ namespace Renci.SshNet.Sftp { get { - return this.Attributes.IsNamedPipe; + return Attributes.IsNamedPipe; } } @@ -284,11 +284,11 @@ namespace Renci.SshNet.Sftp { get { - return this.Attributes.OwnerCanRead; + return Attributes.OwnerCanRead; } set { - this.Attributes.OwnerCanRead = value; + Attributes.OwnerCanRead = value; } } @@ -302,11 +302,11 @@ namespace Renci.SshNet.Sftp { get { - return this.Attributes.OwnerCanWrite; + return Attributes.OwnerCanWrite; } set { - this.Attributes.OwnerCanWrite = value; + Attributes.OwnerCanWrite = value; } } @@ -320,11 +320,11 @@ namespace Renci.SshNet.Sftp { get { - return this.Attributes.OwnerCanExecute; + return Attributes.OwnerCanExecute; } set { - this.Attributes.OwnerCanExecute = value; + Attributes.OwnerCanExecute = value; } } @@ -338,11 +338,11 @@ namespace Renci.SshNet.Sftp { get { - return this.Attributes.GroupCanRead; + return Attributes.GroupCanRead; } set { - this.Attributes.GroupCanRead = value; + Attributes.GroupCanRead = value; } } @@ -356,11 +356,11 @@ namespace Renci.SshNet.Sftp { get { - return this.Attributes.GroupCanWrite; + return Attributes.GroupCanWrite; } set { - this.Attributes.GroupCanWrite = value; + Attributes.GroupCanWrite = value; } } @@ -374,11 +374,11 @@ namespace Renci.SshNet.Sftp { get { - return this.Attributes.GroupCanExecute; + return Attributes.GroupCanExecute; } set { - this.Attributes.GroupCanExecute = value; + Attributes.GroupCanExecute = value; } } @@ -392,11 +392,11 @@ namespace Renci.SshNet.Sftp { get { - return this.Attributes.OthersCanRead; + return Attributes.OthersCanRead; } set { - this.Attributes.OthersCanRead = value; + Attributes.OthersCanRead = value; } } @@ -410,11 +410,11 @@ namespace Renci.SshNet.Sftp { get { - return this.Attributes.OthersCanWrite; + return Attributes.OthersCanWrite; } set { - this.Attributes.OthersCanWrite = value; + Attributes.OthersCanWrite = value; } } @@ -428,31 +428,23 @@ namespace Renci.SshNet.Sftp { get { - return this.Attributes.OthersCanExecute; + return Attributes.OthersCanExecute; } set { - this.Attributes.OthersCanExecute = value; + Attributes.OthersCanExecute = value; } } - /// - /// Gets the extension part of the file. - /// - /// - /// File extensions. - /// - public IDictionary Extensions { get; private set; } - /// /// Sets file permissions. /// /// The mode. public void SetPermissions(short mode) { - this.Attributes.SetPermissions(mode); + Attributes.SetPermissions(mode); - this.UpdateStatus(); + UpdateStatus(); } /// @@ -460,13 +452,13 @@ namespace Renci.SshNet.Sftp /// public void Delete() { - if (this.IsDirectory) + if (IsDirectory) { - this._sftpSession.RequestRmDir(this.FullName); + _sftpSession.RequestRmDir(FullName); } else { - this._sftpSession.RequestRemove(this.FullName); + _sftpSession.RequestRemove(FullName); } } @@ -479,13 +471,13 @@ namespace Renci.SshNet.Sftp { if (destFileName == null) throw new ArgumentNullException("destFileName"); - this._sftpSession.RequestRename(this.FullName, destFileName); + _sftpSession.RequestRename(FullName, destFileName); - var fullPath = this._sftpSession.GetCanonicalPath(destFileName); + var fullPath = _sftpSession.GetCanonicalPath(destFileName); - this.Name = fullPath.Substring(fullPath.LastIndexOf('/') + 1); + Name = fullPath.Substring(fullPath.LastIndexOf('/') + 1); - this.FullName = fullPath; + FullName = fullPath; } /// @@ -493,7 +485,7 @@ namespace Renci.SshNet.Sftp /// public void UpdateStatus() { - this._sftpSession.RequestSetStat(this.FullName, this.Attributes); + _sftpSession.RequestSetStat(FullName, Attributes); } /// @@ -504,7 +496,7 @@ namespace Renci.SshNet.Sftp /// public override string ToString() { - return string.Format(CultureInfo.CurrentCulture, "Name {0}, Length {1}, User ID {2}, Group ID {3}, Accessed {4}, Modified {5}", this.Name, this.Length, this.UserId, this.GroupId, this.LastAccessTime, this.LastWriteTime); + return string.Format(CultureInfo.CurrentCulture, "Name {0}, Length {1}, User ID {2}, Group ID {3}, Accessed {4}, Modified {5}", Name, Length, UserId, GroupId, LastAccessTime, LastWriteTime); } } } diff --git a/Renci.SshClient/Renci.SshNet/Sftp/SftpFileAttributes.cs b/Renci.SshClient/Renci.SshNet/Sftp/SftpFileAttributes.cs index 1d40ab0f..a373bad9 100644 --- a/Renci.SshClient/Renci.SshNet/Sftp/SftpFileAttributes.cs +++ b/Renci.SshClient/Renci.SshNet/Sftp/SftpFileAttributes.cs @@ -69,37 +69,37 @@ namespace Renci.SshNet.Sftp internal bool IsLastAccessTimeChanged { - get { return this._originalLastAccessTime != this.LastAccessTime; } + get { return _originalLastAccessTime != LastAccessTime; } } internal bool IsLastWriteTimeChanged { - get { return this._originalLastWriteTime != this.LastWriteTime; } + get { return _originalLastWriteTime != LastWriteTime; } } internal bool IsSizeChanged { - get { return this._originalSize != this.Size; } + get { return _originalSize != Size; } } internal bool IsUserIdChanged { - get { return this._originalUserId != this.UserId; } + get { return _originalUserId != UserId; } } internal bool IsGroupIdChanged { - get { return this._originalGroupId != this.GroupId; } + get { return _originalGroupId != GroupId; } } internal bool IsPermissionsChanged { - get { return this._originalPermissions != this.Permissions; } + get { return _originalPermissions != Permissions; } } internal bool IsExtensionsChanged { - get { return this._originalExtensions != null && this.Extensions != null && !this._originalExtensions.SequenceEqual(this.Extensions); } + get { return _originalExtensions != null && Extensions != null && !_originalExtensions.SequenceEqual(Extensions); } } /// @@ -284,109 +284,109 @@ namespace Renci.SshNet.Sftp { uint permission = 0; - if (this._isBitFiledsBitSet) + if (_isBitFiledsBitSet) permission = permission | S_IFMT; - if (this.IsSocket) + if (IsSocket) permission = permission | S_IFSOCK; - if (this.IsSymbolicLink) + if (IsSymbolicLink) permission = permission | S_IFLNK; - if (this.IsRegularFile) + if (IsRegularFile) permission = permission | S_IFREG; - if (this.IsBlockDevice) + if (IsBlockDevice) permission = permission | S_IFBLK; - if (this.IsDirectory) + if (IsDirectory) permission = permission | S_IFDIR; - if (this.IsCharacterDevice) + if (IsCharacterDevice) permission = permission | S_IFCHR; - if (this.IsNamedPipe) + if (IsNamedPipe) permission = permission | S_IFIFO; - if (this._isUIDBitSet) + if (_isUIDBitSet) permission = permission | S_ISUID; - if (this._isGroupIDBitSet) + if (_isGroupIDBitSet) permission = permission | S_ISGID; - if (this._isStickyBitSet) + if (_isStickyBitSet) permission = permission | S_ISVTX; - if (this.OwnerCanRead) + if (OwnerCanRead) permission = permission | S_IRUSR; - if (this.OwnerCanWrite) + if (OwnerCanWrite) permission = permission | S_IWUSR; - if (this.OwnerCanExecute) + if (OwnerCanExecute) permission = permission | S_IXUSR; - if (this.GroupCanRead) + if (GroupCanRead) permission = permission | S_IRGRP; - if (this.GroupCanWrite) + if (GroupCanWrite) permission = permission | S_IWGRP; - if (this.GroupCanExecute) + if (GroupCanExecute) permission = permission | S_IXGRP; - if (this.OthersCanRead) + if (OthersCanRead) permission = permission | S_IROTH; - if (this.OthersCanWrite) + if (OthersCanWrite) permission = permission | S_IWOTH; - if (this.OthersCanExecute) + if (OthersCanExecute) permission = permission | S_IXOTH; return permission; } private set { - this._isBitFiledsBitSet = ((value & S_IFMT) == S_IFMT); + _isBitFiledsBitSet = ((value & S_IFMT) == S_IFMT); - this.IsSocket = ((value & S_IFSOCK) == S_IFSOCK); + IsSocket = ((value & S_IFSOCK) == S_IFSOCK); - this.IsSymbolicLink = ((value & S_IFLNK) == S_IFLNK); + IsSymbolicLink = ((value & S_IFLNK) == S_IFLNK); - this.IsRegularFile = ((value & S_IFREG) == S_IFREG); + IsRegularFile = ((value & S_IFREG) == S_IFREG); - this.IsBlockDevice = ((value & S_IFBLK) == S_IFBLK); + IsBlockDevice = ((value & S_IFBLK) == S_IFBLK); - this.IsDirectory = ((value & S_IFDIR) == S_IFDIR); + IsDirectory = ((value & S_IFDIR) == S_IFDIR); - this.IsCharacterDevice = ((value & S_IFCHR) == S_IFCHR); + IsCharacterDevice = ((value & S_IFCHR) == S_IFCHR); - this.IsNamedPipe = ((value & S_IFIFO) == S_IFIFO); + IsNamedPipe = ((value & S_IFIFO) == S_IFIFO); - this._isUIDBitSet = ((value & S_ISUID) == S_ISUID); + _isUIDBitSet = ((value & S_ISUID) == S_ISUID); - this._isGroupIDBitSet = ((value & S_ISGID) == S_ISGID); + _isGroupIDBitSet = ((value & S_ISGID) == S_ISGID); - this._isStickyBitSet = ((value & S_ISVTX) == S_ISVTX); + _isStickyBitSet = ((value & S_ISVTX) == S_ISVTX); - this.OwnerCanRead = ((value & S_IRUSR) == S_IRUSR); + OwnerCanRead = ((value & S_IRUSR) == S_IRUSR); - this.OwnerCanWrite = ((value & S_IWUSR) == S_IWUSR); + OwnerCanWrite = ((value & S_IWUSR) == S_IWUSR); - this.OwnerCanExecute = ((value & S_IXUSR) == S_IXUSR); + OwnerCanExecute = ((value & S_IXUSR) == S_IXUSR); - this.GroupCanRead = ((value & S_IRGRP) == S_IRGRP); + GroupCanRead = ((value & S_IRGRP) == S_IRGRP); - this.GroupCanWrite = ((value & S_IWGRP) == S_IWGRP); + GroupCanWrite = ((value & S_IWGRP) == S_IWGRP); - this.GroupCanExecute = ((value & S_IXGRP) == S_IXGRP); + GroupCanExecute = ((value & S_IXGRP) == S_IXGRP); - this.OthersCanRead = ((value & S_IROTH) == S_IROTH); + OthersCanRead = ((value & S_IROTH) == S_IROTH); - this.OthersCanWrite = ((value & S_IWOTH) == S_IWOTH); + OthersCanWrite = ((value & S_IWOTH) == S_IWOTH); - this.OthersCanExecute = ((value & S_IXOTH) == S_IXOTH); + OthersCanExecute = ((value & S_IXOTH) == S_IXOTH); } } @@ -396,13 +396,13 @@ namespace Renci.SshNet.Sftp internal SftpFileAttributes(DateTime lastAccessTime, DateTime lastWriteTime, long size, int userId, int groupId, uint permissions, IDictionary extensions) { - this.LastAccessTime = this._originalLastAccessTime = lastAccessTime; - this.LastWriteTime = this._originalLastWriteTime = lastWriteTime; - this.Size = this._originalSize = size; - this.UserId = this._originalUserId = userId; - this.GroupId = this._originalGroupId = groupId; - this.Permissions = this._originalPermissions = permissions; - this.Extensions = this._originalExtensions = extensions; + LastAccessTime = _originalLastAccessTime = lastAccessTime; + LastWriteTime = _originalLastWriteTime = lastWriteTime; + Size = _originalSize = size; + UserId = _originalUserId = userId; + GroupId = _originalGroupId = groupId; + Permissions = _originalPermissions = permissions; + Extensions = _originalExtensions = extensions; } /// @@ -420,17 +420,17 @@ namespace Renci.SshNet.Sftp var permission = (modeBytes[0] & 0x0F) * 8 * 8 + (modeBytes[1] & 0x0F) * 8 + (modeBytes[2] & 0x0F); - this.OwnerCanRead = (permission & S_IRUSR) == S_IRUSR; - this.OwnerCanWrite = (permission & S_IWUSR) == S_IWUSR; - this.OwnerCanExecute = (permission & S_IXUSR) == S_IXUSR; + OwnerCanRead = (permission & S_IRUSR) == S_IRUSR; + OwnerCanWrite = (permission & S_IWUSR) == S_IWUSR; + OwnerCanExecute = (permission & S_IXUSR) == S_IXUSR; - this.GroupCanRead = (permission & S_IRGRP) == S_IRGRP; - this.GroupCanWrite = (permission & S_IWGRP) == S_IWGRP; - this.GroupCanExecute = (permission & S_IXGRP) == S_IXGRP; + GroupCanRead = (permission & S_IRGRP) == S_IRGRP; + GroupCanWrite = (permission & S_IWGRP) == S_IWGRP; + GroupCanExecute = (permission & S_IXGRP) == S_IXGRP; - this.OthersCanRead = (permission & S_IROTH) == S_IROTH; - this.OthersCanWrite = (permission & S_IWOTH) == S_IWOTH; - this.OthersCanExecute = (permission & S_IXOTH) == S_IXOTH; + OthersCanRead = (permission & S_IROTH) == S_IROTH; + OthersCanWrite = (permission & S_IWOTH) == S_IWOTH; + OthersCanExecute = (permission & S_IXOTH) == S_IXOTH; } } } diff --git a/Renci.SshClient/Renci.SshNet/Sftp/SftpFileStream.cs b/Renci.SshClient/Renci.SshNet/Sftp/SftpFileStream.cs index bae7b9e4..eac0139d 100644 --- a/Renci.SshClient/Renci.SshNet/Sftp/SftpFileStream.cs +++ b/Renci.SshClient/Renci.SshNet/Sftp/SftpFileStream.cs @@ -340,7 +340,7 @@ namespace Renci.SshNet.Sftp /// Methods were called after the stream was closed. public override int Read(byte[] buffer, int offset, int count) { - int readLen = 0; + var readLen = 0; if (buffer == null) throw new ArgumentNullException("buffer"); diff --git a/Renci.SshClient/Renci.SshNet/Sftp/SftpFileSystemInformation.cs b/Renci.SshClient/Renci.SshNet/Sftp/SftpFileSystemInformation.cs index e5bb5030..50815bbc 100644 --- a/Renci.SshClient/Renci.SshNet/Sftp/SftpFileSystemInformation.cs +++ b/Renci.SshClient/Renci.SshNet/Sftp/SftpFileSystemInformation.cs @@ -121,16 +121,16 @@ /// The namemax. internal SftpFileSytemInformation(ulong bsize, ulong frsize, ulong blocks, ulong bfree, ulong bavail, ulong files, ulong ffree, ulong favail, ulong sid, ulong flag, ulong namemax) { - this.BlockSize = frsize; - this.TotalBlocks = blocks; - this.FreeBlocks = bfree; - this.AvailableBlocks = bavail; - this.TotalNodes = files; - this.FreeNodes = ffree; - this.AvailableNodes = favail; - this.Sid = sid; - this._flag = flag; - this.MaxNameLenght = namemax; + BlockSize = frsize; + TotalBlocks = blocks; + FreeBlocks = bfree; + AvailableBlocks = bavail; + TotalNodes = files; + FreeNodes = ffree; + AvailableNodes = favail; + Sid = sid; + _flag = flag; + MaxNameLenght = namemax; } } } \ No newline at end of file diff --git a/Renci.SshClient/Renci.SshNet/Sftp/SftpListDirectoryAsyncResult.cs b/Renci.SshClient/Renci.SshNet/Sftp/SftpListDirectoryAsyncResult.cs index 13093d2f..37be66d9 100644 --- a/Renci.SshClient/Renci.SshNet/Sftp/SftpListDirectoryAsyncResult.cs +++ b/Renci.SshClient/Renci.SshNet/Sftp/SftpListDirectoryAsyncResult.cs @@ -31,7 +31,7 @@ namespace Renci.SshNet.Sftp /// The files read. internal void Update(int filesRead) { - this.FilesRead = filesRead; + FilesRead = filesRead; } } } diff --git a/Renci.SshClient/Renci.SshNet/Sftp/SftpMessage.cs b/Renci.SshClient/Renci.SshNet/Sftp/SftpMessage.cs index c187a41e..93eae7d4 100644 --- a/Renci.SshClient/Renci.SshNet/Sftp/SftpMessage.cs +++ b/Renci.SshClient/Renci.SshNet/Sftp/SftpMessage.cs @@ -33,17 +33,17 @@ namespace Renci.SshNet.Sftp protected override void SaveData() { - this.Write((byte)this.SftpMessageType); + Write((byte) SftpMessageType); } protected SftpFileAttributes ReadAttributes() { - var flag = this.ReadUInt32(); + var flag = ReadUInt32(); long size = -1; - int userId = -1; - int groupId = -1; + var userId = -1; + var groupId = -1; uint permissions = 0; var accessTime = DateTime.MinValue; var modifyTime = DateTime.MinValue; @@ -51,33 +51,33 @@ namespace Renci.SshNet.Sftp if ((flag & 0x00000001) == 0x00000001) // SSH_FILEXFER_ATTR_SIZE { - size = (long)this.ReadUInt64(); + size = (long)ReadUInt64(); } if ((flag & 0x00000002) == 0x00000002) // SSH_FILEXFER_ATTR_UIDGID { - userId = (int)this.ReadUInt32(); + userId = (int)ReadUInt32(); - groupId = (int)this.ReadUInt32(); + groupId = (int)ReadUInt32(); } if ((flag & 0x00000004) == 0x00000004) // SSH_FILEXFER_ATTR_PERMISSIONS { - permissions = this.ReadUInt32(); + permissions = ReadUInt32(); } if ((flag & 0x00000008) == 0x00000008) // SSH_FILEXFER_ATTR_ACMODTIME { - var time = this.ReadUInt32(); + var time = ReadUInt32(); accessTime = DateTime.FromFileTime((time + 11644473600) * 10000000); - time = this.ReadUInt32(); + time = ReadUInt32(); modifyTime = DateTime.FromFileTime((time + 11644473600) * 10000000); } if ((flag & 0x80000000) == 0x80000000) // SSH_FILEXFER_ATTR_ACMODTIME { - var extendedCount = this.ReadUInt32(); - extensions = this.ReadExtensionPair(); + var extendedCount = ReadUInt32(); + extensions = ReadExtensionPair(); } var attributes = new SftpFileAttributes(accessTime, modifyTime, size, userId, groupId, permissions, extensions); @@ -88,7 +88,7 @@ namespace Renci.SshNet.Sftp { if (attributes == null) { - this.Write((uint)0); + Write((uint)0); return; } @@ -119,35 +119,35 @@ namespace Renci.SshNet.Sftp flag |= 0x80000000; } - this.Write(flag); + Write(flag); if (attributes.IsSizeChanged && attributes.IsRegularFile) { - this.Write((UInt64)attributes.Size); + Write((UInt64)attributes.Size); } if (attributes.IsUserIdChanged|| attributes.IsGroupIdChanged) { - this.Write((UInt32)attributes.UserId); - this.Write((UInt32)attributes.GroupId); + Write((UInt32)attributes.UserId); + Write((UInt32)attributes.GroupId); } if (attributes.IsPermissionsChanged) { - this.Write(attributes.Permissions); + Write(attributes.Permissions); } if (attributes.IsLastAccessTimeChanged || attributes.IsLastWriteTimeChanged) { var time = (uint)(attributes.LastAccessTime.ToFileTime() / 10000000 - 11644473600); - this.Write(time); + Write(time); time = (uint)(attributes.LastWriteTime.ToFileTime() / 10000000 - 11644473600); - this.Write(time); + Write(time); } if (attributes.IsExtensionsChanged) { - this.Write(attributes.Extensions); + Write(attributes.Extensions); } } @@ -193,7 +193,7 @@ namespace Renci.SshNet.Sftp public override string ToString() { - return string.Format(CultureInfo.CurrentCulture, "SFTP Message : {0}", this.SftpMessageType); + return string.Format(CultureInfo.CurrentCulture, "SFTP Message : {0}", SftpMessageType); } } } diff --git a/Renci.SshClient/Renci.SshNet/Sftp/SftpSynchronizeDirectoriesAsyncResult.cs b/Renci.SshClient/Renci.SshNet/Sftp/SftpSynchronizeDirectoriesAsyncResult.cs index 38b824f8..54653aeb 100644 --- a/Renci.SshClient/Renci.SshNet/Sftp/SftpSynchronizeDirectoriesAsyncResult.cs +++ b/Renci.SshClient/Renci.SshNet/Sftp/SftpSynchronizeDirectoriesAsyncResult.cs @@ -31,7 +31,7 @@ namespace Renci.SshNet.Sftp /// The files read. internal void Update(int filesRead) { - this.FilesRead = filesRead; + FilesRead = filesRead; } } } diff --git a/Renci.SshClient/Renci.SshNet/Sftp/SftpUploadAsyncResult.cs b/Renci.SshClient/Renci.SshNet/Sftp/SftpUploadAsyncResult.cs index 521481dc..4adb98d6 100644 --- a/Renci.SshClient/Renci.SshNet/Sftp/SftpUploadAsyncResult.cs +++ b/Renci.SshClient/Renci.SshNet/Sftp/SftpUploadAsyncResult.cs @@ -40,7 +40,7 @@ namespace Renci.SshNet.Sftp /// Number of uploaded bytes. internal void Update(ulong uploadedBytes) { - this.UploadedBytes = uploadedBytes; + UploadedBytes = uploadedBytes; } } } diff --git a/Renci.SshClient/Renci.SshNet/SftpClient.NET.cs b/Renci.SshClient/Renci.SshNet/SftpClient.NET.cs index 2729fbc1..1ee2e82e 100644 --- a/Renci.SshClient/Renci.SshNet/SftpClient.NET.cs +++ b/Renci.SshClient/Renci.SshNet/SftpClient.NET.cs @@ -2,6 +2,7 @@ using System.Linq; using System.Collections.Generic; using System.IO; +using Renci.SshNet.Common; using Renci.SshNet.Sftp; using System.Globalization; @@ -48,11 +49,11 @@ namespace Renci.SshNet var asyncResult = new SftpSynchronizeDirectoriesAsyncResult(asyncCallback, state); - this.ExecuteThread(() => + ExecuteThread(() => { try { - var result = this.InternalSynchronizeDirectories(sourcePath, destinationPath, searchPattern, asyncResult); + var result = InternalSynchronizeDirectories(sourcePath, destinationPath, searchPattern, asyncResult); asyncResult.SetAsCompleted(result, false); } @@ -90,9 +91,9 @@ namespace Renci.SshNet if (!Directory.Exists(sourcePath)) throw new FileNotFoundException(string.Format("Source directory not found: {0}", sourcePath)); - IList uploadedFiles = new List(); + var uploadedFiles = new List(); - DirectoryInfo sourceDirectory = new DirectoryInfo(sourcePath); + var sourceDirectory = new DirectoryInfo(sourcePath); #if SILVERLIGHT var sourceFiles = sourceDirectory.EnumerateFiles(searchPattern); @@ -106,7 +107,7 @@ namespace Renci.SshNet #region Existing Files at The Destination var destFiles = InternalListDirectory(destinationPath, null); - Dictionary destDict = new Dictionary(); + var destDict = new Dictionary(); foreach (var destFile in destFiles) { if (destFile.IsDirectory) @@ -121,11 +122,11 @@ namespace Renci.SshNet const Flags uploadFlag = Flags.Write | Flags.Truncate | Flags.CreateNewOrOpen; foreach (var localFile in sourceFiles) { - bool isDifferent = !destDict.ContainsKey(localFile.Name); + var isDifferent = !destDict.ContainsKey(localFile.Name); if (!isDifferent) { - SftpFile temp = destDict[localFile.Name]; + var temp = destDict[localFile.Name]; // TODO: Use md5 to detect a difference //ltang: File exists at the destination => Using filesize to detect the difference isDifferent = localFile.Length != temp.Length; @@ -138,7 +139,7 @@ namespace Renci.SshNet { using (var file = File.OpenRead(localFile.FullName)) { - this.InternalUploadFile(file, remoteFileName, uploadFlag, null, null); + InternalUploadFile(file, remoteFileName, uploadFlag, null, null); } uploadedFiles.Add(localFile); diff --git a/Renci.SshClient/Renci.SshNet/SftpClient.cs b/Renci.SshClient/Renci.SshNet/SftpClient.cs index 96610175..b84e3bcb 100644 --- a/Renci.SshClient/Renci.SshNet/SftpClient.cs +++ b/Renci.SshClient/Renci.SshNet/SftpClient.cs @@ -165,7 +165,7 @@ namespace Renci.SshNet /// is null. /// is invalid. -or- is null contains whitespace characters. public SftpClient(string host, string username, string password) - : this(host, ConnectionInfo.DEFAULT_PORT, username, password) + : this(host, ConnectionInfo.DefaultPort, username, password) { } @@ -194,7 +194,7 @@ namespace Renci.SshNet /// is null. /// is invalid. -or- is null or contains whitespace characters. public SftpClient(string host, string username, params PrivateKeyFile[] keyFiles) - : this(host, ConnectionInfo.DEFAULT_PORT, username, keyFiles) + : this(host, ConnectionInfo.DefaultPort, username, keyFiles) { } diff --git a/Renci.SshClient/Renci.SshNet/Shell.cs b/Renci.SshClient/Renci.SshNet/Shell.cs index f7ab0add..2e2ffee1 100644 --- a/Renci.SshClient/Renci.SshNet/Shell.cs +++ b/Renci.SshClient/Renci.SshNet/Shell.cs @@ -90,17 +90,17 @@ namespace Renci.SshNet /// Size of the buffer for output stream. internal Shell(ISession session, Stream input, Stream output, Stream extendedOutput, string terminalName, uint columns, uint rows, uint width, uint height, IDictionary terminalModes, int bufferSize) { - this._session = session; - this._input = input; - this._outputStream = output; - this._extendedOutputStream = extendedOutput; - this._terminalName = terminalName; - this._columns = columns; - this._rows = rows; - this._width = width; - this._height = height; - this._terminalModes = terminalModes; - this._bufferSize = bufferSize; + _session = session; + _input = input; + _outputStream = output; + _extendedOutputStream = extendedOutput; + _terminalName = terminalName; + _columns = columns; + _rows = rows; + _width = width; + _height = height; + _terminalModes = terminalModes; + _bufferSize = bufferSize; } /// @@ -109,54 +109,54 @@ namespace Renci.SshNet /// Shell is started. public void Start() { - if (this.IsStarted) + if (IsStarted) { throw new SshException("Shell is started."); } - if (this.Starting != null) + if (Starting != null) { - this.Starting(this, new EventArgs()); + Starting(this, new EventArgs()); } - this._channel = this._session.CreateChannelSession(); - this._channel.DataReceived += Channel_DataReceived; - this._channel.ExtendedDataReceived += Channel_ExtendedDataReceived; - this._channel.Closed += Channel_Closed; - this._session.Disconnected += Session_Disconnected; - this._session.ErrorOccured += Session_ErrorOccured; + _channel = _session.CreateChannelSession(); + _channel.DataReceived += Channel_DataReceived; + _channel.ExtendedDataReceived += Channel_ExtendedDataReceived; + _channel.Closed += Channel_Closed; + _session.Disconnected += Session_Disconnected; + _session.ErrorOccured += Session_ErrorOccured; - this._channel.Open(); - this._channel.SendPseudoTerminalRequest(this._terminalName, this._columns, this._rows, this._width, this._height, this._terminalModes); - this._channel.SendShellRequest(); + _channel.Open(); + _channel.SendPseudoTerminalRequest(_terminalName, _columns, _rows, _width, _height, _terminalModes); + _channel.SendShellRequest(); - this._channelClosedWaitHandle = new AutoResetEvent(false); + _channelClosedWaitHandle = new AutoResetEvent(false); // Start input stream listener - this._dataReaderTaskCompleted = new ManualResetEvent(false); - this.ExecuteThread(() => + _dataReaderTaskCompleted = new ManualResetEvent(false); + ExecuteThread(() => { try { - var buffer = new byte[this._bufferSize]; + var buffer = new byte[_bufferSize]; - while (this._channel.IsOpen) + while (_channel.IsOpen) { - var asyncResult = this._input.BeginRead(buffer, 0, buffer.Length, delegate(IAsyncResult result) + var asyncResult = _input.BeginRead(buffer, 0, buffer.Length, delegate(IAsyncResult result) { // If input stream is closed and disposed already dont finish reading the stream - if (this._input == null) + if (_input == null) return; - var read = this._input.EndRead(result); + var read = _input.EndRead(result); if (read > 0) { - this._channel.SendData(buffer.Take(read).ToArray()); + _channel.SendData(buffer.Take(read).ToArray()); } }, null); - EventWaitHandle.WaitAny(new WaitHandle[] { asyncResult.AsyncWaitHandle, this._channelClosedWaitHandle }); + EventWaitHandle.WaitAny(new WaitHandle[] { asyncResult.AsyncWaitHandle, _channelClosedWaitHandle }); if (asyncResult.IsCompleted) continue; @@ -165,19 +165,19 @@ namespace Renci.SshNet } catch (Exception exp) { - this.RaiseError(new ExceptionEventArgs(exp)); + RaiseError(new ExceptionEventArgs(exp)); } finally { - this._dataReaderTaskCompleted.Set(); + _dataReaderTaskCompleted.Set(); } }); - this.IsStarted = true; + IsStarted = true; - if (this.Started != null) + if (Started != null) { - this.Started(this, new EventArgs()); + Started(this, new EventArgs()); } } @@ -187,25 +187,25 @@ namespace Renci.SshNet /// Shell is not started. public void Stop() { - if (!this.IsStarted) + if (!IsStarted) { throw new SshException("Shell is not started."); } - if (this._channel != null) + if (_channel != null) { - this._channel.Close(); + _channel.Close(); } } private void Session_ErrorOccured(object sender, ExceptionEventArgs e) { - this.RaiseError(e); + RaiseError(e); } private void RaiseError(ExceptionEventArgs e) { - var handler = this.ErrorOccurred; + var handler = ErrorOccurred; if (handler != null) { handler(this, e); @@ -214,60 +214,60 @@ namespace Renci.SshNet private void Session_Disconnected(object sender, EventArgs e) { - this.Stop(); + Stop(); } private void Channel_ExtendedDataReceived(object sender, ChannelDataEventArgs e) { - if (this._extendedOutputStream != null) + if (_extendedOutputStream != null) { - this._extendedOutputStream.Write(e.Data, 0, e.Data.Length); + _extendedOutputStream.Write(e.Data, 0, e.Data.Length); } } private void Channel_DataReceived(object sender, ChannelDataEventArgs e) { - if (this._outputStream != null) + if (_outputStream != null) { - this._outputStream.Write(e.Data, 0, e.Data.Length); + _outputStream.Write(e.Data, 0, e.Data.Length); } } private void Channel_Closed(object sender, ChannelEventArgs e) { - if (this.Stopping != null) + if (Stopping != null) { // Handle event on different thread - this.ExecuteThread(() => this.Stopping(this, new EventArgs())); + ExecuteThread(() => Stopping(this, new EventArgs())); } - if (this._channel.IsOpen) + if (_channel.IsOpen) { - this._channel.Close(); + _channel.Close(); } - this._channelClosedWaitHandle.Set(); + _channelClosedWaitHandle.Set(); - this._input.Dispose(); - this._input = null; + _input.Dispose(); + _input = null; - this._dataReaderTaskCompleted.WaitOne(this._session.ConnectionInfo.Timeout); - this._dataReaderTaskCompleted.Dispose(); - this._dataReaderTaskCompleted = null; + _dataReaderTaskCompleted.WaitOne(_session.ConnectionInfo.Timeout); + _dataReaderTaskCompleted.Dispose(); + _dataReaderTaskCompleted = null; - this._channel.DataReceived -= Channel_DataReceived; - this._channel.ExtendedDataReceived -= Channel_ExtendedDataReceived; - this._channel.Closed -= Channel_Closed; - this._session.Disconnected -= Session_Disconnected; - this._session.ErrorOccured -= Session_ErrorOccured; + _channel.DataReceived -= Channel_DataReceived; + _channel.ExtendedDataReceived -= Channel_ExtendedDataReceived; + _channel.Closed -= Channel_Closed; + _session.Disconnected -= Session_Disconnected; + _session.ErrorOccured -= Session_ErrorOccured; - if (this.Stopped != null) + if (Stopped != null) { // Handle event on different thread - this.ExecuteThread(() => this.Stopped(this, new EventArgs())); + ExecuteThread(() => Stopped(this, new EventArgs())); } - this._channel = null; + _channel = null; } partial void ExecuteThread(Action action); @@ -293,33 +293,33 @@ namespace Renci.SshNet protected virtual void Dispose(bool disposing) { // Check to see if Dispose has already been called. - if (!this._disposed) + if (!_disposed) { // If disposing equals true, dispose all managed // and unmanaged ResourceMessages. if (disposing) { - if (this._channelClosedWaitHandle != null) + if (_channelClosedWaitHandle != null) { - this._channelClosedWaitHandle.Dispose(); - this._channelClosedWaitHandle = null; + _channelClosedWaitHandle.Dispose(); + _channelClosedWaitHandle = null; } - if (this._channel != null) + if (_channel != null) { - this._channel.Dispose(); - this._channel = null; + _channel.Dispose(); + _channel = null; } - if (this._dataReaderTaskCompleted != null) + if (_dataReaderTaskCompleted != null) { - this._dataReaderTaskCompleted.Dispose(); - this._dataReaderTaskCompleted = null; + _dataReaderTaskCompleted.Dispose(); + _dataReaderTaskCompleted = null; } } // Note disposing has been done. - this._disposed = true; + _disposed = true; } } diff --git a/Renci.SshClient/Renci.SshNet/ShellStream.cs b/Renci.SshClient/Renci.SshNet/ShellStream.cs index ce775797..81555098 100644 --- a/Renci.SshClient/Renci.SshNet/ShellStream.cs +++ b/Renci.SshClient/Renci.SshNet/ShellStream.cs @@ -52,7 +52,7 @@ namespace Renci.SshNet } } - internal ShellStream(ISession session, string terminalName, uint columns, uint rows, uint width, uint height, int maxLines, IDictionary terminalModeValues) + internal ShellStream(ISession session, string terminalName, uint columns, uint rows, uint width, uint height, int bufferSize, IDictionary terminalModeValues) { _encoding = session.ConnectionInfo.Encoding; _session = session; @@ -275,7 +275,7 @@ namespace Renci.SshNet { var result = text.Substring(0, match.Index + match.Length); - for (int i = 0; i < match.Index + match.Length && _incoming.Count > 0; i++) + for (var i = 0; i < match.Index + match.Length && _incoming.Count > 0; i++) { // Remove processed items from the queue _incoming.Dequeue(); @@ -389,7 +389,7 @@ namespace Renci.SshNet { var result = text.Substring(0, match.Index + match.Length); - for (int i = 0; i < match.Index + match.Length && _incoming.Count > 0; i++) + for (var i = 0; i < match.Index + match.Length && _incoming.Count > 0; i++) { // Remove processed items from the queue _incoming.Dequeue(); diff --git a/Renci.SshClient/Renci.SshNet/SshClient.cs b/Renci.SshClient/Renci.SshNet/SshClient.cs index fa3950a9..a94216c2 100644 --- a/Renci.SshClient/Renci.SshNet/SshClient.cs +++ b/Renci.SshClient/Renci.SshNet/SshClient.cs @@ -84,7 +84,7 @@ namespace Renci.SshNet /// is null. /// is invalid, or is null or contains whitespace characters. public SshClient(string host, string username, string password) - : this(host, ConnectionInfo.DEFAULT_PORT, username, password) + : this(host, ConnectionInfo.DefaultPort, username, password) { } @@ -121,7 +121,7 @@ namespace Renci.SshNet /// is null. /// is invalid, -or- is null or contains whitespace characters. public SshClient(string host, string username, params PrivateKeyFile[] keyFiles) - : this(host, ConnectionInfo.DEFAULT_PORT, username, keyFiles) + : this(host, ConnectionInfo.DefaultPort, username, keyFiles) { }