formatting fixes

This commit is contained in:
Kyle Spearrin 2018-12-10 09:41:10 -05:00
parent 421f7e8799
commit fdea212415

View file

@ -10,7 +10,7 @@ namespace Bit.App.Utilities
class PasswordFormatter
{
/**
* This enum is used for the statemachine when building the colorized
* This enum is used for the state machine when building the colorized
* password string.
*/
private enum CharType
@ -25,22 +25,22 @@ namespace Bit.App.Utilities
{
var result = new FormattedString();
// Start off with an empty span to prevent possible NPEs. Due to the way the statemachine
// Start off with an empty span to prevent possible NPEs. Due to the way the state machine
// works, this will actually always be replaced by a new span anyway.
var currentSpan = new Span();
// Start with an otherwise uncovered case so we will definitely enter the "something changed"
// state.
var currentType = CharType.None;
foreach (var c in password)
foreach(var c in password)
{
// First, identify what the current char is.
CharType charType;
if (char.IsLetter(c))
if(char.IsLetter(c))
{
charType = CharType.Normal;
}
else if (char.IsDigit(c))
else if(char.IsDigit(c))
{
charType = CharType.Number;
}
@ -50,7 +50,7 @@ namespace Bit.App.Utilities
}
// If the char type changed, build a new span to append the text to.
if (charType != currentType)
if(charType != currentType)
{
currentSpan = new Span();
result.Spans.Add(currentSpan);
@ -58,18 +58,14 @@ namespace Bit.App.Utilities
// Switch the color if it is not a normal text. Otherwise leave the
// default value.
switch (currentType)
switch(currentType)
{
case CharType.Number:
{
currentSpan.TextColor = Color.DodgerBlue;
break;
}
case CharType.Special:
{
currentSpan.TextColor = Color.Firebrick;
break;
}
}
}