123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
-
- using System;
- using System.Collections.Generic;
- using Aliyun.OSS;
- using Aliyun.OSS.Util;
- namespace Aliyun.OSS.Common
- {
-
-
-
- public class ClientConfiguration : ICloneable
- {
- private const string UserAgentPrefix = "aliyun-sdk-dotnet/";
- private static readonly string _userAgent = GetDefaultUserAgent();
-
-
-
- private int _connectionTimeout = -1;
- private int _maxErrorRetry = 3;
- private int _proxyPort = -1;
- private bool _isCname = false;
-
-
-
- public const int ConnectionLimit = 512;
- private Protocol _protocol = Protocol.Http;
-
-
-
- public string UserAgent
- {
- get { return _userAgent; }
- }
-
-
-
- public string ProxyHost { get; set; }
-
-
-
- public int ProxyPort
- {
- get { return _proxyPort; }
- set { _proxyPort = value; }
- }
-
-
-
- public string ProxyUserName { get; set; }
-
-
-
- public string ProxyPassword { get; set; }
-
-
-
- public string ProxyDomain { get; set; }
-
-
-
- public int ConnectionTimeout
- {
- get { return _connectionTimeout; }
- set { _connectionTimeout = value; }
- }
-
-
-
- public int MaxErrorRetry
- {
- get { return _maxErrorRetry; }
- set { _maxErrorRetry = value; }
- }
-
-
-
- public Protocol Protocol
- {
- get { return _protocol; }
- set { _protocol = value; }
- }
-
-
-
-
- public bool IsCname
- {
- get
- {
- return _isCname;
- }
- set
- {
- _isCname = value;
- }
- }
-
-
-
-
-
-
-
-
-
- public void SetCustomEpochTicks(long epochTicks)
- {
- var epochTime = new DateTime(1970, 1, 1);
- var timeSpan = DateTime.UtcNow.Subtract(epochTime);
- var localTicks = (long)timeSpan.TotalSeconds;
- TickOffset = epochTicks - localTicks;
- }
-
-
-
- public long TickOffset { get; internal set; }
-
-
-
-
- public object Clone()
- {
- return new ClientConfiguration
- {
- ConnectionTimeout = ConnectionTimeout,
- MaxErrorRetry = MaxErrorRetry,
- ProxyDomain = ProxyDomain,
- ProxyHost = ProxyHost,
- ProxyPassword = ProxyPassword,
- ProxyPort = ProxyPort,
- ProxyUserName = ProxyUserName,
- TickOffset = TickOffset
- };
- }
-
-
-
- private static string GetDefaultUserAgent()
- {
- return UserAgentPrefix +
- typeof(ClientConfiguration).Assembly.GetName().Version + "(" +
- OssUtils.DetermineOsVersion() + "/" +
- Environment.OSVersion.Version + "/" +
- OssUtils.DetermineSystemArchitecture() + ";" +
- Environment.Version + ")";
- }
- }
- }
|