protected string GenerateName(MemberAttributes attributes, TokenDictionary tokenDictionary, bool takeFirstMatch, params string[] nameStrings) { tokenDictionary = tokenDictionary ?? TokenDictionary; string validToken = null; foreach (var nameString in nameStrings) { var token = ConvertCaseFormating(attributes, nameString).ToAlphaNumericToken(); if (string.IsNullOrWhiteSpace(token)) { continue; } // this token is unused and not null or whitespace so return it if (!tokenDictionary.Contains(token)) { return(tokenDictionary.GenerateValidToken(token)); } // this token is a potential match but has a naming conflict // we only want the first potential match so once we assign to // validToken we never do it again if (validToken == null && tokenDictionary.Contains(token)) { if (takeFirstMatch) { return(tokenDictionary.GenerateValidToken(token)); } validToken = token; } } return (tokenDictionary.GenerateValidToken(!string.IsNullOrWhiteSpace(validToken) ? validToken : ConvertCaseFormating(attributes, "_invalid Name_"))); }