/// <summary> /// Creates a new <see cref="NntpArticle"/> object. /// </summary> /// <param name="number">The number of the <see cref="NntpArticle"/>.</param> /// <param name="messageId">The <see cref="NntpMessageId"/> of the <see cref="NntpArticle"/>.</param> /// <param name="groups">The NNTP newsgroups this <see cref="NntpArticle"/> is posted in.</param> /// <param name="headers">The headers of the <see cref="NntpArticle"/>.</param> /// <param name="body">The body of the <see cref="NntpArticle"/>.</param> public NntpArticle( long number, NntpMessageId messageId, NntpGroups groups, IDictionary <string, ICollection <string> > headers, IEnumerable <string> body) { Number = number; MessageId = messageId ?? NntpMessageId.Empty; Groups = groups ?? NntpGroups.Empty; Headers = (headers ?? MultiValueDictionary <string, string> .Empty).ToImmutableDictionaryWithHashSets(); switch (body) { case null: // create empty immutable list Body = new List <string>(0).ToImmutableList(); break; case ICollection <string> collection: // make immutable Body = collection.ToImmutableList(); break; default: // not a collection but a stream of lines, keep enumerator // this is immutable already Body = body; break; } }
/// <summary> /// Returns a value indicating whether this instance is equal to the specified <see cref="NntpGroups"/> value. /// </summary> /// <param name="other">A <see cref="NntpGroups"/> object to compare to this instance.</param> /// <returns>true if <paramref name="other" /> has the same value as this instance; otherwise, false.</returns> public bool Equals(NntpGroups other) => (object)other != null && groups.SequenceEqual(other.groups);