本文整理汇总了C#中MimeKit.IO.FilteredStream.Write方法的典型用法代码示例。如果您正苦于以下问题:C# FilteredStream.Write方法的具体用法?C# FilteredStream.Write怎么用?C# FilteredStream.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MimeKit.IO.FilteredStream
的用法示例。
在下文中一共展示了FilteredStream.Write方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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) {
using (var filtered = new FilteredStream (stream)) {
filtered.Add (options.CreateNewLineFilter ());
foreach (var header in MergeHeaders ()) {
if (options.HiddenHeaders.Contains (header.Id))
continue;
filtered.Write (header.RawField, 0, header.RawField.Length, cancellationToken);
filtered.Write (new [] { (byte) ':' }, 0, 1, cancellationToken);
filtered.Write (header.RawValue, 0, header.RawValue.Length, cancellationToken);
}
filtered.Flush (cancellationToken);
}
var cancellable = stream as ICancellableStream;
if (cancellable != null) {
cancellable.Write (options.NewLineBytes, 0, options.NewLineBytes.Length, cancellationToken);
} else {
cancellationToken.ThrowIfCancellationRequested ();
stream.Write (options.NewLineBytes, 0, options.NewLineBytes.Length);
}
try {
Body.Headers.Suppress = true;
Body.WriteTo (options, stream, cancellationToken);
} finally {
Body.Headers.Suppress = false;
}
} else {
Headers.WriteTo (options, stream, cancellationToken);
}
}
示例2: 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);
}
}
示例3: GetResponseStream
Stream GetResponseStream (ImapReplayCommand command)
{
MemoryStream memory;
if (testUnixFormat) {
memory = new MemoryStream ();
using (var filtered = new FilteredStream (memory)) {
filtered.Add (new Dos2UnixFilter ());
filtered.Write (command.Response, 0, command.Response.Length);
filtered.Flush ();
}
memory.Position = 0;
} else {
memory = new MemoryStream (command.Response, false);
}
return memory;
}
示例4: 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);
}
}