Esempio n. 1
0
        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));
            }
        }
Esempio n. 2
0
        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));
            }
        }