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


C# FilteredStream.WriteByte方法代码示例

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


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

示例1: WriteTo

		/// <summary>
		/// Writes the message to the specified output stream.
		/// </summary>
		/// <remarks>
		/// Writes the message to the output stream using the provided formatting options.
		/// </remarks>
		/// <param name="options">The formatting options.</param>
		/// <param name="stream">The output stream.</param>
		/// <param name="cancellationToken">A cancellation token.</param>
		/// <exception cref="System.ArgumentNullException">
		/// <para><paramref name="options"/> is <c>null</c>.</para>
		/// <para>-or-</para>
		/// <para><paramref name="stream"/> is <c>null</c>.</para>
		/// </exception>
		/// <exception cref="System.OperationCanceledException">
		/// The operation was canceled via the cancellation token.
		/// </exception>
		/// <exception cref="System.IO.IOException">
		/// An I/O error occurred.
		/// </exception>
		public void WriteTo (FormatOptions options, Stream stream, CancellationToken cancellationToken = default (CancellationToken))
		{
			if (options == null)
				throw new ArgumentNullException ("options");

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

			if (version == null && Body != null && Body.Headers.Count > 0)
				MimeVersion = new Version (1, 0);

			if (Body == null) {
				Headers.WriteTo (options, stream, cancellationToken);

				cancellationToken.ThrowIfCancellationRequested ();
				stream.Write (options.NewLineBytes, 0, options.NewLineBytes.Length);
			} else {
				cancellationToken.ThrowIfCancellationRequested ();

				using (var filtered = new FilteredStream (stream)) {
					filtered.Add (options.CreateNewLineFilter ());

					foreach (var header in MergeHeaders ()) {
						if (options.HiddenHeaders.Contains (header.Id))
							continue;

						cancellationToken.ThrowIfCancellationRequested ();

						var name = Encoding.ASCII.GetBytes (header.Field);

						filtered.Write (name, 0, name.Length);
						filtered.WriteByte ((byte) ':');
						filtered.Write (header.RawValue, 0, header.RawValue.Length);
					}

					filtered.Flush ();
				}

				options.WriteHeaders = false;
				Body.WriteTo (options, stream, cancellationToken);
			}
		}
开发者ID:yijunwu,项目名称:scheduledmailsender,代码行数:62,代码来源:MimeMessage.cs

示例2: WriteTo

        /// <summary>
        /// Writes the message to the specified stream.
        /// </summary>
        /// <param name="options">The formatting options.</param>
        /// <param name="stream">The stream.</param>
        /// <exception cref="System.ArgumentNullException">
        /// <para><paramref name="options"/> is <c>null</c>.</para>
        /// <para>-or-</para>
        /// <para><paramref name="stream"/> is <c>null</c>.</para>
        /// </exception>
        public void WriteTo(FormatOptions options, Stream stream)
        {
            if (options == null)
                throw new ArgumentNullException ("options");

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

            if (!Headers.Contains ("Date"))
                Date = DateTimeOffset.Now;

            if (messageId == null)
                MessageId = MimeUtils.GenerateMessageId ();

            if (version == null && Body != null && Body.Headers.Count > 0)
                MimeVersion = new Version (1, 0);

            if (Body == null) {
                Headers.WriteTo (stream);

                stream.Write (options.NewLineBytes, 0, options.NewLineBytes.Length);
            } else {
                using (var filtered = new FilteredStream (stream)) {
                    filtered.Add (options.CreateNewLineFilter ());

                    foreach (var header in MergeHeaders ()) {
                        var name = Encoding.ASCII.GetBytes (header.Field);

                        filtered.Write (name, 0, name.Length);
                        filtered.WriteByte ((byte) ':');
                        filtered.Write (header.RawValue, 0, header.RawValue.Length);
                    }

                    filtered.Flush ();
                }

                options.WriteHeaders = false;
                Body.WriteTo (options, stream);
            }
        }
开发者ID:princeoffoods,项目名称:MimeKit,代码行数:50,代码来源:MimeMessage.cs


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