本文整理汇总了C#中IRequestFactory类的典型用法代码示例。如果您正苦于以下问题:C# IRequestFactory类的具体用法?C# IRequestFactory怎么用?C# IRequestFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IRequestFactory类属于命名空间,在下文中一共展示了IRequestFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
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;
}
示例2: SetUp
public void SetUp()
{
factory = Substitute.For<IRequestFactory>();
factory.CreateClient().Execute(factory.CreateRequest()).StatusCode = HttpStatusCode.OK;
descendant = new OAuthClientDescendant(
factory, Substitute.For<IClientConfiguration>());
}
示例3: Client
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);
}
示例4: DeviceLocator
public DeviceLocator(ISocketFactory socketFactory, IRequestFactory requestFactory, IMessageParser messageParser, IDeviceInfoCollector deviceInfoCollector)
{
_socketFactory = socketFactory;
_requestFactory = requestFactory;
_messageParser = messageParser;
_deviceInfoCollector = deviceInfoCollector;
}
示例5: SetUp
public void SetUp()
{
requestFactory = Substitute.For<IRequestFactory>();
requestFactory.CreateClient().Execute(requestFactory.CreateRequest()).StatusCode = HttpStatusCode.OK;
descendant = new DigitalOceanClientDescendant(
requestFactory, Substitute.For<IClientConfiguration>());
}
示例6: RpcClient
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;
}
示例7: RequestThrottle
public RequestThrottle(IRequestFactory requestFactory, TimeSpan throttleWindowTime, int throttleWindowCount, int maxPendingRequests)
{
RequestFactory = requestFactory;
ThrottleWindowTime = throttleWindowTime;
ThrottleWindowCount = throttleWindowCount;
MaxPendingRequests = maxPendingRequests;
}
示例8: Channel
public Channel(string name, IRequestFactory requestFactory, IJsonSerializer jsonSerializer, IRestClient restClient)
: base(requestFactory, jsonSerializer, restClient)
{
if (string.IsNullOrEmpty(name))
{
throw new ArgumentNullException("name");
}
_name = name;
}
示例9: AuthorizationRoot
/// <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);
}
示例10: User
public User(string username, IRequestFactory requestFactory, IJsonSerializer jsonSerializer, IRestClient restClient)
: base(requestFactory, jsonSerializer, restClient)
{
if (string.IsNullOrEmpty(username))
{
throw new ArgumentNullException("username");
}
_username = username;
}
示例11: Connection
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;
}
示例12: FollowLinkAsync
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);
}
示例13: SetUp
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>());
}
示例14: Follow
//[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);
}
}
示例15: EntityBase
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;
}