예제 #1
0
        /// <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);
        }
예제 #2
0
        /// <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));
            }
        }
예제 #3
0
 /// <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);
 }