public string ProcessorEncode(object data) { if (data == null) { return(""); } Type type = data.GetType(); PropertyInfo[] properties = type.GetProperties(); Dictionary <string, string> _params = new Dictionary <string, string>(); foreach (PropertyInfo property in properties) { object val = property.GetValue(data, null); if (val == null) { val = ""; } _params[property.Name] = val.ToString(); } return(ReactivixURI.SerializeFormData(_params)); }
public OAuthClient(ReactivixURI uri, string endpoint = ENDPOINT) { URI = uri.Copy(); URI.Path = endpoint; Client = new ReactivixHTTPClient(); Request = ReactivixHTTPPacket.ForPOST(null); Request.Processor = new ReactivixFormIOProcessor(); Response = new ReactivixHTTPPacket(new ReactivixJSONIOProcessor()); }
public QuarkClient(string uriHTTP, string uriStream, IReactivixNetworkTransport transport) { BaseHTTPURI = ReactivixURI.FromURI(uriHTTP); BaseStreamURI = ReactivixURI.FromURI(uriStream); ClientHTTP = new ReactivixHTTPClient(); ResponsePacket = new ReactivixHTTPPacket(new ReactivixJSONIOProcessor()); ClientStream = new QuarkNetworkClient(transport, BaseStreamURI.Host, BaseStreamURI.Port); OAuth = new OAuthClient(BaseHTTPURI.Copy()); }
public object ProcessorDecode(Type type, string data) { object output = Activator.CreateInstance(type); Dictionary <string, string> _params = ReactivixURI.ParseQueryString(data); foreach (KeyValuePair <string, string> item in _params) { PropertyInfo property = type.GetProperty(item.Key); property.SetValue(output, item.Value, null); } return(output); }
public void SendRequest <TResponse>(string uri, ReactivixHTTPPacket request, ReactivixHTTPPacket response, Action <ReactivixHTTPPacket> onResponse = null, Action <Exception> onError = null) { ReactivixURI URI = ReactivixURI.FromURI(uri); if (URI.Port == 0) { if (URI.Scheme == SCHEME_HTTP) { URI.Port = PORT_HTTP; } if (URI.Scheme == SCHEME_HTTPS) { URI.Port = PORT_HTTPS; } } if (request.Processor == null) { request.Processor = new ReactivixFormIOProcessor(); } if (response.Processor == null) { response.Processor = new ReactivixPlainIOProcessor(); } request.URI = URI; request.Headers.Add(new KeyValuePair <string, string>("Accept", response.Processor.MIME)); response.URI = URI; response.DataType = typeof(TResponse); _tasks.Add(new ReactivixHTTPClientTask { OnResponse = onResponse, OnError = onError, Request = request.Copy(), Response = response.Copy() }); }