public static new ResponseBase BuildFrom(Requests.RequestBase request, params object[] obj) { Authentication auth = new Authentication(); if (obj.Length == 3) { if (obj[0].GetType() != typeof(bool)) { throw new ArgumentException("Argument obj[0] must be of type bool."); } if (obj[1].GetType() != typeof(Guid)) { throw new ArgumentException("Argument obj[1] must be of type Guid."); } if (obj[2].GetType() != typeof(DateTime)) { throw new ArgumentException("Argument obj[2] must be of type DateTime."); } auth.Success = (bool)obj[0]; auth.AuthToken = (Guid)obj[1]; auth.Expiry = (DateTime)obj[2]; } else if (obj.Length == 1) { if (obj[0].GetType() != typeof(bool)) { throw new ArgumentException("Argument obj[0] must be of type bool."); } auth.Success = (bool)obj[0]; } else { throw new ArgumentException("Argument obj is expected to have either 1 or 3 elements."); } return(auth); }
public static new ResponseBase BuildFrom(Requests.RequestBase request) { Responses.Pong pong = new Responses.Pong(); return(pong); }
public static new ResponseBase BuildFrom(Requests.RequestBase request, params object[] obj) { return(BuildFrom(request)); }
public static new ResponseBase BuildFrom(Requests.RequestBase request) { throw new InvalidOperationException("Use BuildFrom(Requests.RequestBase, object)"); }
public static ResponseBase BuildFrom(Requests.RequestBase request) { throw new NotImplementedException(); }
public static ResponseBase BuildFrom(Requests.RequestBase request, params object[] obj) { throw new NotImplementedException(); }
protected static Requests.RequestBase Parse(HttpRequest dotNetRequest) { Requests.RequestBase apiRequest; Http.Request request; byte[] buffer = new byte[8192]; int bytesRead = 0; int bytesToRead = 0; int byteValue = 0; int jsonLength = 0; int remainingJsonLength = 0; string temp = ""; // Instantiate our Http.Request request = new Http.Request(dotNetRequest); // read byte by byte until we hit null // We are building our json length while ((byteValue = request.Body.ReceiveStream.ReadByte()) > 0) { temp += byteValue.ToString(); } jsonLength = int.Parse(temp); remainingJsonLength = jsonLength; temp = ""; if (jsonLength > 8192) { bytesToRead = 8192; } else { bytesToRead = jsonLength; } // We now need to read through the body to the end of the Json while ((bytesRead = request.Body.ReceiveStream.Read(buffer, 0, bytesToRead)) > 0) { temp += System.Text.Encoding.UTF8.GetString(buffer, 0, bytesRead); remainingJsonLength -= bytesRead; if (remainingJsonLength <= 0) { break; } else if (remainingJsonLength > 8192) { bytesToRead = 8192; } else { bytesToRead = remainingJsonLength; } } // all that would remain in the stream would be data apiRequest = new Requests.RequestBase(JObject.Parse(temp)) { Stream = request.Body.ReceiveStream }; return(apiRequest); }
protected static Requests.RequestBase Parse(HttpRequest dotNetRequest) { Requests.RequestBase apiRequest; Http.Request request; byte[] buffer = new byte[8192]; int bytesRead = 0; int bytesToRead = 0; int byteValue = 0; int jsonLength = 0; int remainingJsonLength = 0; string temp = ""; // Instantiate our Http.Request request = new Http.Request(dotNetRequest); // read byte by byte until we hit null // We are building our json length while ((byteValue = request.Body.ReceiveStream.ReadByte()) > 0) { temp += byteValue.ToString(); } jsonLength = int.Parse(temp); remainingJsonLength = jsonLength; temp = ""; if (jsonLength > 8192) bytesToRead = 8192; else bytesToRead = jsonLength; // We now need to read through the body to the end of the Json while ((bytesRead = request.Body.ReceiveStream.Read(buffer, 0, bytesToRead)) > 0) { temp += System.Text.Encoding.UTF8.GetString(buffer, 0, bytesRead); remainingJsonLength -= bytesRead; if (remainingJsonLength <= 0) break; else if (remainingJsonLength > 8192) bytesToRead = 8192; else bytesToRead = remainingJsonLength; } // all that would remain in the stream would be data apiRequest = new Requests.RequestBase(JObject.Parse(temp)) { Stream = request.Body.ReceiveStream }; return apiRequest; }