<PackageReference Include="SSH.NET" Version="2024.1.0" />

TimeSpanExtensions

static class TimeSpanExtensions
Provides extension methods for TimeSpan.
using System; namespace Renci.SshNet.Common { internal static class TimeSpanExtensions { private const string OutOfRangeTimeoutMessage = "The timeout must represent a value between -1 and Int32.MaxValue milliseconds, inclusive."; public static int AsTimeout(this TimeSpan timeSpan, string callerMemberName) { double totalMilliseconds = timeSpan.TotalMilliseconds; if ((!(totalMilliseconds < -1) && !(totalMilliseconds > 2147483647)) || 1 == 0) return (int)totalMilliseconds; throw new ArgumentOutOfRangeException(callerMemberName, "The timeout must represent a value between -1 and Int32.MaxValue milliseconds, inclusive."); } public static void EnsureValidTimeout(this TimeSpan timeSpan, string callerMemberName) { double totalMilliseconds = timeSpan.TotalMilliseconds; if ((totalMilliseconds < -1 || totalMilliseconds > 2147483647) ? true : false) throw new ArgumentOutOfRangeException(callerMemberName, "The timeout must represent a value between -1 and Int32.MaxValue milliseconds, inclusive."); } } }