async Task EraseText(RoutedUICommand deleteCommand) { IViewContent vc = FileService.NewFile("stresstest.cs", ""); ITextEditor editor = vc.GetRequiredService <ITextEditor>(); TextArea textArea = editor.GetRequiredService <TextArea>(); editor.Document.Text = File.ReadAllText(bigFile); editor.Caret.Offset = editor.Document.TextLength / 2; await Dispatcher.Yield(Idle); for (int i = 0; i < Repetitions; i++) { deleteCommand.Execute(null, textArea); await Dispatcher.Yield(Idle); } vc.WorkbenchWindow.CloseWindow(true); }
async Task TypeCode() { IViewContent vc = FileService.NewFile("stresstest.cs", ""); ITextEditor editor = vc.GetRequiredService <ITextEditor>(); TextArea textArea = editor.GetRequiredService <TextArea>(); string inputText = string.Join("\n", File.ReadAllLines(bigFile).Where(l => !string.IsNullOrWhiteSpace(l) && !l.StartsWith("//", StringComparison.Ordinal))); await Dispatcher.Yield(Idle); for (int i = 0; i < Math.Min(inputText.Length, Repetitions); i++) { textArea.PerformTextInput(inputText[i].ToString()); await Dispatcher.Yield(Idle); while (!textArea.StackedInputHandlers.IsEmpty) { textArea.PopStackedInputHandler(textArea.StackedInputHandlers.Peek()); } await Dispatcher.Yield(Idle); } vc.WorkbenchWindow.CloseWindow(true); }
async Task TypeText(string theText) { const string csharpHeader = "using System;\n\nclass Test {\n\tpublic void M() {\n\t\t"; const string csharpFooter = "\n\t}\n}\n"; IViewContent vc = FileService.NewFile("stresstest.cs", ""); ITextEditor editor = vc.GetRequiredService <ITextEditor>(); editor.Document.Text = csharpHeader + csharpFooter; editor.Caret.Offset = csharpHeader.Length; TextArea textArea = (TextArea)editor.GetService(typeof(TextArea)); await Dispatcher.Yield(Idle); for (int i = 0; i < Repetitions; i++) { foreach (char c in "// " + theText + "\n") { textArea.PerformTextInput(c.ToString()); await Dispatcher.Yield(Idle); } } vc.WorkbenchWindow.CloseWindow(true); }