Facebook.Extensions.ReadToString C# (CSharp) Method

ReadToString() static private method

static private ReadToString ( this source ) : string
source this
return string
        internal static string ReadToString(this Stream source)
        {
            if (!source.CanRead)
                throw new InvalidOperationException("Cannot read from source stream.");
            if (!source.CanSeek)
                throw new InvalidOperationException("Cannot seek from source stream.");

            long position = source.Position;
            using (StreamReader sr = new StreamReader(source))
            {
                string result = sr.ReadToEnd();
                source.Seek(position, SeekOrigin.Begin);
                return result;
            }
        }