Skip to content

Commit 726a81a

Browse files
committed
ConnectionFactory: make public fields into properties
1 parent 50f7e65 commit 726a81a

File tree

1 file changed

+19
-28
lines changed

1 file changed

+19
-28
lines changed

projects/client/RabbitMQ.Client/src/client/api/ConnectionFactory.cs

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -150,28 +150,27 @@ public class ConnectionFactory : ConnectionFactoryBase, IConnectionFactory
150150
/// <summary>
151151
/// SASL auth mechanisms to use.
152152
/// </summary>
153-
public IList<AuthMechanismFactory> AuthMechanisms = DefaultAuthMechanisms;
153+
public IList<AuthMechanismFactory> AuthMechanisms { get; set; } = DefaultAuthMechanisms;
154154

155155
/// <summary>
156156
/// Set to true to enable automatic connection recovery.
157157
/// </summary>
158-
public bool AutomaticRecoveryEnabled;
158+
public bool AutomaticRecoveryEnabled { get; set; }
159159

160160
/// <summary>
161161
/// Used to select next hostname to try when performing
162162
/// connection recovery (re-connecting). Is not used for
163163
/// non-recovering connections.
164164
/// </summary>
165-
public IHostnameSelector HostnameSelector = new RandomHostnameSelector();
165+
public IHostnameSelector HostnameSelector { get; set; } = new RandomHostnameSelector();
166166

167167
/// <summary>The host to connect to.</summary>
168-
public String HostName = "localhost";
168+
public string HostName { get; set; } = "localhost";
169169

170170
/// <summary>
171171
/// Amount of time client will wait for before re-trying to recover connection.
172172
/// </summary>
173-
public TimeSpan NetworkRecoveryInterval = TimeSpan.FromSeconds(5);
174-
173+
public TimeSpan NetworkRecoveryInterval { get; set; } = TimeSpan.FromSeconds(5);
175174
private TimeSpan m_handshakeContinuationTimeout = TimeSpan.FromSeconds(10);
176175
private TimeSpan m_continuationTimeout = TimeSpan.FromSeconds(20);
177176

@@ -199,58 +198,50 @@ public TimeSpan ContinuationTimeout
199198
/// The port to connect on. <see cref="AmqpTcpEndpoint.UseDefaultPort"/>
200199
/// indicates the default for the protocol should be used.
201200
/// </summary>
202-
public int Port = AmqpTcpEndpoint.UseDefaultPort;
201+
public int Port { get; set; } = AmqpTcpEndpoint.UseDefaultPort;
203202

204203
/// <summary>
205204
/// Protocol used, only AMQP 0-9-1 is supported in modern versions.
206205
/// </summary>
207-
public IProtocol Protocol = Protocols.DefaultProtocol;
206+
public IProtocol Protocol { get; set; } = Protocols.DefaultProtocol;
208207

209208
/// <summary>
210209
/// Timeout setting for connection attempts (in milliseconds).
211210
/// </summary>
212-
public int RequestedConnectionTimeout = DefaultConnectionTimeout;
211+
public int RequestedConnectionTimeout { get; set; } = DefaultConnectionTimeout;
213212

214213
/// <summary>
215214
/// Timeout setting for socket read operations (in milliseconds).
216215
/// </summary>
217-
public int SocketReadTimeout = DefaultConnectionTimeout;
216+
public int SocketReadTimeout { get; set; } = DefaultConnectionTimeout;
218217

219218
/// <summary>
220219
/// Timeout setting for socket write operations (in milliseconds).
221220
/// </summary>
222-
public int SocketWriteTimeout = DefaultConnectionTimeout;
221+
public int SocketWriteTimeout { get; set; } = DefaultConnectionTimeout;
223222

224223
/// <summary>
225224
/// Ssl options setting.
226225
/// </summary>
227-
public SslOption Ssl = new SslOption();
226+
public SslOption Ssl { get; set; } = new SslOption();
228227

229228
/// <summary>
230229
/// Set to true to make automatic connection recovery also recover topology (exchanges, queues, bindings, etc).
231230
/// </summary>
232-
public bool TopologyRecoveryEnabled = true;
231+
public bool TopologyRecoveryEnabled { get; set; } = true;
233232

234233
/// <summary>
235234
/// Task scheduler connections created by this factory will use when
236235
/// dispatching consumer operations, such as message deliveries.
237236
/// </summary>
238-
public TaskScheduler TaskScheduler { get; set; }
237+
public TaskScheduler TaskScheduler { get; set; } = TaskScheduler.Default;
239238

240239
/// <summary>
241240
/// Construct a fresh instance, with all fields set to their respective defaults.
242241
/// </summary>
243242
public ConnectionFactory()
244243
{
245-
this.TaskScheduler = TaskScheduler.Default;
246-
VirtualHost = DefaultVHost;
247-
UserName = DefaultUser;
248-
RequestedHeartbeat = DefaultHeartbeat;
249-
RequestedFrameMax = DefaultFrameMax;
250-
RequestedChannelMax = DefaultChannelMax;
251-
Password = DefaultPass;
252244
ClientProperties = Connection.DefaultClientProperties();
253-
UseBackgroundThreadsForIO = false;
254245
}
255246

256247
/// <summary>
@@ -291,22 +282,22 @@ public Uri uri
291282
/// <summary>
292283
/// Password to use when authenticating to the server.
293284
/// </summary>
294-
public string Password { get; set; }
285+
public string Password { get; set; } = DefaultPass;
295286

296287
/// <summary>
297288
/// Maximum channel number to ask for.
298289
/// </summary>
299-
public ushort RequestedChannelMax { get; set; }
290+
public ushort RequestedChannelMax { get; set; } = DefaultChannelMax;
300291

301292
/// <summary>
302293
/// Frame-max parameter to ask for (in bytes).
303294
/// </summary>
304-
public uint RequestedFrameMax { get; set; }
295+
public uint RequestedFrameMax { get; set; } = DefaultFrameMax;
305296

306297
/// <summary>
307298
/// Heartbeat timeout to use when negotiating with the server (in seconds).
308299
/// </summary>
309-
public ushort RequestedHeartbeat { get; set; }
300+
public ushort RequestedHeartbeat { get; set; } = DefaultHeartbeat;
310301

311302
/// <summary>
312303
/// When set to true, background thread will be used for the I/O loop.
@@ -316,12 +307,12 @@ public Uri uri
316307
/// <summary>
317308
/// Username to use when authenticating to the server.
318309
/// </summary>
319-
public string UserName { get; set; }
310+
public string UserName { get; set; } = DefaultUser;
320311

321312
/// <summary>
322313
/// Virtual host to access during this connection.
323314
/// </summary>
324-
public string VirtualHost { get; set; }
315+
public string VirtualHost { get; set; } = DefaultVHost;
325316

326317
/// <summary>
327318
/// Given a list of mechanism names supported by the server, select a preferred mechanism,

0 commit comments

Comments
 (0)