Skip to content

Commit e78c55d

Browse files
committed
Removed the builder
1 parent fb50e10 commit e78c55d

File tree

2 files changed

+44
-73
lines changed

2 files changed

+44
-73
lines changed

src/MongoDB.Driver/Core/Connections/Socks5ProxySettings.cs

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,57 @@ public sealed class Socks5ProxySettings
4141
/// </summary>
4242
public Socks5AuthenticationSettings Authentication { get; }
4343

44-
internal Socks5ProxySettings(string host, int? port, Socks5AuthenticationSettings authentication)
44+
/// <summary>
45+
/// Initializes a new instance of the <see cref="Socks5ProxySettings"/> class with the specified host.
46+
/// </summary>
47+
/// <param name="host">The SOCKS5 proxy host.</param>
48+
public Socks5ProxySettings(string host)
49+
: this(host, DefaultPort, Socks5AuthenticationSettings.None)
50+
{
51+
}
52+
53+
/// <summary>
54+
/// Initializes a new instance of the <see cref="Socks5ProxySettings"/> class with the specified host and port.
55+
/// </summary>
56+
/// <param name="host">The proxy host.</param>
57+
/// <param name="port">The proxy port.</param>
58+
public Socks5ProxySettings(string host, int port)
59+
: this(host, port, Socks5AuthenticationSettings.None)
60+
{
61+
}
62+
63+
/// <summary>
64+
/// Initializes a new instance of the <see cref="Socks5ProxySettings"/> class with the specified host and authentication settings.
65+
/// </summary>
66+
/// <param name="host">The proxy host.</param>
67+
/// <param name="authentication">The proxy authentication settings.</param>
68+
public Socks5ProxySettings(string host, Socks5AuthenticationSettings authentication)
69+
: this(host, DefaultPort, authentication)
70+
{
71+
}
72+
73+
/// <summary>
74+
/// Initializes a new instance of the <see cref="Socks5ProxySettings"/> class with the specified host, port, and authentication settings.
75+
/// </summary>
76+
/// <param name="host">The proxy host.</param>
77+
/// <param name="port">The proxy port.</param>
78+
/// <param name="authentication">The proxy authentication settings.</param>
79+
public Socks5ProxySettings(string host, int port, Socks5AuthenticationSettings authentication)
4580
{
4681
Host = Ensure.IsNotNullOrEmpty(host, nameof(host));
47-
Port = port is null ? DefaultPort : Ensure.IsBetween(port.Value, 1, 65535, nameof(port));
48-
Authentication = authentication ?? Socks5AuthenticationSettings.None;
82+
Port = Ensure.IsBetween(port, 1, 65535, nameof(port));
83+
Authentication = Ensure.IsNotNull(authentication, nameof(authentication));
4984
}
5085

51-
// Convenience method used internally.
86+
// This is a convenience method to create Socks5ProxySettings from the connection string parameters.
5287
internal static Socks5ProxySettings Create(string host, int? port, string username, string password)
5388
{
54-
var authentication = !string.IsNullOrEmpty(username) ?
55-
Socks5AuthenticationSettings.UsernamePassword(username, password) : Socks5AuthenticationSettings.None;
89+
var authentication =
90+
!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password)
91+
? Socks5AuthenticationSettings.UsernamePassword(username, password)
92+
: Socks5AuthenticationSettings.None;
5693

57-
return new Socks5ProxySettings(host, port, authentication);
94+
return new Socks5ProxySettings(host, port ?? DefaultPort, authentication);
5895
}
5996

6097
/// <inheritdoc />

src/MongoDB.Driver/Core/Connections/Socks5ProxySettingsBuilder.cs

Lines changed: 0 additions & 66 deletions
This file was deleted.

0 commit comments

Comments
 (0)