Skip to content

Commit

Permalink
Merge pull request #74 from hmlendea/casing
Browse files Browse the repository at this point in the history
Added `Original` word casing
  • Loading branch information
hmlendea authored Oct 9, 2023
2 parents 6e3debf + 9bfbcb6 commit 69b5ca1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
1 change: 1 addition & 0 deletions GenerationSchemas.xml
Original file line number Diff line number Diff line change
Expand Up @@ -928,5 +928,6 @@
<Name>Internet usernames</Name>
<Category>Usernames</Category>
<Schema>{markov,4,16,usernames/erepublik|usernames/github|usernames/mastodon|usernames/minecraft|usernames/reddit|usernames/steam|usernames/twitter|usernames/youtube}</Schema>
<WordCasing>Original</WordCasing>
</GenerationSchemaEntity>
</ArrayOfGenerationSchemaEntity>
2 changes: 2 additions & 0 deletions Models/Enumerations/WordCasing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
{
public enum WordCasing
{
Original,

/// <summary>
/// Every letter is lowercase.
/// </summary>
Expand Down
33 changes: 16 additions & 17 deletions Service/NameGeneratorService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,28 +108,27 @@ public IEnumerable<GenerationSchema> GetSchemas()

string GetNameWithCasing(string name, WordCasing casing)
{
string newName = name;

switch(casing)
if (casing.Equals(WordCasing.Lower))
{
case WordCasing.Lower:
newName = name.ToLower();
break;
return name.ToLower();
}

case WordCasing.Upper:
newName = name.ToUpper();
break;
if (casing.Equals(WordCasing.Upper))
{
return name.ToUpper();
}

case WordCasing.Title:
newName = name.ToTitleCase();
break;
if (casing.Equals(WordCasing.Title))
{
return name.ToTitleCase();
}

case WordCasing.Sentence:
newName = name.ToSentanceCase();
break;
if (casing.Equals(WordCasing.Sentence))
{
return name.ToSentanceCase();
}

return newName;
return name;
}

/// <summary>
Expand Down Expand Up @@ -223,7 +222,7 @@ List<Wordlist> GetWordLists(List<string> wordlistKeys)
foreach (string wordlistId in wordlistKeys)
{
string filePath = Path.Combine(ApplicationPaths.WordlistsDirectory, $"{wordlistId}.lst");

IWordRepository wordRepository = new WordRepository(filePath);

IEnumerable<Word> words = wordRepository.GetAll().ToDomainModels();
Expand Down

0 comments on commit 69b5ca1

Please sign in to comment.