/// <summary> /// Initialisiert eine neue Instanz der <see cref="RestClient"/> Klasse. /// </summary> /// <param name="options"></param> public RestClient(Action <RestClientOptions> options) { if (options == null) { throw new ArgumentNullException(nameof(options)); } _options = new RestClientOptions(); options(_options); ThrowIfInvalidOptions(_options); }
/// <summary> /// Prüft die Eigenschaften der <see cref="RestClientOptions"/>. /// </summary> /// <param name="options"></param> private void ThrowIfInvalidOptions(RestClientOptions options) { if (string.IsNullOrWhiteSpace(options.ServerAddress)) { throw new ArgumentNullException(nameof(RestClientOptions.ServerAddress)); } if (options.Credentials == null) { throw new ArgumentNullException(nameof(RestClientOptions.Credentials)); } else if (!options.Credentials.HasValue) { throw new ArgumentException(nameof(RestClientOptions.Credentials)); } }
/// <summary> /// Initialisiert eine neue Instanz der <see cref="RestClient"/> Klasse. /// </summary> /// <param name="options"></param> public RestClient(RestClientOptions options) { _options = options ?? throw new ArgumentNullException(nameof(options)); ThrowIfInvalidOptions(_options); }