public static void ConstructorThrowsIfInnerIsNull()
        {
            // Arrange
            IEndPointSource inner         = null;
            var             cacheDuration = TimeSpan.FromHours(1);

            // Act and Assert
            Assert.Throws <ArgumentNullException>("inner", () => new CachedEndpointSource(inner, cacheDuration));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SocketTransport"/> class.
        /// </summary>
        /// <param name="endPointSource">The <see cref="IEndPointSource"/> to use.</param>
        /// <param name="socketProtocol">Udp or Ip sockets</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="endPointSource"/> is <see langword="null"/>.
        /// </exception>
        public SocketTransport(IEndPointSource endPointSource, SocketProtocol socketProtocol)
        {
            _endpointSource = endPointSource ?? throw new ArgumentNullException(nameof(endPointSource));

            if (!Enum.IsDefined(typeof(SocketProtocol), socketProtocol))
            {
                throw new ArgumentOutOfRangeException(nameof(socketProtocol), socketProtocol, $"Invalid {nameof(SocketProtocol)} value specified.");
            }
            _socketProtocol = socketProtocol;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CachedEndpointSource"/> class.
        /// </summary>
        /// <param name="inner">The inner <see cref="IEndPointSource"/> to use.</param>
        /// <param name="cacheDuration">The duration values should be cached for.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="inner"/> is <see langword="null"/>.
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        /// <paramref name="cacheDuration"/> is less than or equal to <see cref="TimeSpan.Zero"/>.
        /// </exception>
        public CachedEndpointSource(IEndPointSource inner, TimeSpan cacheDuration)
        {
            _inner = inner ?? throw new ArgumentNullException(nameof(inner));

            if (cacheDuration <= TimeSpan.Zero)
            {
                throw new ArgumentOutOfRangeException(nameof(cacheDuration), cacheDuration, "The end point cache duration must be a positive TimeSpan value.");
            }

            _cachedValue   = null;
            _cacheDuration = cacheDuration;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="CachedEndpointSource"/> class.
 /// </summary>
 /// <param name="inner">The inner <see cref="IEndPointSource"/> to use.</param>
 /// <param name="cacheDuration">The duration values should be cached for.</param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="inner"/> is <see langword="null"/>.
 /// </exception>
 public CachedEndpointSource(IEndPointSource inner, TimeSpan cacheDuration)
 {
     _inner         = inner ?? throw new ArgumentNullException(nameof(inner));
     _cachedValue   = null;
     _cacheDuration = cacheDuration;
 }
Exemplo n.º 5
0
 public MillisecondSwitcher(IEndPointSource endpointSource1, IEndPointSource endpointSource2)
 {
     _endpointSource1 = endpointSource1;
     _endpointSource2 = endpointSource2;
 }
Exemplo n.º 6
0
#pragma warning disable CA1801 // Used to validate that IEndPointSource is in DI
            public MyTransport(IEndPointSource endpointSource)
            {
            }