internal static string RemoveDoubling(string input) { var surrounded = SurroundCommand.IsSurrounded(input); var stringToAdjust = input; if (surrounded) { stringToAdjust = SurroundCommand.RemoveSurrounds(input); } var padded = PaddingCommand.IsPadded(stringToAdjust); if (padded) { stringToAdjust = PaddingCommand.PaddingLogic(stringToAdjust, ToggleMode.Reverse); } var letters = stringToAdjust.GetGraphemeClusters().ToList(); var result = new StringBuilder(); var i = 0; while (i < letters.Count) { result.Append(letters[i]); if (char.IsLetter(letters[i][0])) { i += 2; } else { ++i; } } var resultString = result.ToString(); if (padded) { resultString = PaddingCommand.PaddingLogic(resultString, ToggleMode.Apply); } if (surrounded) { resultString = SurroundCommand.SurroundLogic(resultString, ToggleMode.Apply); } return(resultString); }
internal static string Double(string input) { var surrounded = SurroundCommand.IsSurrounded(input); var stringToAdjust = input; if (surrounded) { stringToAdjust = SurroundCommand.RemoveSurrounds(input); } var padded = PaddingCommand.IsPadded(stringToAdjust); if (padded) { stringToAdjust = PaddingCommand.RemovePadding(stringToAdjust); } var letters = stringToAdjust.GetGraphemeClusters().ToList(); var result = new StringBuilder(); foreach (var letter in letters) { if (char.IsLetter(letter[0])) { result.Append(letter); } result.Append(letter); } var finalResult = result.ToString(); if (padded) { finalResult = PaddingCommand.AddPadding(finalResult); } if (surrounded) { finalResult = SurroundCommand.SurroundLogic(finalResult, ToggleMode.Apply); } return(finalResult); }
internal new ToggleMode GetToggleMode(string input) { return(PaddingCommand.IsPadded(input) ? ToggleMode.Reverse : ToggleMode.Apply); }