/// <summary>Static wrapper around the class, enables computation of metaphone keys /// without instantiating a class.</summary> /// /// <param name="word">Word whose metaphone keys are to be computed</param> /// <param name="primaryKey">Ref to var to receive primary metaphone key</param> /// <param name="alternateKey">Ref to var to receive alternate metaphone key, or be set to null if /// word has no alternate key by double metaphone</param> public static void GetDoubleMetaphone(string word, ref string primaryKey, ref string alternateKey) { DoubleMetaphone mp = new DoubleMetaphone(word); primaryKey = mp.PrimaryKey; alternateKey = mp.AlternateKey; }
void SetMetaphones() { int ptr = Name.IndexOf(",", StringComparison.Ordinal); if (ptr > 0) { string forenames = ptr + 2 < Name.Length ? Name.Substring(ptr + 2) : string.Empty; string surname = Name.Substring(0, ptr); int pos = forenames.IndexOf(" ", StringComparison.Ordinal); string forename = forenames is null ? string.Empty : (pos > 0 ? forenames.Substring(0, pos) : forenames); ForenameMetaphone = new DoubleMetaphone(forename).PrimaryKey; SurnameMetaphone = new DoubleMetaphone(surname).PrimaryKey; } else { ForenameMetaphone = string.Empty; SurnameMetaphone = string.Empty; } }