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


C# Stream.ReadToEnd方法代码示例

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


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

示例1: Process

        public static string Process(Stream stream, IPropertyProvider propertyProvider, bool throwIfNotFound = true)
        {
            string text = stream.ReadToEnd();
            var tokenizer = new Tokenizer(text);
            StringBuilder result = new StringBuilder();
            for (; ; )
            {
                Token token = tokenizer.Read();
                if (token == null)
                {
                    break;
                }

                if (token.Category == TokenCategory.Variable)
                {
                    var replaced = ReplaceToken(token.Value, propertyProvider, throwIfNotFound);
                    result.Append(replaced);
                }
                else
                {
                    result.Append(token.Value);
                }
            }

            return result.ToString();
        }
开发者ID:Newtopian,项目名称:nuget,代码行数:26,代码来源:Preprocessor.cs

示例2: Modify

        public Stream Modify(Stream openStream)
        {
            var content = openStream.ReadToEnd();
            content = minifier.Minify(content);

            return content.ToStream();
        }
开发者ID:justin-arvay,项目名称:WebAssetBundler,代码行数:7,代码来源:MinifyModifier.cs

示例3: CreateFrom

        internal static AzureContext CreateFrom(Stream configStream, ContextSettings settings)
        {
            if (configStream == null)
                throw new ArgumentNullException("configStream");

            if (settings == null)
                throw new ArgumentNullException("settings");

            _config = configStream.ReadToEnd().FromJsonToObject<HostConfig>();
            _current = new AzureContext(_config, settings);
            return _current;
        }
开发者ID:punitganshani,项目名称:KonfDB,代码行数:12,代码来源:AzureContext.cs

示例4: AssertAreEqual

 public static void AssertAreEqual(Stream expected, Stream found, int tolerance)
 {
     var expectedByteArray = expected.ReadToEnd();
     var foundByteArray = found.ReadToEnd();
     Assert.AreEqual(expectedByteArray.Length, foundByteArray.Length, "Lengths do not match");
     for (int i = 0; i < expectedByteArray.Length; i++)
     {
         if (Math.Abs(expectedByteArray[i] - foundByteArray[i]) > tolerance)
         {
             Assert.AreEqual(expectedByteArray[i], foundByteArray[i], "Data mismatch at location " + i);
         }
     }
 }
开发者ID:dirkrombauts,项目名称:SirenOfShame,代码行数:13,代码来源:StreamTestHelper.cs

示例5: Load

        public virtual void Load(Stream reader, bool headersOnly = false, int maxLength = 0, char? termChar = null)
        {
            _HeadersOnly = headersOnly;
            Headers = null;
            Body = null;

            if (headersOnly) {
                RawHeaders = reader.ReadToEnd(maxLength, _DefaultEncoding);
            } else {
                var headers = new StringBuilder();
                string line;
                while ((line = reader.ReadLine(ref maxLength, _DefaultEncoding, termChar)) != null) {
                    if (line.Trim().Length == 0)
                        if (headers.Length == 0)
                            continue;
                        else
                            break;
                    headers.AppendLine(line);
                }
                RawHeaders = headers.ToString();

                string boundary = Headers.GetBoundary();
                if (!string.IsNullOrEmpty(boundary)) {
                    //else this is a multipart Mime Message
                    //using (var subreader = new StringReader(line + Environment.NewLine + reader.ReadToEnd()))
                    var atts = new List<Attachment>();
                    ParseMime(reader, boundary, ref maxLength, atts, Encoding, termChar);
                    foreach (var att in atts)
                        (att.IsAttachment ? Attachments : AlternateViews).Add(att);

                    if (maxLength > 0)
                        reader.ReadToEnd(maxLength, Encoding);
                } else {
                    SetBody(reader.ReadToEnd(maxLength, Encoding).Trim());
                }
            }

            if (string.IsNullOrWhiteSpace(Body) && AlternateViews.Count > 0) {
                var att = AlternateViews.FirstOrDefault(x => x.ContentType.Is("text/plain"));
                if (att == null) {
                    att = AlternateViews.FirstOrDefault(x => x.ContentType.Contains("html"));
                }

                if (att != null) {
                    Body = att.Body;
                    ContentTransferEncoding = att.Headers["Content-Transfer-Encoding"].RawValue;
                    ContentType = att.Headers["Content-Type"].RawValue;
                }
            }

            Date = Headers.GetDate();
            To = Headers.GetAddresses("To").ToList();
            Cc = Headers.GetAddresses("Cc").ToList();
            Bcc = Headers.GetAddresses("Bcc").ToList();
            Sender = Headers.GetAddresses("Sender").FirstOrDefault();
            ReplyTo = Headers.GetAddresses("Reply-To").ToList();
            From = Headers.GetAddresses("From").FirstOrDefault();
            MessageID = Headers["Message-ID"].RawValue;

            Importance = Headers.GetEnum<MailPriority>("Importance");
            Subject = Headers["Subject"].RawValue;
        }
