public static MemoryStream GetMemoryStream(this IOExtensionPoint <string> s, Encoding encoding)
        {
            MemoryStream result = null;

            if (s.ExtendedValue.IsNotEmpty())
            {
                byte[] bytes = encoding.GetBytes(s.ExtendedValue);
                result = new MemoryStream(bytes);
            }
            return(result);
        }
        public static string GetString(this IOExtensionPoint <MemoryStream> m)
        {
            string result = null;

            if (m?.ExtendedValue != null && m.ExtendedValue.Length > 0)
            {
                m.ExtendedValue.Flush();
                m.ExtendedValue.Position = 0;
                var sr = new StreamReader(m.ExtendedValue);
                result = sr.ReadToEnd();
            }
            return(result);
        }
Exemple #3
0
        public static MemoryStream GetMemoryStream(this IOExtensionPoint <string> s)
        {
            MemoryStream result = null;

            if (s.ExtendedValue.IsNotEmpty())
            {
                result = new MemoryStream();
                var sw = new StreamWriter(result);
                sw.Write(s.ExtendedValue);
                sw.Flush();
            }
            return(result);
        }
 /// <summary>
 /// Default encoding set to <see cref="Encoding.UTF8"/>
 /// </summary>
 public static MemoryStream GetMemoryStream(this IOExtensionPoint <string> s)
 {
     return(GetMemoryStream(s, Encoding.UTF8));
 }