/// <summary> /// Constructs a client for executing all api commands. /// </summary> /// <param name="subdomain">The harvest account subdomain</param> /// <param name="username">The harvest account username (optional for OAuth)</param> /// <param name="password">The harvest account password (optional for OAuth)</param> /// <param name="clientId">The harvest account client OAuth ID (optional for basic auth)</param> /// <param name="clientSecret">The harvest account client OAuth secret (optional for basic auth)</param> /// <param name="accessToken">The harvest account OAuth token (optional for basic auth)</param> /// <param name="dateFormat">The date format of the harvest account (default: yyyy-MM-dd)</param> private HarvestRestClient(string subdomain, string username, string password, string clientId, string clientSecret, string accessToken, string dateFormat, IAssemblyInformation assemblyInformation, IEnvironmentInformation environmentInformation, IRestSharpFactory restSharpFactory) { this.Username = username; this.Password = password; this.ClientId = clientId; this.ClientSecret = clientSecret; this.AccessToken = accessToken; this.DateFormat = dateFormat ?? "yyyy-MM-dd"; this.BaseUrl = "https://" + subdomain + ".harvestapp.com/"; var assemblyVersion = assemblyInformation.Version; var environmentVersion = environmentInformation.Version; var userAgent = string.Format("harvest.net/{0} (.NET {1})", assemblyVersion, environmentVersion); if (username != null && password != null) { _client = restSharpFactory.GetWebClient(BaseUrl, userAgent, username, password); } else if (accessToken != null) { _client = restSharpFactory.GetWebClient(BaseUrl, userAgent, accessToken); } else { _client = restSharpFactory.GetWebClient(BaseUrl, userAgent); } }
/// <summary> /// Initializes a new instance of the <see cref="Stargate" /> class. /// </summary> /// <param name="options">The options.</param> /// <param name="resourceBuilder">The resource builder.</param> /// <param name="restSharp">The RestSharp factory.</param> /// <param name="converterFactory">The converter factory.</param> /// <param name="errorProvider">The error provider.</param> /// <param name="scannerConverter">The scanner converter.</param> public Stargate(IStargateOptions options, IResourceBuilder resourceBuilder, IRestSharpFactory restSharp, IMimeConverterFactory converterFactory, IErrorProvider errorProvider, IScannerOptionsConverter scannerConverter) { _resourceBuilder = resourceBuilder; _restSharp = restSharp; _errorProvider = errorProvider; _scannerConverter = scannerConverter; _client = _restSharp.CreateClient(options.ServerUrl); options.ContentType = string.IsNullOrEmpty(options.ContentType) ? DefaultContentType : options.ContentType; _converter = converterFactory.CreateConverter(options.ContentType); options.FalseRowKey = string.IsNullOrEmpty(options.FalseRowKey) ? DefaultFalseRowKey : options.FalseRowKey; Options = options; }
/// <summary> /// Initializes a new instance of the <see cref="Stargate" /> class. /// </summary> /// <param name="options">The options.</param> /// <param name="resourceBuilderFactory">The resource builder factory.</param> /// <param name="restSharp">The RestSharp factory.</param> /// <param name="converterFactory">The converter factory.</param> /// <param name="errorProvider">The error provider.</param> /// <param name="scannerConverter">The scanner converter.</param> public Stargate(IStargateOptions options, Func <IStargateOptions, IResourceBuilder> resourceBuilderFactory, IRestSharpFactory restSharp, IMimeConverterFactory converterFactory, IErrorProvider errorProvider, IScannerOptionsConverter scannerConverter) { ResourceBuilder = resourceBuilderFactory(options); RestSharp = restSharp; ErrorProvider = errorProvider; ScannerConverter = scannerConverter; Client = RestSharp.CreateClient(options.ServerUrl); options.ContentType = string.IsNullOrEmpty(options.ContentType) ? DefaultContentType : options.ContentType; Converter = converterFactory.CreateConverter(options.ContentType); options.FalseRowKey = string.IsNullOrEmpty(options.FalseRowKey) ? DefaultFalseRowKey : options.FalseRowKey; Options = options; }
/// <summary> /// Initializes a new client using basic HTTP authentication and non-default dependencies /// </summary> /// <param name="subdomain">The subdomain of the harvest account to connect to</param> /// <param name="username">The username to authenticate with</param> /// <param name="password">The password to authenticate with</param> public HarvestRestClient(string subdomain, string username, string password, IAssemblyInformation assemblyInformation, IEnvironmentInformation environmentInformation, IRestSharpFactory restSharpFactory) : this(subdomain, username, password, null, null, null, null, assemblyInformation, environmentInformation, restSharpFactory) { }
public RequestExecutor(IRestSharpFactory restSharpFactory, IResponseVerifier responseVerifier) { _restSharpFactory = restSharpFactory; _responseVerifier = responseVerifier; }
/// <summary> /// 构造注入: ContainerBuilder /// </summary> /// <param name="builder"></param> public TestClass(IRestSharpFactory c, ILifetimeScope scope) { _c = c; _scope = scope; }
public HandshakeClient(IRestSharpFactory restSharpFactory) { _restSharpFactory = restSharpFactory; }
public ConnectionFactory() { _restSharpFactory = new RestSharpFactory(); _responseVerifier = new ResponseVerifier(); _requestExecutor = new RequestExecutor(_restSharpFactory, _responseVerifier); }
public ConnectionFactory() { _restSharpFactory = new RestSharpFactory(); }
public ChatMessenger(IRestSharpFactory restSharpFactory) { _restSharpFactory = restSharpFactory; }