开发者ID:yodanielo,项目名称:aenetmail,代码行数:62,代码来源:MailMessage.cs

示例6: ParseMime

        private void ParseMime(Stream reader, string boundary, int maxLength)
        {
            var maxLengthSpecified = maxLength > 0;
              string data,
            bounderInner = "--" + boundary,
            bounderOuter = bounderInner + "--";

              do {
            data = reader.ReadLine(ref maxLength, Encoding);
              } while (data != null && !data.StartsWith(bounderInner));

              while (data != null && !data.StartsWith(bounderOuter) && (maxLength > 0 || !maxLengthSpecified)) {
            data = reader.ReadLine(ref maxLength, Encoding);
            var a = new Attachment { Encoding = Encoding };

            var part = new StringBuilder();
            // read part header
            while (!data.StartsWith(bounderInner) && data != string.Empty) {
              part.AppendLine(data);
              data = reader.ReadLine(ref maxLength, Encoding);
            }
            a.RawHeaders = part.ToString();
            // header body

            data = reader.ReadLine(ref maxLength, Encoding);
            var body = new StringBuilder();
            while (data != string.Empty && !data.StartsWith(bounderInner)) {
              body.AppendLine(data);
              data = reader.ReadLine(ref maxLength, Encoding);
            }
            // check for nested part
            string nestedboundary = a.Headers.GetBoundary();
            if (!string.IsNullOrEmpty(nestedboundary)) {
              ParseMime(body.ToString(), nestedboundary);

            } else { // nested
              a.SetBody(body.ToString());
              (a.IsAttachment ? Attachments : AlternateViews).Add(a);
            }
              }

              if (maxLength > 0)
            data = reader.ReadToEnd(maxLength, Encoding);
        }
开发者ID:hugoham,项目名称:aenetmail,代码行数:44,代码来源:MailMessage.cs

示例7: Load

		public virtual void Load(Stream reader, bool headersOnly = false, int maxLength = 0, char? termChar = null)
		{
			_HeadersOnly = headersOnly;
			Headers = null;
			Body = null;
			if (maxLength == 0)
				return;


			var headers = new StringBuilder();
			string line;
			while ((line = reader.ReadLine(ref maxLength, _DefaultEncoding, termChar)) != null) {
				if (line.Length == 0)
					if (headers.Length == 0)
						continue;
					else
						break;
				headers.AppendLine(line);
			}
			RawHeaders = headers.ToString();

			if (!headersOnly) {
				string boundary = Headers.GetBoundary();
				if (!string.IsNullOrEmpty(boundary)) {
					var atts = new List<Attachment>();
					var body = ParseMime(reader, boundary, ref maxLength, atts, Encoding, termChar);
					if (!string.IsNullOrEmpty(body))
						SetBody(body);

					foreach (var att in atts)
						(att.IsAttachment ? Attachments : AlternateViews).Add(att);

					if (maxLength > 0)
						reader.ReadToEnd(maxLength, Encoding);
				} else {
					//	sometimes when email doesn't have a body, we get here with maxLength == 0 and we shouldn't read any further
					string body = String.Empty;
					if (maxLength > 0)
						body = reader.ReadToEnd(maxLength, Encoding);

					SetBody(body);
				}
			}
			else if (maxLength > 0)
				reader.ReadToEnd(maxLength, Encoding);

			if ((string.IsNullOrWhiteSpace(Body) || ContentType.StartsWith("multipart/")) && AlternateViews.Count > 0) {
				var att = AlternateViews.GetTextView() ?? AlternateViews.GetHtmlView();
				if (att != null) {
					Body = att.Body;
					ContentTransferEncoding = att.Headers["Content-Transfer-Encoding"].RawValue;
					ContentType = att.Headers["Content-Type"].RawValue;
				}
			}

			Date = Headers.GetDate();
			To = Headers.GetMailAddresses("To").ToList();
			Cc = Headers.GetMailAddresses("Cc").ToList();
			Bcc = Headers.GetMailAddresses("Bcc").ToList();
			Sender = Headers.GetMailAddresses("Sender").FirstOrDefault();
			ReplyTo = Headers.GetMailAddresses("Reply-To").ToList();
			From = Headers.GetMailAddresses("From").FirstOrDefault();
			MessageID = Headers["Message-ID"].RawValue;

			Importance = Headers.GetEnum<MailPriority>("Importance");
			Subject = Headers["Subject"].RawValue;
		}
