123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using COSXML.Network;
- namespace COSXML
- {
-
-
-
- public sealed class CosXmlConfig
- {
- private HttpClientConfig httpConfig;
- private string appid;
- private string region;
- private bool isHttps = true;
- private bool isDebug;
-
-
-
-
- public string endpointSuffix { get; private set; }
-
-
-
-
- public string host { get; private set; }
- private CosXmlConfig(Builder builder)
- {
- this.appid = builder.appid;
- this.region = builder.region;
- this.isHttps = builder.isHttps;
- this.httpConfig = builder.httpClientConfigBuilder.Build();
- this.isDebug = builder.isDebug;
- this.endpointSuffix = builder.endpointSuffix;
- this.host = builder.host;
- }
-
-
-
-
- public string Appid
- {
- get
- {
- return appid;
- }
- }
-
-
-
-
- public string Region
- {
- get
- {
- return region;
- }
- }
-
-
-
-
- public bool IsHttps
- {
- get
- {
- return isHttps;
- }
- }
-
-
-
-
- public HttpClientConfig HttpConfig
- {
- get
- {
- return httpConfig;
- }
- }
-
-
-
-
- public bool IsDebugLog
- {
- get
- {
- return isDebug;
- }
- }
-
-
-
- public sealed class Builder
- {
- internal string appid;
- internal string region;
- internal bool isHttps = true;
- internal HttpClientConfig.Builder httpClientConfigBuilder;
- internal bool isDebug = false;
- internal string endpointSuffix;
- internal string host;
-
-
-
- public Builder()
- {
- httpClientConfigBuilder = new HttpClientConfig.Builder();
- }
-
-
-
-
-
- public Builder SetAppid(string appid)
- {
- this.appid = appid;
- return this;
- }
-
-
-
-
-
- public Builder SetRegion(string region)
- {
-
- if(region == null || region == "") {
- throw new CosException.CosClientException(
- (int)COSXML.Common.CosClientError.InvalidArgument,
- "region cannot be empty"
- );
- }
- this.region = region;
- return this;
- }
-
-
-
-
-
- public Builder IsHttps(bool isHttps)
- {
- this.isHttps = isHttps;
- return this;
- }
-
-
-
-
-
- public Builder SetConnectionLimit(int connectionLimit)
- {
- this.httpClientConfigBuilder.SetConnectionLimit(connectionLimit);
- return this;
- }
-
-
-
-
-
- public Builder SetConnectionTimeoutMs(int connectionTimeoutMs)
- {
- this.httpClientConfigBuilder.SetConnectionTimeoutMs(connectionTimeoutMs);
- return this;
- }
-
-
-
-
-
- public Builder SetReadWriteTimeoutMs(int readWriteTimeoutMs)
- {
- this.httpClientConfigBuilder.SetReadWriteTimeoutMs(readWriteTimeoutMs);
- return this;
- }
-
-
-
-
-
- public Builder SetHttpKeepAlive(bool keepAlive)
- {
- this.httpClientConfigBuilder.SetHttpKeepAlive(keepAlive);
- return this;
- }
-
-
-
-
-
- public Builder SetProxyHost(string host)
- {
- this.httpClientConfigBuilder.SetProxyHost(host);
- return this;
- }
-
-
-
-
-
- public Builder SetProxyPort(int port)
- {
- this.httpClientConfigBuilder.SetProxyPort(port);
- return this;
- }
-
-
-
-
-
- public Builder SetProxyUserName(string userName)
- {
- this.httpClientConfigBuilder.SetProxyUserName(userName);
- return this;
- }
-
-
-
-
-
- public Builder SetProxyUserPassword(string password)
- {
- this.httpClientConfigBuilder.SetProxyUserPassword(password);
- return this;
- }
-
-
-
-
-
- public Builder SetProxyDomain(string domain)
- {
- this.httpClientConfigBuilder.SetProxyDomain(domain);
- return this;
- }
-
-
-
-
-
- public Builder SetAllowAutoRedirect(bool isAllow)
- {
- this.httpClientConfigBuilder.AllowAutoRedirect(isAllow);
- return this;
- }
-
-
-
-
-
- public Builder SetDebugLog(bool isDebug)
- {
- this.isDebug = isDebug;
- return this;
- }
-
-
-
-
-
- public Builder SetEndpointSuffix(string suffix)
- {
- this.endpointSuffix = suffix;
- return this;
- }
-
-
-
-
-
- public Builder SetHost(string host)
- {
- this.host = host;
- return this;
- }
-
-
-
-
- public CosXmlConfig Build()
- {
- return new CosXmlConfig(this);
- }
- }
- }
- }
|