public override void Accept(IClientVisitor visitor) { foreach (var submessage in OriginalText.Split('\n')) { visitor.Visit(new PublicMessage(submessage)); } }
public CorrectionCandidate(TextElement textElement, Hunspell hunspell, ref Dictionary <string, string> autoReplacementList) { this.parameter = null; this.textElement = textElement; this.hunspell = hunspell; this.autoReplacementList = autoReplacementList; OriginalText = textElement.Text; char[] delimiterChars = { ' ', ',', '.', ':', '\t', '\\', '/', '(', ')', '<', '>', '\r' }; if (!string.IsNullOrEmpty(OriginalText)) { originalWords = OriginalText.Split(delimiterChars); NewText = OriginalText; } else { originalWords = null; NewText = OriginalText; } currentIndex = -1; rgx = new Regex(@"^.*[\d]+.*$"); }
public static void InjectLogs(string preLogText, string postLogText) { OriginalText = Clipboard.GetText(); var lines = OriginalText.Split('\n'); var sb = new StringBuilder(); for (int i = 0; i < lines.Length; i++) { if (lines[i].ShouldSkip()) { continue; } sb.Append($"{preLogText}{i}: {lines[i].Trim()}{postLogText}"); sb.Append(Environment.NewLine); sb.Append(lines[i]); } Clipboard.SetText(sb.ToString()); }
/// <summary> /// /// </summary> /// <param name="contents"></param> /// <param name="delim"></param> /// <param name="correctColCount"></param> /// <param name="position"></param> /// <param name="disallowedChars">A list of disallowed characters to remove in addition to /// those specified by the field. This is for support of globally disallowed characters.</param> public Row(string contents, string[] delim, int correctColCount, int position, char[] disallowedChars) { Position = position; //immediately get rid of any characters that are never ever legal OriginalText = PreSanitize(contents, disallowedChars); var stringVals = OriginalText.Split(delim, StringSplitOptions.None); HasCorrectColCount = correctColCount == stringVals.Count(); //if this is a single row, save the values and scoot if (stringVals.Count() <= correctColCount) { Values = GetValues(stringVals, correctColCount); return; } //but wait! what if it's just two or more rows joined together? In that case it would be twice the number of values except //that two values would be smushed together. Luckily we can undo that. int tmp = stringVals.Count() - correctColCount; if (tmp % (correctColCount - 1) == 0) { var allRows = SeparateCombinedRows(stringVals, correctColCount, delim); ExtraRows.AddRange(allRows.Skip(1).Select(r => new Row(string.Join(delim[0], r), delim, correctColCount, Position, disallowedChars))); //set the parameters of this row OriginalText = string.Join(delim[0], allRows[0]); HasCorrectColCount = true; Values = GetValues(allRows[0], correctColCount); } else { Values = GetValues(stringVals, correctColCount); } }