开发者ID:Wenqihai,项目名称:aenetmail,代码行数:67,代码来源:MailMessage.cs

示例8: LocalAfterRequestCompleted

 private void LocalAfterRequestCompleted(Stream stream)
 {
     LogInstance.LogInfo("Call complete to {0} in {1:#.000} seconds", this.Url, CallTimer.Stop());
     this.ResponseText = stream.ReadToEnd().TrimEnd();
     AfterRequestCompleted(this.ResponseText);
 }
开发者ID:thnk2wn,项目名称:codestock-winphone,代码行数:6,代码来源:WebServiceBase.cs

示例9: Process

 internal static string Process(Stream stream, IPropertyProvider propertyProvider, bool throwIfNotFound = true)
 {
     string text = stream.ReadToEnd();
     return _tokenRegex.Replace(text, match => ReplaceToken(match, propertyProvider, throwIfNotFound));
 }
开发者ID:shrknt35,项目名称:sonarlint-vs,代码行数:5,代码来源:Preprocessor.cs

示例10: GetDeserializedObject

        static object GetDeserializedObject(Stream inputStream)
        {
            string body = inputStream.ReadToEnd().ToUtf8String();
            if (body.IsEmpty())
                return null;

            return new JavaScriptSerializer().DeserializeObject(body);
        }
开发者ID:hakeemsm,项目名称:Magnum,代码行数:8,代码来源:JsonValueProvider.cs

示例11: Load

        public virtual void Load(Stream reader,  Scope scope, int maxLength, char? termChar = null)
        {
            Scope = scope;
            Headers = null;
            Body = null;

            var headers = new StringBuilder();
            string line;
            while ((line = reader.ReadLine(ref maxLength, _DefaultEncoding, termChar)) != null)
            {
                if (line.Trim().Length == 0)
                    if (headers.Length == 0)
                        continue;
                    else
                        break;
                headers.AppendLine(line);
            }
            RawHeaders = headers.ToString();

            if (Scope > Scope.Headers)
            {
                string boundary = Headers.GetBoundary();
                if (!string.IsNullOrEmpty(boundary))
                {
                    var atts = new List<Attachment>();
                    // Read the mime structure anyways, but the body might be empty.
                    var body = ParseMime(reader, boundary, ref maxLength, atts, Encoding, termChar, scope);
                    if (Scope > Scope.HeadersAndMime && !string.IsNullOrEmpty(body))
                    {
                        SetBody(body);
                    }

                    foreach (var att in atts)
                    {
                        Add(att);
                    }

                    if (maxLength > 0)
                        reader.ReadToEnd(maxLength, Encoding);
                }
                else if (Scope > Scope.HeadersAndMime)
                {
                    //	sometimes when email doesn't have a body, we get here with maxLength == 0 and we shouldn't read any further
                    string body = String.Empty;
                    if (maxLength > 0)
                        body = reader.ReadToEnd(maxLength, Encoding);

                    SetBody(body);
                }
            }

            Date = Headers.GetDate();
            To = Headers.GetMailAddresses("To").ToList();
            Cc = Headers.GetMailAddresses("Cc").ToList();
            Bcc = Headers.GetMailAddresses("Bcc").ToList();
            Sender = Headers.GetMailAddresses("Sender").FirstOrDefault();
            ReplyTo = Headers.GetMailAddresses("Reply-To").ToList();
            From = Headers.GetMailAddresses("From").FirstOrDefault();
            MessageID = Headers["Message-ID"].RawValue;

            Importance = Headers.GetEnum<MailPriority>("Importance");
            Subject = Headers["Subject"].RawValue;
        }
开发者ID:achingono,项目名称:WinPhoneGmail,代码行数:63,代码来源:MailMessage.cs

示例12: Process

 internal static string Process(Stream stream, IPropertyProvider propertyProvider)
 {
     string text = stream.ReadToEnd();
     return _tokenRegex.Replace(text, match => ReplaceToken(match, propertyProvider));
 }
开发者ID:jacksonh,项目名称:nuget,代码行数:5,代码来源:Preprocessor.cs


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