コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #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);
        }
コード例 #4
0
 /// <summary>
 /// Default encoding set to <see cref="Encoding.UTF8"/>
 /// </summary>
 public static MemoryStream GetMemoryStream(this IOExtensionPoint <string> s)
 {
     return(GetMemoryStream(s, Encoding.UTF8));
 }