public void SetUp() { factory = Substitute.For<IRequestFactory>(); factory.CreateClient().Execute(factory.CreateRequest()).StatusCode = HttpStatusCode.OK; descendant = new OAuthClientDescendant( factory, Substitute.For<IClientConfiguration>()); }
public Client(Uri rpcUri, Uri streamingUri, string appKey,IJsonSerializer serializer, IRequestFactory factory) : base(serializer, factory) { #if SILVERLIGHT #if WINDOWS_PHONE UserAgent = "CIAPI.PHONE7."+ GetVersionNumber(); #else UserAgent = "CIAPI.SILVERLIGHT."+ GetVersionNumber(); #endif #else UserAgent = "CIAPI.CS." + GetVersionNumber(); #endif AppKey=appKey; _client=this; _rootUri = rpcUri; _streamingUri = streamingUri; this. Authentication = new _Authentication(this); this. PriceHistory = new _PriceHistory(this); this. News = new _News(this); this. CFDMarkets = new _CFDMarkets(this); this. SpreadMarkets = new _SpreadMarkets(this); this. Market = new _Market(this); this. Preference = new _Preference(this); this. TradesAndOrders = new _TradesAndOrders(this); this. AccountInformation = new _AccountInformation(this); this. Messaging = new _Messaging(this); this. Watchlist = new _Watchlist(this); this. ClientApplication = new _ClientApplication(this); this. ExceptionHandling = new _ExceptionHandling(this); Log.Debug("Rpc.Client created for " + _rootUri.AbsoluteUri); }
public static RequestInfo Create( RequestMethod method, string target, string uriTemplate, Dictionary<string, object> parameters, string userAgent, Dictionary<string, string> headers, ContentType requestContentType, ContentType responseContentType, TimeSpan cacheDuration, int timeout, int retryCount, Uri uri, string requestBody, IRequestFactory requestFactory) { var result = new RequestInfo { Target = target, UriTemplate = uriTemplate, AllowedRetries = retryCount, Uri = uri, Method = method, UserAgent = userAgent, _headers = new Dictionary<string, string>(headers ?? new Dictionary<string, string>()), RequestBody = requestBody, Parameters = new Dictionary<string, object>(parameters ?? new Dictionary<string, object>()), CacheDuration = cacheDuration, RequestContentType = requestContentType, ResponseContentType = responseContentType, Timeout = timeout }; return result; }
public RequestThrottle(IRequestFactory requestFactory, TimeSpan throttleWindowTime, int throttleWindowCount, int maxPendingRequests) { RequestFactory = requestFactory; ThrottleWindowTime = throttleWindowTime; ThrottleWindowCount = throttleWindowCount; MaxPendingRequests = maxPendingRequests; }
public DeviceLocator(ISocketFactory socketFactory, IRequestFactory requestFactory, IMessageParser messageParser, IDeviceInfoCollector deviceInfoCollector) { _socketFactory = socketFactory; _requestFactory = requestFactory; _messageParser = messageParser; _deviceInfoCollector = deviceInfoCollector; }
public void SetUp() { requestFactory = Substitute.For<IRequestFactory>(); requestFactory.CreateClient().Execute(requestFactory.CreateRequest()).StatusCode = HttpStatusCode.OK; descendant = new DigitalOceanClientDescendant( requestFactory, Substitute.For<IClientConfiguration>()); }
public RpcClient(Uri uri, Uri streamingUri, IRequestCache cache, IRequestFactory requestFactory,IStreamingConnectionFactory streamingConnectionFactory, Dictionary<string, IThrottedRequestQueue> throttleScopes, int retryCount) : base(uri, cache, requestFactory, throttleScopes, retryCount) { _streamingConnectionFactory = streamingConnectionFactory; _streamingUri = streamingUri; }
public User(string username, IRequestFactory requestFactory, IJsonSerializer jsonSerializer, IRestClient restClient) : base(requestFactory, jsonSerializer, restClient) { if (string.IsNullOrEmpty(username)) { throw new ArgumentNullException("username"); } _username = username; }
/// <summary> /// Initializes a new instance of the <see cref="AuthorizationRoot" /> class. /// </summary> /// <param name="configurationManager">The configuration manager.</param> /// <param name="configurationSectionName">Name of the configuration section.</param> /// <param name="requestFactory">The request factory.</param> public AuthorizationRoot( IConfigurationManager configurationManager, string configurationSectionName, IRequestFactory requestFactory) { this.requestFactory = requestFactory; configurationSection = configurationManager .GetConfigSection<OAuth2ConfigurationSection>(configurationSectionName); }
public Channel(string name, IRequestFactory requestFactory, IJsonSerializer jsonSerializer, IRestClient restClient) : base(requestFactory, jsonSerializer, restClient) { if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException("name"); } _name = name; }
public Connection(IRegistrationService registrationService, IRequestFactory requestFactory, IIrcClientFactory ircClientFactory) : this() { Contract.Requires<ArgumentNullException>(registrationService != null, "registrationService"); Contract.Requires<ArgumentNullException>(requestFactory != null, "requestFactory"); Contract.Requires<ArgumentNullException>(ircClientFactory != null, "ircClientFactory"); this.registrationService = registrationService; this.requestFactory = requestFactory; this.ircClientFactory = ircClientFactory; }
public static Task<HttpResponseMessage> FollowLinkAsync( this System.Net.Http.HttpClient httpClient, IRequestFactory requestFactory, IResponseHandler handler = null) { var httpRequestMessage = requestFactory.CreateRequest(); httpRequestMessage.Properties[PropertyKeyLinkRelation] = requestFactory.LinkRelation; return httpClient.SendAsync(httpRequestMessage) .ApplyRepresentationToAsync(handler); }
public void SetUp() { factory = Substitute.For<IRequestFactory>(); var client = Substitute.For<IRestClient>(); var request = Substitute.For<IRestRequest>(); var response = Substitute.For<IRestResponse>(); factory.CreateClient().Returns(client); factory.CreateRequest(null).ReturnsForAnyArgs(request); client.Execute(request).Returns(Task.FromResult(response)); response.StatusCode.Returns(HttpStatusCode.OK); descendant = new VkClientDescendant(factory, Substitute.For<IClientConfiguration>()); }
public RequestController(IJsonSerializer serializer) { _serializer = serializer; //Recorder = new Recorder(_serializer); Id = Guid.NewGuid(); Log.Debug("creating RequestController: " + Id); _requestFactory = new RequestFactory(); _requestCache = new List<RequestInfo>(); _requestQueue = new Queue<RequestInfo>(); _waitHandle = new AutoResetEvent(false); _backgroundThread = new Thread(BackgroundProcess); _backgroundThread.Start(); Log.Debug("created RequestController: " + Id); }
//[Fact] //public Task CompareApproaches() //{ // //// Wrapper Service // //var customerService = new CustomerService(); // //var customer = customerService.GetCustomer(22); // //application.Process(customer); // //// Hypermedia Centric // //var customerLink = linkFactory.Create<CustomerLink>(); // //customerLink.Id = 22; // //application.FollowLink(customerLink); //} private static async Task Follow(IRequestFactory link) { var request = link.CreateRequest(); var httpClient = new HttpClient(); httpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("test", "1.0")); var response = await httpClient.SendAsync(request); var responseHandler = link as IResponseHandler; if (responseHandler != null) { await responseHandler.HandleResponseAsync(link.LinkRelation, response); } }
protected EntityBase(IRequestFactory requestFactory, IJsonSerializer jsonSerializer, IRestClient restClient) { if (requestFactory == null) { throw new ArgumentNullException("requestFactory"); } if (jsonSerializer == null) { throw new ArgumentNullException("jsonSerializer"); } if (restClient == null) { throw new ArgumentNullException("restClient"); } _requestFactory = requestFactory; _jsonSerializer = jsonSerializer; _restClient = restClient; }
public void SetUp() { restRequest = Substitute.For<IRestRequest>(); restResponse = Substitute.For<IRestResponse>(); restClient = Substitute.For<IRestClient>(); restClient.Execute(restRequest).Returns(restResponse); factory = Substitute.For<IRequestFactory>(); factory.NewClient().Returns(restClient); factory.NewRequest().Returns(restRequest); var configuration = Substitute.For<IClientConfiguration>(); configuration.ClientId.Returns("client_id"); configuration.ClientSecret.Returns("client_secret"); configuration.RedirectUri.Returns("http://redirect-uri.net"); configuration.Scope.Returns("scope"); descendant = new OAuth2ClientDescendant(factory, configuration); }
/** * Creates new request with parameters. See documentation for methods here https://vk.com/dev/methods * * @param method API-method name, e.g. audio.get * @param parameters method parameters * @param httpMethod HTTP method for execution, e.g. GET, POST */ protected AbstractRequest(string method, VKParameters parameters, HttpMethod httpMethod, IRequestFactory requestFactory) { methodName = method; if (parameters == null) { parameters = new VKParameters(); } mMethodParameters = new VKParameters(parameters); if (httpMethod == null) httpMethod = HttpMethod.GET; this.httpMethod = httpMethod; this._requestFactory = requestFactory; mAttemptsUsed = 0; secure = true; //By default there is 1 attempt for loading. attempts = 1; //If system language is not supported, we use english mPreferredLang = "en"; //By default we use system language. useSystemLanguage = true; }
public void SetUp() { restRequest = Substitute.For<IRestRequest>(); restResponse = Substitute.For<IRestResponse>(); restResponse.StatusCode.Returns(HttpStatusCode.OK); restResponse.RawBytes.Returns(_encoding.GetBytes("response")); restClient = Substitute.For<IRestClient>(); restClient.Execute(restRequest).Returns(Task.FromResult(restResponse)); factory = Substitute.For<IRequestFactory>(); factory.CreateClient().Returns(restClient); factory.CreateRequest(null).ReturnsForAnyArgs(restRequest); var configuration = Substitute.For<IClientConfiguration>(); configuration.ClientId.Returns("client_id"); configuration.ClientSecret.Returns("client_secret"); configuration.RedirectUri.Returns("http://redirect-uri.net"); configuration.Scope.Returns("scope"); descendant = new OAuth2ClientDescendant(factory, configuration); }
/// <summary> Creates a new <see cref="GitLabLicenseRepository" /> instance. </summary> /// <param name="requestFactory"> An instance of <see cref="IRequestFactory" /> to use for this repository. </param> public GitLabLicenseRepository(IRequestFactory requestFactory) : base(requestFactory) { }
public void SetUp() { requestFactory = Substitute.For<IRequestFactory>(); descendant = new FacebookClientDescendant( requestFactory, Substitute.For<IClientConfiguration>()); }
/// <summary> Creates a new <see cref="SystemHookRepository" /> instance. </summary> /// <param name="requestFactory"> An instance of <see cref="IRequestFactory" /> to use for this repository. </param> public SystemHookRepository(IRequestFactory requestFactory) : base(requestFactory) { }
internal void Configure(IRequestFactory requestFactory) { _requestFactory = requestFactory; }
public StravaClientForTest(IRequestFactory factory, IClientConfiguration configuration) : base(factory, configuration) { }
public GitHubClient(IRequestFactory factory, IClientConfiguration configuration) : base(factory, configuration) { _factory = factory; }
/// <summary> /// Initializes a new instance of the <see cref="WindowsLiveClient"/> class. /// </summary> /// <param name="factory">The factory.</param> /// <param name="configuration">The configuration.</param> public WindowsLiveClient(IRequestFactory factory, IClientConfiguration configuration) : base(factory, configuration) { }
public TwitterClient(IRequestFactory factory, IClientConfiguration configuration) : base(factory, configuration) { }
/// <summary> /// Initializes a new instance of the <see cref="GoogleClient"/> class. /// </summary> /// <param name="factory">The factory.</param> /// <param name="configuration">The configuration.</param> public GoogleClient(IRequestFactory factory, IClientConfiguration configuration) : base(factory, configuration) { }
public OdnoklassnikiClientDescendant(IRequestFactory factory, IClientConfiguration configuration) : base(factory, configuration) { }
internal static IConnector Create(IRequestFactory request, string clientEmail, byte[] privateKey) { return(new Connector(request, clientEmail, privateKey)); }
public void SetUp() { factory = Substitute.For <IRequestFactory>(); factory.CreateClient().Execute(factory.CreateRequest()).StatusCode = HttpStatusCode.OK; descendant = new VkClientDescendant(factory, Substitute.For <IClientConfiguration>()); }
public AclPluginGroups(IRequestFactory requestFactory) { _requestFactory = requestFactory; }
public OAuth2ClientDescendant(IRequestFactory factory, IClientConfiguration configuration) : base(factory, configuration) { }
public WeatherDetailsBuilder(ILogger logger , IRestClient <WeatherDetails> restClient , IReadonlyRepository <City> cityRepository , IRequestFactory requestFactory) : base(logger, restClient, cityRepository, requestFactory) { }
/// <summary> /// Initializes a new instance of the <see cref="OdnoklassnikiClient"/> class. /// </summary> /// <param name="factory">The factory.</param> /// <param name="configuration">The configuration.</param> public OdnoklassnikiClient(IRequestFactory factory, IClientConfiguration configuration) : base(factory, configuration) { _configuration = configuration; }
/// <summary> /// Initializes a new instance of the <see cref="FacebookClient"/> class. /// </summary> /// <param name="factory">The factory.</param> /// <param name="configuration">The configuration.</param> public FacebookClient(IRequestFactory factory, IClientConfiguration configuration) : base(factory, configuration) { }
/// <summary> /// Initializes a new instance of the <see cref="OAuth2Client"/> class. /// </summary> /// <param name="factory">The factory.</param> /// <param name="configuration">The configuration.</param> protected OAuth2Client(IRequestFactory factory, IClientConfiguration configuration) { ExpirationSafetyMargin = TimeSpan.FromSeconds(5); _factory = factory; Configuration = configuration; }
/// <summary> Creates a new <see cref="EmailRepository" /> instance. </summary> /// <param name="requestFactory"> An instance of <see cref="IRequestFactory" /> to use for this repository. </param> public EmailRepository(IRequestFactory requestFactory) : base(requestFactory) { }
/// <summary> /// Initializes a new instance of the <see cref="OAuthClient" /> class. /// </summary> /// <param name="factory">The factory.</param> /// <param name="configuration">The configuration.</param> protected OAuthClient(IRequestFactory factory, IClientConfiguration configuration) { _factory = factory; Configuration = configuration; }
public TwitterClient(IRequestFactory factory, IClientConfiguration configuration) : base(ClientName, RequestTokenEndpoint, LoginEndpoint, TokenEndpoint, UserInfoEndpoint, factory, configuration) { }
static HerokuApi() { mFactory = new RequestFactory(); }
/// <summary> /// Constructor /// </summary> /// <param name="factory"></param> /// <param name="configuration"></param> public DigitalOceanClient(IRequestFactory factory, IClientConfiguration configuration) : base(factory, configuration) { }
internal static HttpRequestMessage CreateRequest(this IRequestFactory factory, EndPoint endpoint) { return(CreateRequest(factory, endpoint, HttpMethod.Get)); }
public void SetUp() { factory = Substitute.For <IRequestFactory>(); descendant = new YandexClientDescendant( factory, Substitute.For <IClientConfiguration>()); }
/// <summary> /// Initializes a new instance of the <see cref="ExactOnlineClient"/> class. /// </summary> /// <param name="factory">The factory.</param> /// <param name="configuration">The configuration.</param> public ExactOnlineClient(IRequestFactory factory, IClientConfiguration configuration) : base(factory, configuration) { }
public YandexClientDescendant(IRequestFactory factory, IClientConfiguration configuration) : base(factory, configuration) { }
internal ProjectApi(IRequestFactory requestFactory) : base(requestFactory) { }
public VSeeHelper() { mFactory = new RequestFactory(); }
public WcfOwinHost(IApplication application, IRequestFactory requestFactory, IResponseMessageFactory responseFactory) { _responseFactory = responseFactory; _requestFactory = requestFactory; _application = application; }
/// <summary> /// Initializes a new instance of the <see cref="SalesforceClient"/> class. /// </summary> /// <param name="factory">The factory.</param> /// <param name="configuration">The configuration.</param> public SalesforceClient(IRequestFactory factory, IClientConfiguration configuration) : base(factory, configuration) { }
internal static WebRequest CreateRequest(RequestInfoBase info, IRequestFactory requestFactory) { WebRequest Request = requestFactory.Create(info.Uri.AbsoluteUri); Request.Method = info.Method.ToString(); if ((info.Method == RequestMethod.POST || info.Method == RequestMethod.PUT)) { Request.ContentType = info.RequestContentType.ToHeaderValue(); } if (Request is HttpWebRequest) { var request = ((HttpWebRequest)Request); switch (info.ResponseContentType) { case ContentType.JSON: request.Accept = "text/plain, text/json, application/json"; break; case ContentType.FORM: request.Accept = "text/plain, text/json, application/json, text/xml, application/xml"; break; case ContentType.XML: request.Accept = "text/xml, application/xml"; break; case ContentType.TEXT: request.Accept = "text/plain"; break; } request.UserAgent = info.UserAgent; var headers = info.Headers; if (headers != null) { foreach (var header in headers) { request.Headers[header.Key] = header.Value.ToString(); } } } if ((info.Method == RequestMethod.POST || info.Method == RequestMethod.PUT)) { if (string.IsNullOrEmpty(info.RequestBody)) { #if !WINDOWS_PHONE Request.ContentLength = 0; #endif } else { // set request stream var gate = new AutoResetEvent(false); byte[] bodyValue = Encoding.UTF8.GetBytes(info.RequestBody); Exception exception = null; Request.BeginGetRequestStream(ac => { try { using ( Stream requestStream = Request.EndGetRequestStream(ac)) { requestStream.Write(bodyValue, 0, bodyValue.Length); requestStream.Flush(); } } catch (Exception ex) { exception = ex; } finally { gate.Set(); } }, null); gate.WaitOne(); // #FIXME: logic to catch stalls conflicts with throttle //if (!gate.WaitOne(10000)) //{ // throw new Exception("timed out setting request body"); //} if (exception != null) { throw exception; } } } return Request; }
/// <summary> /// Initializes a new instance of the <see cref="LinkedInClient"/> class. /// </summary> /// <param name="factory">The factory.</param> /// <param name="configuration">The configuration.</param> public LinkedInClient(IRequestFactory factory, IClientConfiguration configuration) : base(factory, configuration) { }
public Client(Uri uri, IRequestCache cache, IRequestFactory requestFactory, Dictionary<string, IThrottedRequestQueue> throttleScopes, int retryCount) : base(uri,cache, requestFactory, throttleScopes, retryCount) { }
/// <summary> /// Initializes a new instance of the <see cref="TodoistClient"/> class. /// </summary> /// <param name="factory">The factory.</param> /// <param name="configuration">The configuration.</param> public TodoistClient(IRequestFactory factory, IClientConfiguration configuration) : base(factory, configuration) { }
/// <summary> /// Initializes a new instance of the <see cref="OAuth2Client"/> class. /// </summary> /// <param name="factory">The factory.</param> /// <param name="configuration">The configuration.</param> protected OAuth2Client(IRequestFactory factory, IClientConfiguration configuration) { _factory = factory; Configuration = configuration; }
public void SetUp() { _factory = Substitute.For <IRequestFactory>(); _descendant = new FoursquareClientDescendant( _factory, Substitute.For <IClientConfiguration>()); }
/// <summary> /// Initializes a new instance of the <see cref="AsanaClient"/> class. /// </summary> /// <param name="factory">The factory.</param> /// <param name="configuration">The configuration.</param> public AsanaClient(IRequestFactory factory, IClientConfiguration configuration) : base(factory, configuration) { }
public FoursquareClientDescendant(IRequestFactory factory, IClientConfiguration configuration) : base(factory, configuration) { }