/// <summary> /// Initializes a new instance of the <see cref="ApiConnection"/> class. /// </summary> /// <param name="connectionSettings">The connection settings.</param> /// <exception cref="System.ArgumentNullException"> /// connectionSettings - <see cref="ApiConnectionServer.Host"/> of one of the servers is null. /// or /// connectionSettings - <see cref="ApiConnectionServer.Host"/> of one of the servers is empty. /// </exception> public ApiConnection(ApiConnectionSettings connectionSettings) { ThrowIfServerIsInvalid(connectionSettings.MainServer); if (connectionSettings.CacheServers != null) { foreach (var cacheServer in connectionSettings.CacheServers) { ThrowIfServerIsInvalid(cacheServer); } } _connectionSettings = connectionSettings; }
/// <summary> /// Initializes a new instance of the <see cref="ApiConnection"/> class. /// </summary> /// <param name="connectionSettings">The connection settings.</param> /// <exception cref="System.ArgumentNullException"> /// connectionSettings - <see cref="ApiConnectionServer.Host"/> of one of the servers is null. /// or /// connectionSettings - <see cref="ApiConnectionServer.Host"/> of one of the servers is empty. /// </exception> /// <exception cref="System.ArgumentOutOfRangeException"> /// connectionSettings - <see cref="ApiConnectionServer.Timeout"/> of one of the servers is less than zero and is not <see cref="System.Threading.Timeout.Infinite" />. /// </exception> public ApiConnection(ApiConnectionSettings connectionSettings) { ThrowIfServerIsInvalid(connectionSettings.MainServer); if (connectionSettings.CacheServers != null) { foreach (var cacheServer in connectionSettings.CacheServers) { ThrowIfServerIsInvalid(cacheServer); } } _connectionSettings = connectionSettings; _jsonSerializerSettings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Ignore }; }
/// <summary> /// Initializes a new instance of the <see cref="ApiConnection"/> class. /// </summary> /// <param name="connectionSettings">The connection settings.</param> /// <exception cref="System.ArgumentNullException"> /// connectionSettings - Url to main server is null. /// or /// connectionSettings - Url to main server is empty. /// </exception> /// <exception cref="System.ArgumentOutOfRangeException"> /// connectionSettings - Timeout value is less than zero and is not <see cref="System.Threading.Timeout.Infinite" />. /// </exception> protected ApiConnection(ApiConnectionSettings connectionSettings) { if (connectionSettings.MainServer == null) { throw new ArgumentNullException("connectionSettings", "Url to main server is null."); } if (string.IsNullOrEmpty(connectionSettings.MainServer)) { throw new ArgumentNullException("connectionSettings", "Url to main server is empty."); } if (connectionSettings.Timeout < 0 && connectionSettings.Timeout != System.Threading.Timeout.Infinite) { throw new ArgumentOutOfRangeException("connectionSettings", "Timeout value is less than zero and is not System.Threading.Timeout.Infinite."); } _connectionSettings = connectionSettings; _jsonSerializerSettings = new JsonSerializerSettings(); _jsonSerializerSettings.NullValueHandling = NullValueHandling.Ignore; _jsonSerializerSettings.MissingMemberHandling = MissingMemberHandling.Ignore; }
public void SetUp() { _apiConnectionSettings = new ApiConnectionSettings { MainServer = new ApiConnectionServer() { Host = "main_server" }, CacheServers = new[] { new ApiConnectionServer() { Host = "cache_server_1" }, new ApiConnectionServer() { Host = "cache_server_2" } } }; }
public void SetUp() { _apiConnectionSettings = new ApiConnectionSettings(); _apiConnectionSettings.MainServer = new ApiConnectionServer() { Host = "main_server", Timeout = 1 }; _apiConnectionSettings.CacheServers = new[] { new ApiConnectionServer() { Host = "cache_server_1", Timeout = 1 }, new ApiConnectionServer() { Host = "cache_server_2", Timeout = 1 } }; }