本文整理汇总了C#中RequestType.GetAttr方法的典型用法代码示例。如果您正苦于以下问题:C# RequestType.GetAttr方法的具体用法?C# RequestType.GetAttr怎么用?C# RequestType.GetAttr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RequestType
的用法示例。
在下文中一共展示了RequestType.GetAttr方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: createRequest
public static WebRequest createRequest(RequestType type, Authentication authentication, int? id, Notification model)
{
HttpRequestAttr requestAttrs = (HttpRequestAttr) type.GetAttr();
WebRequest request;
string url = requestAttrs.URL;
if (id.HasValue)
{
url += ("/" + id);
}
url += "?username=" + authentication.Username + "&secretKey=" + authentication.SecretKey;
request = WebRequest.Create(url);
request.Method = requestAttrs.Method;
if (model != null)
{
request.ContentType = "application/json";
using (var streamWriter = new StreamWriter(request.GetRequestStream()))
{
string json = model.GenerateJsonString();
streamWriter.Write(json);
}
}
else
{
request.ContentLength = 0;
}
request.Timeout = CONNECTION_TIMEOUT;
return request;
}
示例2: createGetRequest
public static WebRequest createGetRequest(RequestType requestType, Authentication authentication, int? id, int? type, bool? unread, int? fromId)
{
HttpRequestAttr requestAttrs = (HttpRequestAttr)requestType.GetAttr();
WebRequest request;
string url = requestAttrs.URL;
if (id.HasValue)
{
url += ("/" + id);
}
url += "?username=" + authentication.Username + "&secretKey=" + authentication.SecretKey;
if (type.HasValue)
{
url += "&type=" + type.Value;
}
if (unread.HasValue)
{
url += "&unread=" + unread.Value;
}
if (fromId.HasValue)
{
url += "&fromId=" + fromId.Value;
}
request = WebRequest.Create(url);
request.Method = requestAttrs.Method;
request.Timeout = CONNECTION_TIMEOUT;
return request;
}