本文整理汇总了C#中MimeKit.ParserOptions.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# ParserOptions.Clone方法的具体用法?C# ParserOptions.Clone怎么用?C# ParserOptions.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MimeKit.ParserOptions
的用法示例。
在下文中一共展示了ParserOptions.Clone方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryParse
/// <summary>
/// Tries to parse the given text into a new <see cref="MimeKit.Header"/> instance.
/// </summary>
/// <remarks>
/// Parses a header from the specified text.
/// </remarks>
/// <returns><c>true</c>, if the header was successfully parsed, <c>false</c> otherwise.</returns>
/// <param name="options">The parser options to use.</param>
/// <param name="text">The text to parse.</param>
/// <param name="header">The parsed header.</param>
/// <exception cref="System.ArgumentNullException">
/// <para><paramref name="options"/> is <c>null</c>.</para>
/// <para>-or-</para>
/// <para><paramref name="text"/> is <c>null</c>.</para>
/// </exception>
public static bool TryParse (ParserOptions options, string text, out Header header)
{
if (options == null)
throw new ArgumentNullException ("options");
if (text == null)
throw new ArgumentNullException ("text");
var buffer = Encoding.UTF8.GetBytes (text);
unsafe {
fixed (byte *inptr = buffer) {
return TryParse (options.Clone (), inptr, buffer.Length, true, out header);
}
}
}
示例2: TryParse
/// <summary>
/// Tries to parse the given input buffer into a new <see cref="MimeKit.Header"/> instance.
/// </summary>
/// <remarks>
/// Parses a header from the specified buffer.
/// </remarks>
/// <returns><c>true</c>, if the header was successfully parsed, <c>false</c> otherwise.</returns>
/// <param name="options">The parser options to use.</param>
/// <param name="buffer">The input buffer.</param>
/// <param name="header">The parsed header.</param>
/// <exception cref="System.ArgumentNullException">
/// <para><paramref name="options"/> is <c>null</c>.</para>
/// <para>-or-</para>
/// <para><paramref name="buffer"/> is <c>null</c>.</para>
/// </exception>
public static bool TryParse (ParserOptions options, byte[] buffer, out Header header)
{
ParseUtils.ValidateArguments (options, buffer);
unsafe {
fixed (byte* inptr = buffer) {
return TryParse (options.Clone (), inptr, buffer.Length, true, out header);
}
}
}
示例3: SetStream
/// <summary>
/// Sets the stream to parse.
/// </summary>
/// <param name="options">The parser options.</param>
/// <param name="stream">The stream to parse.</param>
/// <param name="format">The format of the stream.</param>
/// <param name="persistent"><c>true</c> if the stream is persistent; otherwise <c>false</c>.</param>
/// <remarks>
/// <para>If <paramref name="persistent"/> is <c>true</c> and <paramref name="stream"/> is seekable, then
/// the <see cref="MimeParser"/> will not copy the content of <see cref="MimePart"/>s into memory. Instead,
/// it will use a <see cref="MimeKit.IO.BoundStream"/> to reference a substream of <paramref name="stream"/>.
/// This has the potential to not only save mmeory usage, but also improve <see cref="MimeParser"/>
/// performance.</para>
/// <para>It should be noted, however, that disposing <paramref name="stream"/> will make it impossible
/// for <see cref="ContentObject"/> to read the content.</para>
/// </remarks>
/// <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 SetStream(ParserOptions options, Stream stream, MimeFormat format, bool persistent)
{
if (options == null)
throw new ArgumentNullException ("options");
if (stream == null)
throw new ArgumentNullException ("stream");
this.persistent = persistent && stream.CanSeek;
this.options = options.Clone ();
this.format = format;
this.stream = stream;
inputIndex = inputStart;
inputEnd = inputStart;
mboxMarkerOffset = 0;
mboxMarkerLength = 0;
offset = stream.CanSeek ? stream.Position : 0;
headers.Clear ();
headerOffset = 0;
headerIndex = 0;
bounds.Clear ();
if (format == MimeFormat.Mbox) {
bounds.Add (Boundary.CreateMboxBoundary ());
mboxMarkerBuffer = new byte[ReadAheadSize];
state = MimeParserState.MboxMarker;
} else {
state = MimeParserState.Initialized;
}
}