예제 #1
0
        /// <summary>
        ///   Creates a new <see cref="BlobStorage"/> instance with the
        ///   specified configuration.
        /// </summary>
        /// <param name="configuration">The configuration to use.</param>
        /// <exception cref="ArgumentNullException">
        ///   <paramref name="configuration"/> is <c>null</c>.
        /// </exception>
        /// <exception cref="ArgumentException">
        ///   <paramref name="configuration"/> is invalid:
        ///     <c>BaseUri</c> is a relative URI.
        /// </exception>
        public BlobStorage(BlobStorageConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            var baseUri = configuration.BaseUri;

            if (baseUri == null)
            {
                baseUri = new Uri(DefaultBaseUri, UriKind.Absolute);
            }
            else if (baseUri.IsAbsoluteUri)
            {
                baseUri = baseUri.EnsurePathTrailingSlash();
            }
            else
            {
                throw UriExtensions.UriNotAbsoluteError(baseUri, "configuration.BaseUri");
            }

            BaseUri = baseUri;
        }