< Summary

Information
Class: Renci.SshNet.PrivateKeyConnectionInfo
Assembly: Renci.SshNet
File(s): \home\appveyor\projects\ssh-net\src\Renci.SshNet\PrivateKeyConnectionInfo.cs
Line coverage
28%
Covered lines: 15
Uncovered lines: 37
Coverable lines: 52
Total lines: 189
Line coverage: 28.8%
Branch coverage
20%
Covered branches: 2
Total branches: 10
Branch coverage: 20%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
get_KeyFiles()100%1100%
.ctor(...)100%10%
.ctor(...)100%1100%
.ctor(...)100%10%
.ctor(...)100%10%
.ctor(...)100%10%
.ctor(...)100%10%
.ctor(...)100%10%
.ctor(...)100%1100%
Dispose()100%10%
Dispose(...)20%1021.05%
Finalize()100%1100%

File(s)

\home\appveyor\projects\ssh-net\src\Renci.SshNet\PrivateKeyConnectionInfo.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.Collections.ObjectModel;
 4
 5namespace Renci.SshNet
 6{
 7    /// <summary>
 8    /// Provides connection information when private key authentication method is used.
 9    /// </summary>
 10    /// <example>
 11    ///   <code source="..\..\src\Renci.SshNet.Tests\Classes\PrivateKeyConnectionInfoTest.cs" region="Example PrivateKey
 12    ///   </example>
 13    public class PrivateKeyConnectionInfo : ConnectionInfo, IDisposable
 14    {
 15        private bool _isDisposed;
 16
 17        /// <summary>
 18        /// Gets the key files used for authentication.
 19        /// </summary>
 620        public ICollection<IPrivateKeySource> KeyFiles { get; private set; }
 21
 22        /// <summary>
 23        /// Initializes a new instance of the <see cref="PrivateKeyConnectionInfo"/> class.
 24        /// </summary>
 25        /// <param name="host">Connection host.</param>
 26        /// <param name="username">Connection username.</param>
 27        /// <param name="keyFiles">Connection key files.</param>
 28        /// <example>
 29        ///     <code source="..\..\src\Renci.SshNet.Tests\Classes\PrivateKeyConnectionInfoTest.cs" region="Example Priv
 30        ///     <code source="..\..\src\Renci.SshNet.Tests\Classes\PrivateKeyConnectionInfoTest.cs" region="Example Priv
 31        /// </example>
 32        public PrivateKeyConnectionInfo(string host, string username, params PrivateKeyFile[] keyFiles)
 033            : this(host, DefaultPort, username, ProxyTypes.None, string.Empty, 0, string.Empty, string.Empty, keyFiles)
 034        {
 035        }
 36
 37        /// <summary>
 38        /// Initializes a new instance of the <see cref="PrivateKeyConnectionInfo"/> class.
 39        /// </summary>
 40        /// <param name="host">Connection host.</param>
 41        /// <param name="port">Connection port.</param>
 42        /// <param name="username">Connection username.</param>
 43        /// <param name="keyFiles">Connection key files.</param>
 44        public PrivateKeyConnectionInfo(string host, int port, string username, params IPrivateKeySource[] keyFiles)
 645            : this(host, port, username, ProxyTypes.None, string.Empty, 0, string.Empty, string.Empty, keyFiles)
 646        {
 647        }
 48
 49        /// <summary>
 50        /// Initializes a new instance of the <see cref="PrivateKeyConnectionInfo"/> class.
 51        /// </summary>
 52        /// <param name="host">Connection host.</param>
 53        /// <param name="port">The port.</param>
 54        /// <param name="username">Connection username.</param>
 55        /// <param name="proxyType">Type of the proxy.</param>
 56        /// <param name="proxyHost">The proxy host.</param>
 57        /// <param name="proxyPort">The proxy port.</param>
 58        /// <param name="keyFiles">The key files.</param>
 59        public PrivateKeyConnectionInfo(string host, int port, string username, ProxyTypes proxyType, string proxyHost, 
 060            : this(host, port, username, proxyType, proxyHost, proxyPort, string.Empty, string.Empty, keyFiles)
 061        {
 062        }
 63
 64        /// <summary>
 65        /// Initializes a new instance of the <see cref="PrivateKeyConnectionInfo"/> class.
 66        /// </summary>
 67        /// <param name="host">Connection host.</param>
 68        /// <param name="port">The port.</param>
 69        /// <param name="username">Connection username.</param>
 70        /// <param name="proxyType">Type of the proxy.</param>
 71        /// <param name="proxyHost">The proxy host.</param>
 72        /// <param name="proxyPort">The proxy port.</param>
 73        /// <param name="proxyUsername">The proxy username.</param>
 74        /// <param name="keyFiles">The key files.</param>
 75        public PrivateKeyConnectionInfo(string host, int port, string username, ProxyTypes proxyType, string proxyHost, 
 076            : this(host, port, username, proxyType, proxyHost, proxyPort, proxyUsername, string.Empty, keyFiles)
 077        {
 078        }
 79
 80        /// <summary>
 81        /// Initializes a new instance of the <see cref="PrivateKeyConnectionInfo"/> class.
 82        /// </summary>
 83        /// <param name="host">Connection host.</param>
 84        /// <param name="username">Connection username.</param>
 85        /// <param name="proxyType">Type of the proxy.</param>
 86        /// <param name="proxyHost">The proxy host.</param>
 87        /// <param name="proxyPort">The proxy port.</param>
 88        /// <param name="keyFiles">The key files.</param>
 89        public PrivateKeyConnectionInfo(string host, string username, ProxyTypes proxyType, string proxyHost, int proxyP
 090            : this(host, DefaultPort, username, proxyType, proxyHost, proxyPort, string.Empty, string.Empty, keyFiles)
 091        {
 092        }
 93
 94        /// <summary>
 95        /// Initializes a new instance of the <see cref="PrivateKeyConnectionInfo"/> class.
 96        /// </summary>
 97        /// <param name="host">Connection host.</param>
 98        /// <param name="username">Connection username.</param>
 99        /// <param name="proxyType">Type of the proxy.</param>
 100        /// <param name="proxyHost">The proxy host.</param>
 101        /// <param name="proxyPort">The proxy port.</param>
 102        /// <param name="proxyUsername">The proxy username.</param>
 103        /// <param name="keyFiles">The key files.</param>
 104        public PrivateKeyConnectionInfo(string host, string username, ProxyTypes proxyType, string proxyHost, int proxyP
 0105            : this(host, DefaultPort, username, proxyType, proxyHost, proxyPort, proxyUsername, string.Empty, keyFiles)
 0106        {
 0107        }
 108
 109        /// <summary>
 110        /// Initializes a new instance of the <see cref="PrivateKeyConnectionInfo"/> class.
 111        /// </summary>
 112        /// <param name="host">Connection host.</param>
 113        /// <param name="username">Connection username.</param>
 114        /// <param name="proxyType">Type of the proxy.</param>
 115        /// <param name="proxyHost">The proxy host.</param>
 116        /// <param name="proxyPort">The proxy port.</param>
 117        /// <param name="proxyUsername">The proxy username.</param>
 118        /// <param name="proxyPassword">The proxy password.</param>
 119        /// <param name="keyFiles">The key files.</param>
 120        public PrivateKeyConnectionInfo(string host, string username, ProxyTypes proxyType, string proxyHost, int proxyP
 0121            : this(host, DefaultPort, username, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword, keyFiles)
 0122        {
 0123        }
 124
 125        /// <summary>
 126        /// Initializes a new instance of the <see cref="PrivateKeyConnectionInfo"/> class.
 127        /// </summary>
 128        /// <param name="host">Connection host.</param>
 129        /// <param name="port">The port.</param>
 130        /// <param name="username">Connection username.</param>
 131        /// <param name="proxyType">Type of the proxy.</param>
 132        /// <param name="proxyHost">The proxy host.</param>
 133        /// <param name="proxyPort">The proxy port.</param>
 134        /// <param name="proxyUsername">The proxy username.</param>
 135        /// <param name="proxyPassword">The proxy password.</param>
 136        /// <param name="keyFiles">The key files.</param>
 137        public PrivateKeyConnectionInfo(string host, int port, string username, ProxyTypes proxyType, string proxyHost, 
 6138            : base(host, port, username, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword, new PrivateKeyAu
 6139        {
 6140            KeyFiles = new Collection<IPrivateKeySource>(keyFiles);
 6141        }
 142
 143        /// <summary>
 144        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 145        /// </summary>
 146        public void Dispose()
 0147        {
 0148            Dispose(disposing: true);
 0149            GC.SuppressFinalize(this);
 0150        }
 151
 152        /// <summary>
 153        /// Releases unmanaged and - optionally - managed resources.
 154        /// </summary>
 155        /// <param name="disposing"><see langword="true"/> to release both managed and unmanaged resources; <see langwor
 156        protected virtual void Dispose(bool disposing)
 6157        {
 6158            if (_isDisposed)
 0159            {
 0160                return;
 161            }
 162
 6163            if (disposing)
 0164            {
 165                // Dispose managed resources.
 0166                if (AuthenticationMethods != null)
 0167                {
 0168                    foreach (var authenticationMethod in AuthenticationMethods)
 0169                    {
 0170                        if (authenticationMethod is IDisposable disposable)
 0171                        {
 0172                            disposable.Dispose();
 0173                        }
 0174                    }
 0175                }
 176
 0177                _isDisposed = true;
 0178            }
 6179        }
 180
 181        /// <summary>
 182        /// Finalizes an instance of the <see cref="PrivateKeyConnectionInfo"/> class.
 183        /// </summary>
 184        ~PrivateKeyConnectionInfo()
 12185        {
 6186            Dispose(disposing: false);
 12187        }
 188    }
 189}