public static XElement AsXml(this IHttpRequestBody body) { var bytes = body.AsRaw(); if (body.IsMaxSizeExceeded) { return(null); } using (var ms = new MemoryStream()) { ms.Write(bytes, 0, bytes.Length); ms.Seek(0L, SeekOrigin.Begin); return(XElement.Load(ms)); } }
public static T AsBinary <T>(this IHttpRequestBody body) { var bytes = body.AsRaw(); if (body.IsMaxSizeExceeded) { return(default(T)); } using (var ms = new MemoryStream()) { ms.Write(bytes, 0, bytes.Length); ms.Seek(0L, SeekOrigin.Begin); var formatter = new BinaryFormatter(); return((T)formatter.Deserialize(ms)); } }