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; }
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); }
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 }; }
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); }
/// <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()); }
/// <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()); }