本文整理汇总了C#中IDictionary.ToNameValueCollection方法的典型用法代码示例。如果您正苦于以下问题:C# IDictionary.ToNameValueCollection方法的具体用法?C# IDictionary.ToNameValueCollection怎么用?C# IDictionary.ToNameValueCollection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDictionary
的用法示例。
在下文中一共展示了IDictionary.ToNameValueCollection方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendDirectMessageAndGetResponse
public IDictionary<string, string> SendDirectMessageAndGetResponse(ServiceEndpoint providerEndpoint, IDictionary<string, string> fields) {
OpenIdProvider provider = new OpenIdProvider(providerStore, providerEndpoint.ProviderEndpoint,
providerEndpoint.ProviderEndpoint, fields.ToNameValueCollection());
Debug.Assert(provider.Request.IsResponseReady, "Direct messages should always have an immediately available response.");
Response webResponse = (Response)provider.Request.Response;
EncodableResponse opAuthResponse = (EncodableResponse)webResponse.EncodableMessage;
return opAuthResponse.EncodedFields;
}
示例2: CreateHttpRequestInfo
internal static HttpRequestInfo CreateHttpRequestInfo(string method, IDictionary<string, string> fields) {
var requestUri = new UriBuilder(DefaultUrlForHttpRequestInfo);
var headers = new NameValueCollection();
NameValueCollection form = null;
if (method == "POST") {
form = fields.ToNameValueCollection();
headers.Add(HttpRequestHeaders.ContentType, Channel.HttpFormUrlEncoded);
} else if (method == "GET") {
requestUri.Query = MessagingUtilities.CreateQueryString(fields);
} else {
throw new ArgumentOutOfRangeException("method", method, "Expected POST or GET");
}
return new HttpRequestInfo(method, requestUri.Uri, form: form, headers: headers);
}
示例3: Read
public override Result Read(string table, IDictionary<string, string> query)
{
var type = ResolveModelType(table);
var param = query.ToNameValueCollection();
var database = GetDatabase();
var collection = database.GetCollection(ResolveModelType(table), table);
var result = collection.FindAllAs(type);
var data = Filter(result, type, param);
return new Result
{
Success = true,
Data = data
};
}
示例4: CreateHttpRequestInfo
private static HttpRequestInfo CreateHttpRequestInfo(HttpDeliveryMethods scheme, IDictionary<string, string> fields) {
var requestUri = new UriBuilder(MessagingTestBase.DefaultUrlForHttpRequestInfo);
var headers = new NameValueCollection();
NameValueCollection form = null;
string method;
switch (scheme) {
case HttpDeliveryMethods.PostRequest:
method = "POST";
form = fields.ToNameValueCollection();
headers.Add(HttpRequestHeaders.ContentType, Channel.HttpFormUrlEncoded);
break;
case HttpDeliveryMethods.GetRequest:
method = "GET";
requestUri.Query = MessagingUtilities.CreateQueryString(fields);
break;
case HttpDeliveryMethods.AuthorizationHeaderRequest:
method = "GET";
headers.Add(HttpRequestHeaders.Authorization, CreateAuthorizationHeader(fields));
break;
default:
throw new ArgumentOutOfRangeException("scheme", scheme, "Unexpected value");
}
return new HttpRequestInfo(method, requestUri.Uri, form: form, headers: headers);
}
示例5: Post
/// <summary>
/// POSTs to an API URL and returns a dynamically typed object representing the
/// response from the service.
/// </summary>
/// <param name="pageMethod">Page, method, or file to append to end of API URL</param>
/// <param name="formData">String dictionary of Key/value pair query parameters (e.g. ?key=value)</param>
/// <returns></returns>
public dynamic Post(string pageMethod, IDictionary<string, string> formData) {
return PerformRequest(pageMethod, HttpMethod.POST, formData.ToNameValueCollection());
}
示例6: Get
/// <summary>
/// GETs from API URL and returns a dynamically typed object representing the
/// response from the service.
/// </summary>
/// <param name="pageMethod">Page, method, or file to append to end of API URL</param>
/// <param name="queryParams">String dictionary of Key/value pair query parameters (e.g. ?key=value)</param>
/// <returns></returns>
public dynamic Get(string pageMethod, IDictionary<string, string> queryParams) {
return PerformRequest(pageMethod, HttpMethod.GET, queryParams.ToNameValueCollection());
}