diff options
Diffstat (limited to 'src/slskd/Common/Extensions.cs')
| -rw-r--r-- | src/slskd/Common/Extensions.cs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/slskd/Common/Extensions.cs b/src/slskd/Common/Extensions.cs index 4d463092..32a9b26e 100644 --- a/src/slskd/Common/Extensions.cs +++ b/src/slskd/Common/Extensions.cs @@ -21,10 +21,12 @@ namespace slskd using System.Collections.Generic; using System.IO; using System.Linq; + using System.Net.Sockets; using System.Reflection; using System.Text.Json; using System.Text.Json.Serialization; using System.Text.RegularExpressions; + using Soulseek; using YamlDotNet.Serialization; using YamlDotNet.Serialization.NamingConventions; @@ -283,6 +285,36 @@ namespace slskd } /// <summary> + /// Creates a copy of this instance with the specified parameters changed. + /// </summary> + /// <param name="o">The options instance to copy.</param> + /// <param name="readBufferSize">The read buffer size for underlying TCP connections.</param> + /// <param name="writeBufferSize">The write buffer size for underlying TCP connections.</param> + /// <param name="writeQueueSize">The size of the write queue for double buffered writes.</param> + /// <param name="connectTimeout">The connection timeout, in milliseconds, for client and peer TCP connections.</param> + /// <param name="inactivityTimeout">The inactivity timeout, in milliseconds, for peer TCP connections.</param> + /// <param name="proxyOptions">Optional SOCKS 5 proxy configuration options.</param> + /// <param name="configureSocketAction"> + /// The delegate invoked during instantiation to configure the server Socket instance. + /// </param> + /// <returns>The new instance.</returns> + public static ConnectionOptions With( + this ConnectionOptions o, + int? readBufferSize = null, + int? writeBufferSize = null, + int? writeQueueSize = null, + int? connectTimeout = null, + int? inactivityTimeout = null, + ProxyOptions proxyOptions = null, + Action<Socket> configureSocketAction = null) => new ConnectionOptions( + readBufferSize: readBufferSize ?? o.ReadBufferSize, + writeBufferSize: writeBufferSize ?? o.WriteBufferSize, + writeQueueSize: writeQueueSize ?? o.WriteQueueSize, + connectTimeout: connectTimeout ?? o.ConnectTimeout, + inactivityTimeout: inactivityTimeout ?? o.InactivityTimeout, + configureSocketAction: configureSocketAction ?? o.ConfigureSocketAction); + + /// <summary> /// Deserializes this string from json to an object of type <typeparamref name="T"/>. /// </summary> /// <typeparam name="T">The type to which to deserialize the string.</typeparam> |
