/// <summary> /// Checks whether the supplied voter name exists in the list of known identities. /// This finds names using the current comparison settings, usually ignoring /// differences in whitespace, punctuation, etc. /// </summary> /// <param name="voterName">The name of the voter to check for. Does not need to be exact. Must not be null or empty.</param> /// <returns>Returns true if the voter name is known to exist.</returns> /// <exception cref="ArgumentNullException"/> public bool HasVoterName(string voterName) { if (string.IsNullOrEmpty(voterName)) { throw new ArgumentNullException(nameof(voterName)); } return(IdentityLookup.TryGetValue(voterName, out IdentitySet identities)); }
/// <summary> /// Gets all of the voter identities. /// </summary> /// <param name="voterName">Name of the voter.</param> /// <returns>The Identity Set for that voter.</returns> public IdentitySet GetVoterIdentities(string voterName) { if (IdentityLookup.TryGetValue(voterName, out IdentitySet identities)) { return(identities); } return(null); }
/// <summary> /// Gets the last voter identity. /// </summary> /// <param name="voterName">Name of the voter.</param> /// <returns>The last (by post ID) identity for that voter.</returns> public Identity GetLastVoterIdentity(string voterName, string host = null) { if (IdentityLookup.TryGetValue(voterName, out IdentitySet identities)) { var matchHost = identities.Where(i => host == null || i.Host == host).OrderBy(i => i.PostIDValue).Last(); return(matchHost); } return(null); }
/// <summary> /// Fill in the lookup table for name -> identity. /// </summary> private void InitIdentityLookup() { IdentityLookup.Clear(); foreach (var post in postsList) { if (IdentityLookup.TryGetValue(post.Identity.Name, out IdentitySet identities)) { identities.Add(post.Identity); } else { IdentityLookup.Add(post.Identity.Name, new IdentitySet { post.Identity }); } } }