Skip to content

Commit 37bfb7c

Browse files
committed
Remove usage of Linq.
1 parent d90f16f commit 37bfb7c

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

src/Renci.SshNet/PasswordConnectionInfo.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Linq;
32
using System.Net;
43
using System.Text;
54
using Renci.SshNet.Common;
@@ -248,9 +247,13 @@ public PasswordConnectionInfo(string host, string username, byte[] password, Pro
248247
public PasswordConnectionInfo(string host, int port, string username, byte[] password, ProxyTypes proxyType, string proxyHost, int proxyPort, string proxyUsername, string proxyPassword)
249248
: base(host, port, username, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword, new PasswordAuthenticationMethod(username, password))
250249
{
251-
foreach (var authenticationMethod in AuthenticationMethods.OfType<PasswordAuthenticationMethod>())
250+
foreach (var authenticationMethod in AuthenticationMethods)
252251
{
253-
authenticationMethod.PasswordExpired += AuthenticationMethod_PasswordExpired;
252+
var pwdAuthentication = authenticationMethod as PasswordAuthenticationMethod;
253+
if (pwdAuthentication != null)
254+
{
255+
pwdAuthentication.PasswordExpired += AuthenticationMethod_PasswordExpired;
256+
}
254257
}
255258
}
256259

@@ -288,9 +291,13 @@ protected virtual void Dispose(bool disposing)
288291
{
289292
if (AuthenticationMethods != null)
290293
{
291-
foreach (var authenticationMethods in AuthenticationMethods.OfType<IDisposable>())
294+
foreach (var authenticationMethod in AuthenticationMethods)
292295
{
293-
authenticationMethods.Dispose();
296+
var disposable = authenticationMethod as IDisposable;
297+
if (disposable != null)
298+
{
299+
disposable.Dispose();
300+
}
294301
}
295302
}
296303

src/Renci.SshNet/PrivateKeyConnectionInfo.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Linq;
43
using System.Collections.ObjectModel;
54

65
namespace Renci.SshNet
@@ -167,9 +166,13 @@ protected virtual void Dispose(bool disposing)
167166
// Dispose managed resources.
168167
if (AuthenticationMethods != null)
169168
{
170-
foreach (var authenticationMethods in AuthenticationMethods.OfType<IDisposable>())
169+
foreach (var authenticationMethod in AuthenticationMethods)
171170
{
172-
authenticationMethods.Dispose();
171+
var disposable = authenticationMethod as IDisposable;
172+
if (disposable != null)
173+
{
174+
disposable.Dispose();
175+
}
173176
}
174177
}
175178

0 commit comments

Comments
 (0)