本文整理汇总了C#中IRestRequest.AddParameter方法的典型用法代码示例。如果您正苦于以下问题:C# IRestRequest.AddParameter方法的具体用法?C# IRestRequest.AddParameter怎么用?C# IRestRequest.AddParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRestRequest
的用法示例。
在下文中一共展示了IRestRequest.AddParameter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HttpRequest
private CustomResponse HttpRequest(IRestRequest request, string url, Dictionary<string, string> parameters = null)
{
try
{
IRestClient client = new RestClient();
IRestResponse response = new RestResponse();
client.BaseUrl = new Uri(url);
if (parameters != null)
{
foreach (var item in parameters)
{
request.AddParameter(item.Key, item.Value);
}
}
response = client.Execute(request);
var myResponse = new CustomResponse();
myResponse.StatusCode = response.StatusCode;
myResponse.Content = response.Content;
return myResponse;
}
catch(Exception ex)
{
throw ex;
}
}
示例2: AddFilter
public override void AddFilter(IRestRequest request)
{
base.AddFilter(request);
if (MinimumId != null)
{
request.AddParameter("min_id", MinimumId, ParameterType.GetOrPost);
}
if (MaximumId != null)
{
request.AddParameter("max_id", MaximumId, ParameterType.GetOrPost);
}
if (Name != null)
{
request.AddParameter("name", Name, ParameterType.GetOrPost);
}
if (ParentId != null)
{
request.AddParameter("parent_id", ParentId, ParameterType.GetOrPost);
}
if (IsVisible != null)
{
request.AddParameter("is_visible", IsVisible, ParameterType.GetOrPost);
}
}
示例3: AddFilter
public override void AddFilter(IRestRequest request) {
base.AddFilter(request);
if (StateName != null) {
request.AddParameter("state", StateName, ParameterType.GetOrPost);
}
if (StateAbbreviation != null) {
request.AddParameter("state_abbreviation", StateAbbreviation, ParameterType.GetOrPost);
}
}
示例4: AddFilter
public override void AddFilter(IRestRequest request) {
base.AddFilter(request);
if (CountryName != null) {
request.AddParameter("country", CountryName, ParameterType.GetOrPost);
}
if (CountryIso2 != null) {
request.AddParameter("country_iso2", CountryIso2, ParameterType.GetOrPost);
}
if (CountryIso3 != null) {
request.AddParameter("country_iso3", CountryIso3, ParameterType.GetOrPost);
}
}
示例5: Populate
public void Populate(IRestRequest request)
{
if (!string.IsNullOrEmpty(_bankAccount.Description))
request.AddParameter("description", _bankAccount.Description);
request.AddParameter("routing_number", _bankAccount.RoutingNumber);
request.AddParameter("account_number", _bankAccount.AccountNumber);
request.AddParameter("account_type", _bankAccount.AccountType == AccountType.Company ? "company" : "individual");
request.AddParameter("signatory", _bankAccount.Signatory);
if(_bankAccount.MetaData != null)
new MetaDataPopulator(_bankAccount.MetaData).Populate(request);
}
示例6: AddFilter
public virtual void AddFilter(IRestRequest request)
{
if (this.IfModifiedSince != null)
request.AddHeader("If-Modified-Since", String.Format(RFC2822_DATE_FORMAT, this.IfModifiedSince));
if (this.Limit != null)
{
request.AddParameter("limit", Limit, ParameterType.GetOrPost);
}
if (this.Page != null)
{
request.AddParameter("page", Page, ParameterType.GetOrPost);
}
}
示例7: AddFilter
public override void AddFilter(IRestRequest request)
{
base.AddFilter(request);
if (this.Name != null)
{
request.AddParameter("name", this.Name, ParameterType.GetOrPost);
}
if (this.IsDefault != null)
{
request.AddParameter("is_default", this.IsDefault, ParameterType.GetOrPost);
}
}
示例8: AddFilter
public override void AddFilter(IRestRequest request) {
base.AddFilter(request);
if (this.Name != null) {
request.AddParameter("name", this.Name, ParameterType.GetOrPost);
}
if (this.DisplayName != null) {
request.AddParameter("display_name", this.DisplayName, ParameterType.GetOrPost);
}
if (this.OptionType != null) {
request.AddParameter("type", this.OptionType, ParameterType.GetOrPost);
}
}
示例9: Populate
public void Populate(IRestRequest request)
{
var addressPopulator = new AddressPopulator(_address);
addressPopulator.Populate(request);
if (_addressInfo.Description != null) request.AddParameter("description", _addressInfo.Description);
if (_addressInfo.MetaData != null)
{
var populator = new MetaDataPopulator(_addressInfo.MetaData);
populator.Populate(request);
}
if (_addressInfo.Name != null) request.AddParameter("name", _addressInfo.Name);
if (_addressInfo.Phone != null) request.AddParameter("phone", _addressInfo.Phone);
if (_addressInfo.Email != null) request.AddParameter("email", _addressInfo.Email);
if (_addressInfo.Company != null) request.AddParameter("company", _addressInfo.Company);
}
示例10: Authenticate
public void Authenticate(IRestClient client, IRestRequest request)
{
if(!request.Parameters.Any(p => p.Name.Equals("Authorization", StringComparison.OrdinalIgnoreCase)))
{
request.AddParameter("Authorization", "SuTToken " + _token, ParameterType.HttpHeader);
}
}
示例11: Authenticate
public void Authenticate(IRestClient client, IRestRequest request)
{
if (request.Parameters.Exists(p => p.Name.Equals("Cookie", StringComparison.InvariantCultureIgnoreCase)))
return;
request.AddParameter("cookie", _authHeader, ParameterType.HttpHeader);
}
示例12: PopulateRoutes
private void PopulateRoutes(IRestRequest request)
{
foreach (var route in _definition.Routes)
{
request.AddParameter("routes", route.ToString());
}
}
示例13: Authenticate
/// <summary>
/// Modifies the request to ensure that the authentication requirements are met.
/// </summary>
/// <param name="client">Client executing this request</param>
/// <param name="request">Request to authenticate</param>
public void Authenticate(IRestClient client, IRestRequest request)
{
// only add the Authorization parameter if it hasn't been added by a previous Execute
if (request.Parameters.Any(p => p.Name != null && p.Name.Equals("Authorization", StringComparison.OrdinalIgnoreCase)))
return;
request.AddParameter("Authorization", this._authHeader, ParameterType.HttpHeader);
}
示例14: Authenticate
/// <summary>
/// Modifies the request to ensure that the authentication requirements are met.
/// </summary>
/// <param name="client">Client executing this request</param>
/// <param name="request">Request to authenticate</param>
public void Authenticate(IRestClient client, IRestRequest request)
{
if (HasDigestHeader)
{
var digestHeader = GetDigestHeader(client, request);
request.AddParameter("Authorization", digestHeader, ParameterType.HttpHeader);
}
}
示例15: Authenticate
public override void Authenticate(IRestClient client, IRestRequest request)
{
// only add the Authorization parameter if it hasn't been added.
if (!request.Parameters.Any(p => p.Name.Equals("Authorization", StringComparison.OrdinalIgnoreCase)))
{
request.AddParameter("Authorization", _authorizationValue, ParameterType.HttpHeader);
}
}