object ReadResponse(HttpClientMethod method, WebResponse response, Stream responseStream) { HttpWebResponse httpResponse = response as HttpWebResponse; if (httpResponse != null && (int)httpResponse.StatusCode >= 300) { throw new WebException(RequestResponseUtils.CreateResponseExceptionString(httpResponse, responseStream), null, WebExceptionStatus.ProtocolError, httpResponse); } if (method.readerType == null) { return(null); } // if (responseStream != null) { MimeReturnReader reader = (MimeReturnReader)MimeFormatter.CreateInstance(method.readerType, method.readerInitializer); return(reader.Read(response, responseStream)); } else { return(null); } }
object ReadResponse(HttpClientMethod method, WebResponse response, Stream responseStream) { HttpWebResponse httpResponse = response as HttpWebResponse; if (httpResponse != null && (int)httpResponse.StatusCode >= 300) { throw new WebException(RequestResponseUtils.CreateResponseExceptionString(httpResponse, responseStream), null, WebExceptionStatus.ProtocolError, httpResponse); } if (method.readerType == null) { return(null); } // CONSIDER,yannc: in future versions when we allow additional mime formatters we // : should consider giving them access to the response even if there is no // : response content. if (responseStream != null) { MimeReturnReader reader = (MimeReturnReader)MimeFormatter.CreateInstance(method.readerType, method.readerInitializer); return(reader.Read(response, responseStream)); } else { return(null); } }
internal override object[] ReadParameters() { if (this.serverMethod.readerTypes == null) { return(new object[0]); } for (int i = 0; i < this.serverMethod.readerTypes.Length; i++) { MimeParameterReader reader; if (!this.hasInputPayload) { if (!(this.serverMethod.readerTypes[i] != typeof(UrlParameterReader))) { goto Label_0061; } continue; } if (this.serverMethod.readerTypes[i] == typeof(UrlParameterReader)) { continue; } Label_0061: reader = (MimeParameterReader)MimeFormatter.CreateInstance(this.serverMethod.readerTypes[i], this.serverMethod.readerInitializers[i]); object[] objArray = reader.Read(base.Request); if (objArray != null) { return(objArray); } } if (!this.hasInputPayload) { throw new InvalidOperationException(Res.GetString("WebInvalidRequestFormat")); } throw new InvalidOperationException(Res.GetString("WebInvalidRequestFormatDetails", new object[] { base.Request.ContentType })); }
internal override void WriteReturns(object[] returnValues, Stream outputStream) { if (this.serverMethod.writerType != null) { ((MimeReturnWriter)MimeFormatter.CreateInstance(this.serverMethod.writerType, this.serverMethod.writerInitializer)).Write(base.Response, outputStream, returnValues[0]); } }
MimeParameterWriter GetParameterWriter(HttpClientMethod method) { if (method.writerType == null) { return(null); } return((MimeParameterWriter)MimeFormatter.CreateInstance(method.writerType, method.writerInitializer)); }
internal override void WriteReturns(object[] returnValues, Stream outputStream) { if (serverMethod.writerType == null) { return; } MimeReturnWriter writer = (MimeReturnWriter)MimeFormatter.CreateInstance(serverMethod.writerType, serverMethod.writerInitializer); writer.Write(Response, outputStream, returnValues[0]); }
private object ReadResponse(HttpClientMethod method, WebResponse response, Stream responseStream) { HttpWebResponse response2 = response as HttpWebResponse; if ((response2 != null) && (response2.StatusCode >= HttpStatusCode.MultipleChoices)) { throw new WebException(RequestResponseUtils.CreateResponseExceptionString(response2, responseStream), null, WebExceptionStatus.ProtocolError, response2); } if ((method.readerType != null) && (responseStream != null)) { MimeReturnReader reader = (MimeReturnReader)MimeFormatter.CreateInstance(method.readerType, method.readerInitializer); return(reader.Read(response, responseStream)); } return(null); }
internal override object[] ReadParameters() { if (serverMethod.readerTypes == null) { return(new object[0]); } for (int i = 0; i < serverMethod.readerTypes.Length; i++) { if (!hasInputPayload) { // only allow URL parameters if doesn't have payload if (serverMethod.readerTypes[i] != typeof(UrlParameterReader)) { continue; } } else { // don't allow URL params if has payload if (serverMethod.readerTypes[i] == typeof(UrlParameterReader)) { continue; } } MimeParameterReader reader = (MimeParameterReader)MimeFormatter.CreateInstance(serverMethod.readerTypes[i], serverMethod.readerInitializers[i]); object[] parameters = reader.Read(Request); if (parameters != null) { return(parameters); } } if (!hasInputPayload) { throw new InvalidOperationException(Res.GetString(Res.WebInvalidRequestFormat)); } else { throw new InvalidOperationException(Res.GetString(Res.WebInvalidRequestFormatDetails, Request.ContentType)); } }
public MimeFormatter Create() { return(MimeFormatter.CreateInstance(Type, Initializer)); }