/// <summary> /// Tries to parse the given input buffer into a new <see cref="MimeKit.InternetAddressList"/> instance. /// </summary> /// <remarks> /// Parses a list of addresses from the supplied buffer starting at the given index /// and spanning across the specified number of bytes. /// </remarks> /// <returns><c>true</c>, if the address list 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="addresses">The parsed addresses.</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 InternetAddressList addresses) { 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 || length > (buffer.Length - startIndex)) { throw new ArgumentOutOfRangeException("length"); } List <InternetAddress> addrlist; int index = startIndex; if (!TryParse(options, buffer, ref index, startIndex + length, false, false, out addrlist)) { addresses = null; return(false); } addresses = new InternetAddressList(addrlist); return(true); }
/// <summary> /// Tries to parse the given input buffer into a new <see cref="MimeKit.InternetAddressList"/> instance. /// </summary> /// <remarks> /// Parses a list of addresses from the supplied buffer starting at the given index /// and spanning across the specified number of bytes. /// </remarks> /// <returns><c>true</c>, if the address list was successfully parsed, <c>false</c> otherwise.</returns> /// <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="addresses">The parsed addresses.</param> /// <exception cref="System.ArgumentNullException"> /// <paramref name="buffer"/> is <c>null</c>. /// </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(byte[] buffer, int startIndex, int length, out InternetAddressList addresses) { return(TryParse(ParserOptions.Default, buffer, startIndex, length, out addresses)); }
/// <summary> /// Tries to parse the given text into a new <see cref="MimeKit.InternetAddressList"/> instance. /// </summary> /// <remarks> /// Parses a list of addresses from the specified text. /// </remarks> /// <returns><c>true</c>, if the address list was successfully parsed, <c>false</c> otherwise.</returns> /// <param name="text">The text.</param> /// <param name="addresses">The parsed addresses.</param> /// <exception cref="System.ArgumentNullException"> /// <paramref name="text"/> is <c>null</c>. /// </exception> public static bool TryParse(string text, out InternetAddressList addresses) { return(TryParse(ParserOptions.Default, text, out addresses)); }
/// <summary> /// Tries to parse the given input buffer into a new <see cref="MimeKit.InternetAddressList"/> instance. /// </summary> /// <remarks> /// Parses a list of addresses from the specified buffer. /// </remarks> /// <returns><c>true</c>, if the address list was successfully parsed, <c>false</c> otherwise.</returns> /// <param name="buffer">The input buffer.</param> /// <param name="addresses">The parsed addresses.</param> /// <exception cref="System.ArgumentNullException"> /// <paramref name="buffer"/> is <c>null</c>. /// </exception> public static bool TryParse(byte[] buffer, out InternetAddressList addresses) { return(TryParse(ParserOptions.Default, buffer, out addresses)); }
/// <summary> /// Tries to parse the given input buffer into a new <see cref="MimeKit.InternetAddressList"/> instance. /// </summary> /// <remarks> /// Parses a list of addresses from the supplied buffer starting at the specified index. /// </remarks> /// <returns><c>true</c>, if the address list 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="addresses">The parsed addresses.</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"/> is out of range. /// </exception> public static bool TryParse(ParserOptions options, byte[] buffer, int startIndex, out InternetAddressList addresses) { ParseUtils.ValidateArguments(options, buffer, startIndex); List <InternetAddress> addrlist; int index = startIndex; if (!TryParse(options, buffer, ref index, buffer.Length, false, false, out addrlist)) { addresses = null; return(false); } addresses = new InternetAddressList(addrlist); return(true); }
/// <summary> /// Initialize a new instance of the <see cref="GroupAddress"/> class. /// </summary> /// <remarks> /// Creates a new <see cref="GroupAddress"/> with the specified name. The specified /// text encoding is used when encoding the name according to the rules of rfc2047. /// </remarks> /// <param name="encoding">The character encoding to be used for encoding the name.</param> /// <param name="name">The name of the group.</param> /// <exception cref="System.ArgumentNullException"> /// <paramref name="encoding"/> is <c>null</c>. /// </exception> public GroupAddress(Encoding encoding, string name) : base(encoding, name) { Members = new InternetAddressList(); Members.Changed += MembersChanged; }
/// <summary> /// Initialize a new instance of the <see cref="GroupAddress"/> class. /// </summary> /// <remarks> /// Creates a new <see cref="GroupAddress"/> with the specified name and list of addresses. The /// specified text encoding is used when encoding the name according to the rules of rfc2047. /// </remarks> /// <param name="encoding">The character encoding to be used for encoding the name.</param> /// <param name="name">The name of the group.</param> /// <param name="addresses">A list of addresses.</param> /// <exception cref="System.ArgumentNullException"> /// <paramref name="encoding"/> is <c>null</c>. /// </exception> public GroupAddress(Encoding encoding, string name, IEnumerable <InternetAddress> addresses) : base(encoding, name) { Members = new InternetAddressList(addresses); Members.Changed += MembersChanged; }