当前位置: 首页>>代码示例>>C#>>正文


C# MemoryStream.ReadAllText方法代码示例

本文整理汇总了C#中System.IO.MemoryStream.ReadAllText方法的典型用法代码示例。如果您正苦于以下问题:C# MemoryStream.ReadAllText方法的具体用法?C# MemoryStream.ReadAllText怎么用?C# MemoryStream.ReadAllText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.MemoryStream的用法示例。


在下文中一共展示了MemoryStream.ReadAllText方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Write

        public void Write(Action<Stream> output)
        {
            var stream = new MemoryStream();
            output(stream);

            stream.Position = 0;
            _writer.WriteLine(stream.ReadAllText());
        }
开发者ID:jemacom,项目名称:fubumvc,代码行数:8,代码来源:IHttpWriter.cs

示例2: TestReadAllText

        public void TestReadAllText()
        {
            var inputText = "Testing1234";
            var bytes = Encoding.UTF8.GetBytes(inputText);

            var stream = new MemoryStream(bytes);
            var outputText = stream.ReadAllText(Encoding.UTF8);

            Assert.AreEqual(inputText, outputText);
        }
开发者ID:tommyinb,项目名称:TommiUtility,代码行数:10,代码来源:StreamUtil.cs

示例3: can_read_all_text_synchronously

        public void can_read_all_text_synchronously()
        {
            var helloWorld = "Hello world.";

            var stream = new MemoryStream();
            var writer = new StreamWriter(stream, Encoding.Unicode);
            writer.WriteLine(helloWorld);
            writer.Flush();

            stream.Position = 0;
            stream.ReadAllText().Trim()
                .ShouldBe(helloWorld);
        }
开发者ID:JasperFx,项目名称:baseline,代码行数:13,代码来源:StreamExtensionsTests.cs

示例4: injectContent

        private void injectContent(IDictionary<string, object> environment, MemoryStream recordedStream, OwinHttpResponse response)
        {
            var html = recordedStream.ReadAllText();
            var builder = new StringBuilder(html);
            var position = html.IndexOf("</head>", 0, StringComparison.OrdinalIgnoreCase);

            if (position >= 0)
            {
                builder.Insert(position, _options.Content(environment));
            }

            response.Write(builder.ToString());
            response.Flush();
        }
开发者ID:kingreatwill,项目名称:fubumvc,代码行数:14,代码来源:HtmlHeadInjectionMiddleware.cs

示例5: ReadAllText_should_return_the_correct_string

        public void ReadAllText_should_return_the_correct_string()
        {
            const string expectedValue = "hello";

            var stream = new MemoryStream();
            var writer = new StreamWriter(stream)
            {
                AutoFlush = true
            };

            writer.Write(expectedValue);
            stream.Position = 0;

            stream.ReadAllText().Should().Be(expectedValue);
        }
开发者ID:jasonreimer,项目名称:Praetorium,代码行数:15,代码来源:IOExtensionsSpecs.cs

示例6: ToText

        /// <summary>
        /// Convert document to text
        /// </summary>
        public static string ToText(this XmlNode xmlNode, Encoding encoding)
        {
            if (xmlNode == null)
            {
                throw new ArgumentNullException("xmlNode");
            }

            using (var ms = new MemoryStream())
            {
                using (var writer = CreateXmlWriter(xmlNode, ms, encoding))
                {
                    xmlNode.WriteTo(writer);
                    writer.Flush();

                    return ms.ReadAllText(encoding);
                }
            }
        }
开发者ID:netvietdev,项目名称:RabbitFoundation,代码行数:21,代码来源:XmlExtensions.cs

示例7: Write

        public async Task Write(Func<Stream, Task> output)
        {
            var stream = new MemoryStream();
            await output(stream).ConfigureAwait(false);

            stream.Position = 0;
            _writer.WriteLine(stream.ReadAllText());

        }
开发者ID:DarthFubuMVC,项目名称:fubumvc,代码行数:9,代码来源:IHttpResponse.cs

示例8: GetContent

 /// <summary>
 /// Gets the content with the specified data format.
 /// </summary>
 /// <param name="dataFormat">The data format.</param>
 /// <returns>The content with the specified data format.</returns>
 private string GetContent(string dataFormat)
 {
     TextRange textRange = new TextRange(this.Document.ContentStart, this.Document.ContentEnd);
     using (MemoryStream memoryStream = new MemoryStream())
     {
         textRange.Save(memoryStream, dataFormat);
         memoryStream.Position = 0;
         return memoryStream.ReadAllText();
     }
 }
开发者ID:ruisebastiao,项目名称:Elysium-Extra,代码行数:15,代码来源:RichTextBoxExtended.cs


注:本文中的System.IO.MemoryStream.ReadAllText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。