12
12
13
13
namespace RabbitMQ . AMQP . Client
14
14
{
15
- // TODO rename to ConnectionSettingsBuilder
16
- public class ConnectionSettingBuilder
15
+ public class ConnectionSettingsBuilder
17
16
{
18
- // TODO: maybe add the event "LifeCycle" to the builder
19
17
private string _host = "localhost" ;
20
18
private int _port = - 1 ; // Note: -1 means use the defalt for the scheme
21
19
private string ? _user = "guest" ;
@@ -28,54 +26,54 @@ public class ConnectionSettingBuilder
28
26
private RecoveryConfiguration _recoveryConfiguration = new RecoveryConfiguration ( ) ;
29
27
private IList < Uri > ? _uris ;
30
28
31
- public static ConnectionSettingBuilder Create ( )
29
+ public static ConnectionSettingsBuilder Create ( )
32
30
{
33
- return new ConnectionSettingBuilder ( ) ;
31
+ return new ConnectionSettingsBuilder ( ) ;
34
32
}
35
33
36
- public ConnectionSettingBuilder Host ( string host )
34
+ public ConnectionSettingsBuilder Host ( string host )
37
35
{
38
36
_host = host ;
39
37
return this ;
40
38
}
41
39
42
- public ConnectionSettingBuilder Port ( int port )
40
+ public ConnectionSettingsBuilder Port ( int port )
43
41
{
44
42
_port = port ;
45
43
return this ;
46
44
}
47
45
48
- public ConnectionSettingBuilder User ( string user )
46
+ public ConnectionSettingsBuilder User ( string user )
49
47
{
50
48
_user = user ;
51
49
return this ;
52
50
}
53
51
54
- public ConnectionSettingBuilder Password ( string password )
52
+ public ConnectionSettingsBuilder Password ( string password )
55
53
{
56
54
_password = password ;
57
55
return this ;
58
56
}
59
57
60
- public ConnectionSettingBuilder Scheme ( string scheme )
58
+ public ConnectionSettingsBuilder Scheme ( string scheme )
61
59
{
62
60
_scheme = scheme ;
63
61
return this ;
64
62
}
65
63
66
- public ConnectionSettingBuilder ContainerId ( string containerId )
64
+ public ConnectionSettingsBuilder ContainerId ( string containerId )
67
65
{
68
66
_containerId = containerId ;
69
67
return this ;
70
68
}
71
69
72
- public ConnectionSettingBuilder VirtualHost ( string virtualHost )
70
+ public ConnectionSettingsBuilder VirtualHost ( string virtualHost )
73
71
{
74
72
_virtualHost = virtualHost ;
75
73
return this ;
76
74
}
77
75
78
- public ConnectionSettingBuilder MaxFrameSize ( uint maxFrameSize )
76
+ public ConnectionSettingsBuilder MaxFrameSize ( uint maxFrameSize )
79
77
{
80
78
_maxFrameSize = maxFrameSize ;
81
79
if ( _maxFrameSize != uint . MinValue && _maxFrameSize < 512 )
@@ -86,7 +84,7 @@ public ConnectionSettingBuilder MaxFrameSize(uint maxFrameSize)
86
84
return this ;
87
85
}
88
86
89
- public ConnectionSettingBuilder SaslMechanism ( SaslMechanism saslMechanism )
87
+ public ConnectionSettingsBuilder SaslMechanism ( SaslMechanism saslMechanism )
90
88
{
91
89
_saslMechanism = saslMechanism ;
92
90
if ( _saslMechanism == Client . SaslMechanism . Anonymous ||
@@ -99,13 +97,13 @@ public ConnectionSettingBuilder SaslMechanism(SaslMechanism saslMechanism)
99
97
return this ;
100
98
}
101
99
102
- public ConnectionSettingBuilder RecoveryConfiguration ( RecoveryConfiguration recoveryConfiguration )
100
+ public ConnectionSettingsBuilder RecoveryConfiguration ( RecoveryConfiguration recoveryConfiguration )
103
101
{
104
102
_recoveryConfiguration = recoveryConfiguration ;
105
103
return this ;
106
104
}
107
105
108
- public ConnectionSettingBuilder Uris ( IEnumerable < Uri > uris )
106
+ public ConnectionSettingsBuilder Uris ( IEnumerable < Uri > uris )
109
107
{
110
108
_uris = uris . ToList ( ) ;
111
109
return this ;
@@ -226,6 +224,9 @@ public ConnectionSettings(string scheme, string host, int port,
226
224
public SaslMechanism SaslMechanism => _saslMechanism ;
227
225
public TlsSettings ? TlsSettings => _tlsSettings ;
228
226
public RecoveryConfiguration Recovery => _recoveryConfiguration ;
227
+ public IEnumerable < Uri > ? Uris => throw new NotImplementedException ( ) ;
228
+
229
+ internal Address Address => _address ;
229
230
230
231
public override string ToString ( )
231
232
{
@@ -243,32 +244,25 @@ public override bool Equals(object? obj)
243
244
return false ;
244
245
}
245
246
246
- if ( obj is ConnectionSettings address )
247
+ if ( Object . ReferenceEquals ( this , obj ) )
247
248
{
248
- return _address . Host == address . _address . Host &&
249
- _address . Port == address . _address . Port &&
250
- _address . Path == address . _address . Path &&
251
- _address . User == address . _address . User &&
252
- _address . Password == address . _address . Password &&
253
- _address . Scheme == address . _address . Scheme ;
249
+ return true ;
254
250
}
255
251
256
- return false ;
257
- }
258
-
259
- protected bool Equals ( ConnectionSettings other )
260
- {
261
- if ( other is null )
252
+ if ( obj is ConnectionSettings other )
262
253
{
263
- return false ;
254
+ return
255
+ _address . Host == other . _address . Host &&
256
+ _address . Port == other . _address . Port &&
257
+ _virtualHost == other . _virtualHost &&
258
+ _address . User == other . _address . User &&
259
+ _address . Password == other . _address . Password &&
260
+ _address . Scheme == other . _address . Scheme &&
261
+ _containerId == other . _containerId &&
262
+ _address . Path == other . _address . Path ;
264
263
}
265
264
266
- return _address . Equals ( other . _address ) ;
267
- }
268
-
269
- public override int GetHashCode ( )
270
- {
271
- return _address . GetHashCode ( ) ;
265
+ return false ;
272
266
}
273
267
274
268
bool IEquatable < ConnectionSettings > . Equals ( ConnectionSettings ? other )
@@ -278,24 +272,20 @@ bool IEquatable<ConnectionSettings>.Equals(ConnectionSettings? other)
278
272
return false ;
279
273
}
280
274
281
- if ( other is ConnectionSettings connectionSettings )
275
+ if ( Object . ReferenceEquals ( this , other ) )
282
276
{
283
- return _address . Host == connectionSettings . Host &&
284
- _address . Port == connectionSettings . Port &&
285
- _address . Path == connectionSettings . Path &&
286
- _address . User == connectionSettings . User &&
287
- _address . Password == connectionSettings . Password &&
288
- _address . Scheme == connectionSettings . Scheme ;
277
+ return true ;
289
278
}
290
279
291
- return false ;
280
+ return Equals ( other ) ;
292
281
}
293
282
294
- internal Address Address => _address ;
295
-
296
- public IEnumerable < Uri > ? Uris => throw new NotImplementedException ( ) ;
297
-
298
- // public RecoveryConfiguration RecoveryConfiguration { get; set; } = RecoveryConfiguration.Create();
283
+ public override int GetHashCode ( )
284
+ {
285
+ return HashCode . Combine ( _address . Host , _address . Port ,
286
+ _virtualHost , _address . User , _address . Password ,
287
+ _address . Scheme , _containerId , _address . Path ) ;
288
+ }
299
289
300
290
///<summary>
301
291
/// Unescape a string, protecting '+'.
0 commit comments