public Stream GetStream(IPortalResponse response) { var portalResponse = ((Dto.v2.PortalResponse) response.Output); var json = JsonConvert.SerializeObject(portalResponse); return new MemoryStream(response.Encoding.GetBytes(json)); }
public Stream GetStream(IPortalResponse response) { var xdoc = SerializerFactory.XMLSerializer.Serialize(response.Output, false); xdoc.Declaration = new XDeclaration("1.0", response.Encoding.HeaderName, "yes"); var stream = new MemoryStream(); xdoc.Save(stream, SaveOptions.DisableFormatting); stream.Position = 0; return stream; }
public Stream GetStream(IPortalResponse response) { var attachment = (Attachment) response.Output; if (attachment == null) { if(response.Output == null) throw new Exception("Response.Output must not be null"); throw new Exception("Response.Output is not an Attachment but a " + response.Output.GetType().FullName); } if (attachment.Stream.CanSeek) attachment.Stream.Position = 0; return attachment.Stream; }
public IExtension WithPortalResponse(IPortalResponse response) { Response = response; return this; }
public Stream GetStream(IPortalResponse response) { var callback = response.Callback ?? "portal_callback"; return new MemoryStream(response.Encoding.GetBytes(SerializerFactory.Get<JSON>().Serialize(response, false).GetAsJSONP(callback))); }
/// <summary> /// Get the http response content type based on the return format requested /// </summary> /// <param name="format">The return format for which the mime type is returned</param> /// <returns>The mime type associated with the ReturnFormat</returns> private static string GetContentType(IPortalResponse response) { if (response.ContainsHeader("Content-Type")) return response.GetHeader("Content-Type"); switch (response.ReturnFormat) { case ReturnFormat.XML: case ReturnFormat.XML2: return "text/xml"; case ReturnFormat.JSON: case ReturnFormat.JSON2: case ReturnFormat.JSON3: return "application/json"; case ReturnFormat.JSONP: case ReturnFormat.JSONP2: return "application/javascript"; default: throw new NotImplementedException("Unknown return format"); } }
public Stream GetStream(IPortalResponse response) { var json = SerializerFactory.Get<JSON>().Serialize(response.Output, false).Value; return new MemoryStream(response.Encoding.GetBytes(json)); }