public string GetMostSimilarMemberName(INamespace ns, string name, EntityType elementType)
{
if (null == ns) return null;
string expectedSoundex = ToSoundex(name);
string lastMemberName = null;
foreach (IEntity member in ns.GetMembers())
{
if (EntityType.Any != elementType && elementType != member.EntityType)
continue;
if (lastMemberName == member.Name)
continue;//no need to check this name again
//TODO: try Levenshtein distance or Metaphone instead of Soundex.
if (expectedSoundex == ToSoundex(member.Name))
{
return member.Name;
}
lastMemberName = member.Name;
}
return null;
}