Boo.Lang.Compiler.TypeSystem.NameResolutionService.GetMostSimilarMemberName C# (CSharp) Method

GetMostSimilarMemberName() public method

public GetMostSimilarMemberName ( INamespace ns, string name, EntityType elementType ) : string
ns INamespace
name string
elementType EntityType
return string
        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;
        }