C# based username suggestor based off current input.
Default settings.
string input = ".:Test:.";
List<string> suggestionList = SuggestorService.GetSuggestions(".:alex:.");
// [".:alexVigorous:.", ".:alexSnoopy:.", ".:alexThrifty:."]
Customisable, you can load the wordlist yourself or you can give it a word list file path and it will load the loads (list of words separated by new line characters).
List<string> suggestionList = SuggestorService.GetSuggestions(".:alex:.", new SuggestorSettings
{
Format = "{original}{}",
MaximumWordLength = 12,
SuggestionCount = 3,
MaximumAttempts = 10,
WordList = null,
WordListFile = null
});
// [".:alexRich:.", ".:alexSnoopy:.", ".:alexThrifty:."]
You can access the default settings with SuggestorService.DefaultSettings
.
In addition, you can add a callback to return true / false if this entry already exists in your own data source so it will keep retrying.
SuggestorService.GetSuggestions(".:alex:.", IsUsernameTaken)
// or...
SuggestorService.GetSuggestions(".:alex:.", new SuggestorSettings
{
Format = "{original}{}",
MaximumWordLength = 12,
SuggestionCount = 3,
MaximumAttempts = 10,
WordList = null,
WordListFile = null
}, IsUsernameTaken);
Example callback method:
private static bool IsUsernameTaken(string input)
{
return _db.Users.Any(x => x.Username == input);
}
Another valid way to use such callback method with valid syntax:
SuggestorService.GetSuggestions(input, suggestorSettings, existsCallback: (checkName) =>
{
return this.NameTaken(checkName);
});
NuGet link: https://www.nuget.org/packages/Suggestor/1.0.0
Package:
NuGet\Install-Package Suggestor -Version 1.0.0