/// <summary> /// Initializes a new instance of the <see cref="LoadBalancerVirtualAddress"/> class /// with the specified virtual address type and family. /// </summary> /// <param name="type">The virtual address type.</param> /// <param name="version">The address family for this virtual address, or <see langword="null"/> to not specify the address family.</param> /// <exception cref="ArgumentNullException">If <paramref name="type"/> is <see langword="null"/>.</exception> /// <exception cref="NotSupportedException">If <paramref name="version"/> is not <see cref="AddressFamily.InterNetwork"/> or <see cref="AddressFamily.InterNetworkV6"/>.</exception> public LoadBalancerVirtualAddress(LoadBalancerVirtualAddressType type, AddressFamily? version) { if (type == null) throw new ArgumentNullException("type"); _type = type; if (version.HasValue) { switch (version) { case AddressFamily.InterNetwork: _ipVersion = "IPV4"; break; case AddressFamily.InterNetworkV6: _ipVersion = "IPV6"; break; default: throw new NotSupportedException("The specified address family is not supported by this service."); } } }
/// <summary> /// Initializes a new instance of the <see cref="LoadBalancerVirtualAddress"/> class /// with the specified virtual address type. /// </summary> /// <param name="type">The virtual address type.</param> /// <exception cref="ArgumentNullException">If <paramref name="type"/> is <see langword="null"/>.</exception> public LoadBalancerVirtualAddress(LoadBalancerVirtualAddressType type) : this(type, null) { }
public static LoadBalancerVirtualAddress AddVirtualAddress(this ILoadBalancerService service, LoadBalancerId loadBalancerId, LoadBalancerVirtualAddressType type, AddressFamily addressFamily) { if (service == null) throw new ArgumentNullException("service"); try { return service.AddVirtualAddressAsync(loadBalancerId, type, addressFamily, AsyncCompletionOption.RequestSubmitted, CancellationToken.None, null).Result; } catch (AggregateException ex) { ReadOnlyCollection<Exception> innerExceptions = ex.Flatten().InnerExceptions; if (innerExceptions.Count == 1) throw innerExceptions[0]; throw; } }