MimeKit.ParserOptions.Clone C# (CSharp) Méthode

Clone() public méthode

Clones an instance of MimeKit.ParserOptions.
Clones a set of options, allowing you to change a specific option without requiring you to change the original.
public Clone ( ) : ParserOptions
Résultat ParserOptions
		public ParserOptions Clone ()
		{
			var options = new ParserOptions ();
			options.AddressParserComplianceMode = AddressParserComplianceMode;
			options.ParameterComplianceMode = ParameterComplianceMode;
			options.Rfc2047ComplianceMode = Rfc2047ComplianceMode;
			options.RespectContentLength = RespectContentLength;
			options.CharsetEncoding = CharsetEncoding;

			foreach (var mimeType in mimeTypes)
				options.mimeTypes.Add (mimeType.Key, mimeType.Value);

			return options;
		}

Usage Example

Exemple #1
0
        /// <summary>
        /// Tries to parse the given input buffer into a new <see cref="MimeKit.Header"/> instance.
        /// </summary>
        /// <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="startIndex">The starting index of the input buffer.</param>
        /// <param name="length">The number of bytes in the input buffer 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="buffer"/> is <c>null</c>.</para>
        /// </exception>
        /// <exception cref="System.ArgumentOutOfRangeException">
        /// <paramref name="startIndex"/> and <paramref name="length"/> do not specify
        /// a valid range in the byte array.
        /// </exception>
        public static bool TryParse(ParserOptions options, byte[] buffer, int startIndex, int length, out Header header)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            if (buffer == null)
            {
                throw new ArgumentNullException("buffer");
            }

            if (startIndex < 0 || startIndex > buffer.Length)
            {
                throw new ArgumentOutOfRangeException("startIndex");
            }

            if (length < 0 || startIndex + length > buffer.Length)
            {
                throw new ArgumentOutOfRangeException("length");
            }

            unsafe
            {
                fixed(byte *inptr = buffer)
                {
                    return(TryParse(options.Clone(), inptr + startIndex, length, true, out header));
                }
            }
        }
All Usage Examples Of MimeKit.ParserOptions::Clone