public static void WriteObjects <TObj, TMember1, TMember2, TMember3, TMember4, TMember5, TMember6, TMember7, TMember8, TMember9, TMember10>( this CommandContext context, IEnumerable <TObj> objects, Expression <Func <TObj, TMember1> > expression1, Expression <Func <TObj, TMember2> > expression2, Expression <Func <TObj, TMember3> > expression3, Expression <Func <TObj, TMember4> > expression4, Expression <Func <TObj, TMember5> > expression5, Expression <Func <TObj, TMember6> > expression6, Expression <Func <TObj, TMember7> > expression7, Expression <Func <TObj, TMember8> > expression8, Expression <Func <TObj, TMember9> > expression9, Expression <Func <TObj, TMember10> > expression10, bool indent, bool createHeader) { context.WriteText( LineFormatter.CreateLines( objects, expression1, expression2, expression3, expression4, expression5, expression6, expression7, expression8, expression9, expression10, indent, createHeader)); }
public void Build_EmptyAndNullAreDifferent_CorrectDisplay() { // Design Dummy Column DataColumn col = new DataColumn("DummyColumn"); col.ExtendedProperties.Add("NBi::Role", ColumnRole.Key); col.ExtendedProperties.Add("NBi::Type", ColumnType.Text); // Design dummy table DataTable table = new DataTable(); table.Columns.Add(col); var row = table.NewRow(); row[0] = string.Empty; row.SetColumnError(0, "(null)"); ICellFormatter cf = LineFormatter.Build(row, 0); // This must not throw an exception when the header is bigger that requested size var text = cf.GetText(20); Assert.That(text, Is.StringContaining("(empty)")); Assert.That(text, Is.StringContaining("<>")); Assert.That(text, Is.StringContaining("(null)")); }
/// <summary> Appends the log. </summary> /// <param name="text">The text to log.</param> public void AppendLog(string text, Color foreColor, bool dateStamp) { if (InvokeRequired) { Invoke((MethodInvoker)(() => AppendLog(text, foreColor, dateStamp))); return; } if (dateStamp) { Append(CurrentDate, Color.Gray); } int line = GetLineFromCharIndex(Math.Max(0, TextLength - 1)); if (!Colorize) { AppendText(text); if (AutoScroll) { ScrollToEnd(line); } return; } LineFormatter.Format(text, (c, s) => LineFormatter.FormatGui(c, s, this, foreColor)); if (AutoScroll) { ScrollToEnd(line); } }
public void Build_ColumnWithName_CorrectDisplay() { // Design Dummy Column DataColumn col = new DataColumn("DummyColumn"); col.ExtendedProperties.Add("NBi::Role", ColumnRole.Key); col.ExtendedProperties.Add("NBi::Type", ColumnType.Text); col.ColumnName = "My very long name that I want to display!"; // Design dummy table DataTable table = new DataTable(); table.Columns.Add(col); var row = table.NewRow(); row[0] = "My Value"; row.SetColumnError(0, "(null)"); ICellFormatter cf = LineFormatter.BuildHeader(table, 0); var length = cf.GetCellLength(); var name = cf.GetColumnName(length); Assert.That(name, Is.EqualTo("My very long name that I want to display! ")); // This should be the returned value var text = cf.GetText(length); Assert.That(text, Is.StringStarting("KEY (Text) ")); }
public void FormatLineTest(string lm0, string ts0, string s0, string[] s1) { var d = new LineFormatter(new LineMargins(lm0), new TabStops(ts0)); var r1 = d.FormatLine(s0); Assert.Equal(s1, r1); }
private void GetVariables() { string[] dataLines = assemblyCode.GetDataLines(); for (int i = 0; i < dataLines.Length; i++) { string line = LineFormatter.FormatDataLine(dataLines[i]); if (VariableManager.IsVariable(line)) { string[] pair = line.Split(new char[] { ' ' }, 2); string value; if (line.Equals("' '")) { value = line; } else if (pair.Length == 1) { value = pair[0]; } else { variableManager.AddVariable(pair[0], memoryCounter.ToString()); value = pair[1]; } AddInitVariableInstruction(value); } } }
/// <summary> /// Checks that a single line of input text is formatted as expected. /// </summary> /// <param name="text">Input code to format</param> /// <param name="expected">The expected result from the formatter. If null, then text is used.</param> /// <param name="line">The line number to request to be formatted.</param> /// <param name="languageVersion">Python language version to format.</param> /// <param name="editStart">Where the edit should begin (i.e. when whitespace or a multi-line string begins a line).</param> public static void AssertSingleLineFormat(string text, string expected = null, int line = 1, PythonLanguageVersion languageVersion = PythonLanguageVersion.V37, int editStart = 1) { if (text == null) { throw new ArgumentNullException(nameof(text)); } if (expected == null) { expected = text; } using (var reader = new StringReader(text)) { var lineFormatter = new LineFormatter(reader, languageVersion); var edits = lineFormatter.FormatLine(line); edits.Should().OnlyContain(new TextEdit { newText = expected, range = new Range { start = new SourceLocation(line, editStart), end = new SourceLocation(line, text.Split('\n')[line - 1].Length + 1) } }); } }
/// <summary>Creates an instance of AbstractMessageWriter.</summary> /// <remarks>Creates an instance of AbstractMessageWriter.</remarks> /// <param name="buffer">the session output buffer.</param> /// <param name="formatter"> /// the line formatter If <code>null</code> /// <see cref="Org.Apache.Http.Message.BasicLineFormatter.Instance">Org.Apache.Http.Message.BasicLineFormatter.Instance /// </see> /// will be used. /// </param> /// <since>4.3</since> public AbstractMessageWriter(SessionOutputBuffer buffer, LineFormatter formatter) : base() { this.sessionBuffer = Args.NotNull(buffer, "Session input buffer"); this.lineFormatter = (formatter != null) ? formatter : BasicLineFormatter.Instance; this.lineBuf = new CharArrayBuffer(128); }
public static void InitLogger() { var formatter = new LineFormatter(); var logConfig = new LogConfig(formatter); logConfig.AddTarget(LogLevel.Trace, LogLevel.Fatal, new AsyncFileTarget(formatter, "Log.log")); LogManager.Init(logConfig); Logger = LogManager.Default.GetLogger("BLogger"); }
private static void InitLogger() { var formatter = new LineFormatter(); var logConfig = new LogConfig(formatter); logConfig.AddTarget(LogLevel.Trace, LogLevel.Fatal, new SyncFileTarget(Path.Combine(ApplicationData.Current.LocalFolder.Path, @"Log.log"))); LogManager.Init(logConfig); }
private void InitLogging() { var formatter = new LineFormatter(); var logConfig = new LogConfig(formatter); var target = new SyncFileTarget(Path.Combine(global::Android.OS.Environment.ExternalStorageDirectory.AbsolutePath, "Log.log")); logConfig.AddTarget(LogLevel.Trace, LogLevel.Fatal, target); LogManager.Init(logConfig); }
private static void InitLogger() { var formatter = new LineFormatter(); var logConfig = new LogConfig(formatter); logConfig.AddTarget(LogLevel.Trace, LogLevel.Fatal, new SyncFileTarget(@"D:\Log.log")); LogManager.Init(logConfig); }
private static void InitLogger() { var formatter = new LineFormatter(); var logConfig = new LogConfig(formatter); logConfig.AddTarget(LogLevel.Trace, LogLevel.Fatal, new InMemoryBufferTarget(65536)); LogManager.Init(logConfig); }
public static void AssertNoEdits(string text, int line = 0, PythonLanguageVersion languageVersion = PythonLanguageVersion.V37) { Check.ArgumentNull(nameof(text), text); using (var reader = new StringReader(text)) { var edits = new LineFormatter(reader, languageVersion).FormatLine(line); edits.Should().BeEmpty(); } }
private static void InitLogger() { var categoryRegistry = new LogCategoryRegistrar(); var formatter = new LineFormatter(new DefaultCategoryFormatter(categoryRegistry)); var logConfig = new LogConfig(formatter, categoryRegistry); logConfig.AddTarget(LogLevel.Trace, LogLevel.Fatal, new PlainTcpSocketTarget("logs6.papertrailapp.com", 26613, new SyslogFormatter("GrigoryP_Console", "Slotomania" + DateTime.Now.ToString("u")))); LogManager.Init(logConfig); }
private static void InitLogger() { var formatter = new LineFormatter(); var logConfig = new LogConfig(formatter); logConfig.AddTarget(LogLevel.Trace, LogLevel.Fatal, new PlainStreamSocketTarget("logs6.papertrailapp.com", 26613, new SyslogFormatter("GrigoryP_Console", "Slotomania" + DateTime.Now.ToString("u")))); logConfig.AddTarget(LogLevel.Trace, LogLevel.Fatal, new SyncFileTarget(Path.Combine(ApplicationData.Current.LocalFolder.Path, @"Log.log"))); LogManager.Init(logConfig); }
/// <summary> /// Checks that a single line of input text is formatted as expected. /// </summary> /// <param name="text">Input code to format.</param> /// <param name="expected">The expected result from the formatter.</param> /// <param name="line">The line number to request to be formatted.</param> /// <param name="languageVersion">Python language version to format.</param> /// <param name="editStart">Where the edit should begin (i.e. when whitespace or a multi-line string begins a line).</param> public static void AssertSingleLineFormat(string text, string expected, int line = 0, PythonLanguageVersion languageVersion = PythonLanguageVersion.V37, int editStart = 0) { Check.ArgumentNull(nameof(text), text); Check.ArgumentNull(nameof(expected), expected); using (var reader = new StringReader(text)) { var edits = new LineFormatter(reader, languageVersion).FormatLine(line); edits.Should().OnlyHaveTextEdit(expected, (line, editStart, line, text.Split('\n')[line].Length)); } }
private static void InitLogger() { var categoryRegistry = new LogCategoryRegistrar(); var formatter = new LineFormatter(new DefaultCategoryFormatter(categoryRegistry)); var logConfig = new LogConfig(formatter, categoryRegistry); logConfig.AddTarget(LogLevel.Trace, LogLevel.Fatal, new ConsoleTarget()); LogManager.Init(logConfig); }
public TheBerlinClockSteps() { var lineFormatter = new LineFormatter((char)TimeConverter.Lamp.Off); var hourConverter = new HourConverter(lineFormatter); var minuteConverter = new MinuteConverter(lineFormatter); var secondConverter = new SecondConverter(lineFormatter); _berlinClock = new TimeConverter(hourConverter, minuteConverter, secondConverter); }
public void Line_is_split_as_expected(int lineLength, string input, string[] expectedResult) { var actualResult = LineFormatter.GetLines(input, lineLength); if (!expectedResult.SequenceEqual(actualResult)) { throw new XunitException("SequenceEqual failure:\r\n" + $"Expected: {expectedResult.Select(x => $"\"{x}\"").JoinToString(", ")}\r\n" + $"Actual: {actualResult.Select(x => $"\"{x}\"").JoinToString(", ")}"); } }
public void GetStringSegments_returns_the_expected_segments(string input, string[] expectedSegments) { var actualSegments = LineFormatter.GetStringSegments(input).Select(x => x.value).ToArray(); if (!expectedSegments.SequenceEqual(actualSegments)) { throw new XunitException("SequenceEqual failure:\r\n" + $"Expected: {expectedSegments.Select(x => $"\"{x}\"").JoinToString(", ")}\r\n" + $"Actual: {actualSegments.Select(x => $"\"{x}\"").JoinToString(", ")}"); } }
public Loger() { var formatter = new LineFormatter(); var logConfig = new LogConfig(formatter); var target = new SyncFileTarget(System.IO.Path.Combine(ApplicationData.Current.LocalFolder.Path, @"FileManagerLogs.log")); logConfig.AddTarget(LogLevel.Trace, LogLevel.Fatal, target); LogManager.Init(logConfig); _logger = LogManager.Default.GetLogger("FileManager logs"); }
public void Test_SplitWords_ShouldWork() { //arrange string workToBreak = "¿Hola? ¿Perdóneme? � Hay una línea, amigo."; //act var list = LineFormatter.SplitWords(workToBreak, 4, 4); //assert Assert.NotNull(list); Assert.Equal(2, list.Count); Assert.Equal(workToBreak, string.Join(" ", list)); }
public void Test_SplitWords_ShouldNotSplit() { //arrange string workToBreak = "¿Hola? ¿Perdóneme? � Hay una línea, amigo."; //act var list = LineFormatter.SplitWords(workToBreak, 100, 4); //assert Assert.NotNull(list); Assert.Equal(1, list.Count); Assert.Equal(workToBreak, list[0]); }
public static void AssertNoEdits(string text, int line = 1, PythonLanguageVersion languageVersion = PythonLanguageVersion.V37) { if (text == null) { throw new ArgumentNullException(nameof(text)); } using (var reader = new StringReader(text)) { var lineFormatter = new LineFormatter(reader, languageVersion); lineFormatter.FormatLine(line).Should().BeEmpty(); } }
public void CtorTest() { var lm0 = new LineMargins("(2,60,20)"); var ts0 = new TabStops("(4,10,30)"); var d0 = new LineFormatter(); var d1 = new LineFormatter(lm0); var d2 = new LineFormatter(lm0, ts0); Assert.Equal(new LineMargins(), d0.Margins); Assert.Equal(new TabStops(), d1.TabStops); Assert.Equal(lm0, d2.Margins); Assert.Equal(ts0, d2.TabStops); }
public static void WriteObjects <TObj, TMember1, TMember2>( this CommandContext context, IEnumerable <TObj> objects, Expression <Func <TObj, TMember1> > expression1, Expression <Func <TObj, TMember2> > expression2, bool indent, bool createHeader) { context.WriteText( LineFormatter.CreateLines( objects, expression1, expression2, indent, createHeader)); }
public AssemblyCode(string assemblyCode) { StringBuilder builder = new StringBuilder(); assemblyCode = Regex.Replace(assemblyCode, "[\t ]{2,}", " "); assemblyCode = assemblyCode.Replace("\r\n", "\n"); assemblyCode = assemblyCode.Replace("\t", " "); string[] lines = assemblyCode.Split('\n'); dataStart = 0; codeStart = 0; int originalLineCounter = 0; int reducedLineCounter = 0; while (originalLineCounter < lines.Length) { string line = LineFormatter.DeleteComments(lines[originalLineCounter]); if (line.Replace(" ", "").Equals("")) { originalLineCounter++; continue; } if (LineFormatter.IsStartData(line)) { dataStart = reducedLineCounter; } if (LineFormatter.IsStartCode(line)) { codeStart = reducedLineCounter; } if (LineFormatter.IsString(line)) { line = LineFormatter.GetCharacterArray(line); builder.Append(line); reducedLineCounter += line.Split('\n').Length - 1; originalLineCounter++; } else { builder.Append(line); builder.Append('\n'); reducedLineCounter++; originalLineCounter++; } } this.lines = builder.ToString().Split('\n'); }
private void ProcessCode() { instructionCounter = instructions.Count; string[] codeLines = assemblyCode.GetCodeLines(); for (int i = 0; i < codeLines.Length; i++) { if (!labelManager.IsLabelDeclaration(codeLines[i]) && !LineFormatter.ReservedWord(codeLines[i]) && !LineFormatter.IsCommentLine(codeLines[i])) { string line = LineFormatter.FormatCodeLine(codeLines[i]); try { Instruction instruction = InstructionFactory .createInstruction(line, labelManager.labels, variableManager.variablesValues); instructions.Add(instruction); instructionCounter++; if (instruction.GetType() == typeof(Pop1Instruction)) { instructions.Add( InstructionFactory.createInstruction( "2" + line, labelManager.labels, variableManager.variablesValues)); instructionCounter++; } else if (instruction.GetType() == typeof(Ret1Instruction)) { instructions.Add( InstructionFactory.createInstruction( "2" + line, labelManager.labels, variableManager.variablesValues)); instructionCounter++; } } catch (Exception ex) { Console.WriteLine(); Console.WriteLine("ERROR EN LINEA: " + line); Console.WriteLine(); Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); Console.ReadKey(); } } } }
public void GetText_ShortColumn_NoException() { // Design Dummy Column DataColumn col = new DataColumn("DummyColumn"); col.ExtendedProperties.Add("NBi::Role", ColumnRole.Key); col.ExtendedProperties.Add("NBi::Type", ColumnType.Numeric); // Design dummy table DataTable table = new DataTable(); table.Columns.Add(col); ICellFormatter cf = LineFormatter.BuildHeader(table, 0); // This must not throw an exception when the header is bigger that requested size cf.GetText(4); Assert.Pass(); }