using System;
using System.IO;

namespace BMA.EHR.Recurit.Exam.Service.Extensions
{
    public static class StreamExtension
    {
        #region  " Methods "

        #region " Public "

        public static string ToBase64(this MemoryStream stream)
        {
            stream.Seek(0, SeekOrigin.Begin);
            byte[] bytes;
            using (var memoryStream = new MemoryStream())
            {
                stream.CopyTo(memoryStream);
                bytes = memoryStream.ToArray();
            }

            return Convert.ToBase64String(bytes);
        }

        #endregion

        #endregion
    }
}