public void ColorsAreAsExpected(WriteStyle style, ConsoleColor expected) { TestConsoleLogger logger = Substitute.ForPartsOf <TestConsoleLogger>(); logger.Write(style, "Foo"); logger.Received(1).TestWriteColor(expected, Arg.Any <string>()); }
protected override void WriteInternal(WriteStyle style, string value) { foreach (ILogger logger in _loggers) { logger.Write(style, value); } }
public void TestFormatting(WriteStyle style, string value, string expected) { TestHtmlLogger logger = new TestHtmlLogger(); logger.TestAppendFormatedString(style, value); logger.HtmlTextBuffer.Should().EndWith(expected); }
protected override void WriteInternal(WriteStyle style, string value) { // TODO: How do we normalize this with the current design? Perhaps hold lines without a line end until we get one? // MSBuild ALWAYS is a "Writeline" value = value.Trim('\f', '\n', '\r'); if (string.IsNullOrWhiteSpace(value)) { return; } if (style.HasFlag(WriteStyle.Error)) { LogError(value); } else if (style.HasFlag(WriteStyle.Critical)) { LogWarning(value); } else { MessageImportance importance = MessageImportance.Normal; if (style.HasFlag(WriteStyle.Bold) || style.HasFlag(WriteStyle.Important)) { importance = MessageImportance.High; } BuildMessageEventArgs message = new BuildMessageEventArgs( message: value, helpKeyword: null, senderName: _taskName, importance: importance); _buildEngine.LogMessageEvent(message); } }
public void TestFormatting(WriteStyle style, string value, string expected) { TestRichTextLogger logger = new TestRichTextLogger(); logger.Write(style, value); logger.RichTextBuffer.Should().Be(expected); }
protected override void WriteInternal(WriteStyle style, string value) { bool bold = style.HasFlag(WriteStyle.Bold); bool underline = style.HasFlag(WriteStyle.Underline); bool italic = style.HasFlag(WriteStyle.Italic); bool fixedWidth = style.HasFlag(WriteStyle.Fixed); // 1. Output Style start tags (if any) \f1 \ul \b \i // 2. Output escaped text // 3. Output Style end tags \f0 \ul0 \b0 \i0 if (bold) { this.richText.Append(@"\b"); } if (fixedWidth) { this.richText.Append(@"\f1"); } if (underline) { this.richText.Append(@"\ul"); } if (italic) { this.richText.Append(@"\i"); } this.priorControlCharacter |= bold || italic || underline; this.richText.Append(this.Escape(value)); if (bold) { this.richText.Append(@"\b0"); } if (fixedWidth) { this.richText.Append(@"\f0"); } if (underline) { this.richText.Append(@"\ul0"); } if (italic) { this.richText.Append(@"\i0"); } this.priorControlCharacter |= bold || italic || underline; // Perhaps bracket every Write to scope style? Then resetting fonts isn't necessary {} }
protected override void WriteInternal(WriteStyle style, string value) { this.htmlText.AppendFormat( @"<span style='font-size:11.0pt;font-family:Calibri,sans-serif;white-space:pre{0}'>", style.HasFlag(WriteStyle.Error) ? @";color:red" : String.Empty); this.AppendFormatedString(style, value); this.htmlText.Append(@"</span>"); }
protected override void WriteInternal(WriteStyle style, string value) { _htmlText.AppendFormat( @"<span style='font-size:11.0pt;font-family:Calibri,sans-serif;white-space:pre{0}'>", style.HasFlag(WriteStyle.Error) ? @";color:red" : string.Empty); AppendFormatedString(style, value); _htmlText.Append(@"</span>"); }
public void Write(WriteStyle style, string value) { if (style.HasFlag(WriteStyle.Error)) { WriteInternal(style, String.Format(CultureInfo.CurrentUICulture, XTaskStrings.ErrorFormatString, value)); } else { WriteInternal(style, value); } }
protected void AppendFormatedString(WriteStyle style, string value) { if (style.HasFlag(WriteStyle.Bold)) { _htmlText.Append(@"<b>"); } if (style.HasFlag(WriteStyle.Italic)) { _htmlText.Append(@"<i>"); } if (style.HasFlag(WriteStyle.Critical)) { _htmlText.Append(@"<strong>"); } if (style.HasFlag(WriteStyle.Important)) { _htmlText.Append(@"<em>"); } if (style.HasFlag(WriteStyle.Underline)) { _htmlText.Append(@"<u>"); } if (style.HasFlag(WriteStyle.Fixed)) { _htmlText.Append(@"<pre>"); } ; _htmlText.Append(Strings.ReplaceLineEnds(WebUtility.HtmlEncode(value), @"<br>")); if (style.HasFlag(WriteStyle.Fixed)) { _htmlText.Append(@"</pre>"); } ; if (style.HasFlag(WriteStyle.Underline)) { _htmlText.Append(@"</u>"); } if (style.HasFlag(WriteStyle.Important)) { _htmlText.Append(@"</em>"); } if (style.HasFlag(WriteStyle.Critical)) { _htmlText.Append(@"</strong>"); } if (style.HasFlag(WriteStyle.Italic)) { _htmlText.Append(@"</i>"); } if (style.HasFlag(WriteStyle.Bold)) { _htmlText.Append(@"</b>"); } }
protected override void WriteInternal(WriteStyle style, string value) { if (style.HasFlag(WriteStyle.Underline)) { this.Output.Append(Strings.Underline(value)); } else { this.Output.Append(value); } }
/// <summary> /// возвращает набор ячеек, в которые помещено значение /// </summary> public ExcelRange Write(object toWrite, WriteOptions options, WriteStyle style = WriteStyle.Orinary) { ExcelRange cells; switch (options) { case WriteOptions.FullWidth: int width = worksheet.Dimension.End.Column; cells = worksheet.Cells[currRow, 1, currRow, width]; cells.Merge = true; cells.Value = toWrite; ApplyStyle(cells.Style, style); NewLine(); return(cells); case WriteOptions.SingleCell: //какие-то глобальные проблемы с заданием типа ячейки //теоретически, при получении числового значения, //фреймворк должен понимать, что в ячейке - число, //но он выставляет как строку - видимо, смотрит на формальный тип object cells = worksheet.Cells[currRow, currColumn, currRow, currColumn + singleColumnSize - 1]; cells.Merge = true; decimal tmp; if (decimal.TryParse(toWrite.ToString(), out tmp)) { cells.Value = tmp; } else { cells.Value = toWrite.ToString(); } currColumn += singleColumnSize; ApplyStyle(cells.Style, style); return(cells); case WriteOptions.Formula: cells = worksheet.Cells[currRow, currColumn, currRow, currColumn + singleColumnSize - 1]; cells.Merge = true; cells.Formula = toWrite.ToString(); currColumn += singleColumnSize; ApplyStyle(cells.Style, style); return(cells); default: throw new ArgumentException("Unknown write mode"); } }
protected void AppendFormatedString(WriteStyle style, string value) { if (style.HasFlag(WriteStyle.Bold)) this.htmlText.Append(@"<b>"); if (style.HasFlag(WriteStyle.Italic)) this.htmlText.Append(@"<i>"); if (style.HasFlag(WriteStyle.Critical)) this.htmlText.Append(@"<strong>"); if (style.HasFlag(WriteStyle.Important)) this.htmlText.Append(@"<em>"); if (style.HasFlag(WriteStyle.Underline)) this.htmlText.Append(@"<u>"); if (style.HasFlag(WriteStyle.Fixed)) this.htmlText.Append(@"<pre>"); ; this.htmlText.Append(Strings.ReplaceLineEnds(WebUtility.HtmlEncode(value), @"<br>")); if (style.HasFlag(WriteStyle.Fixed)) this.htmlText.Append(@"</pre>"); ; if (style.HasFlag(WriteStyle.Underline)) this.htmlText.Append(@"</u>"); if (style.HasFlag(WriteStyle.Important)) this.htmlText.Append(@"</em>"); if (style.HasFlag(WriteStyle.Critical)) this.htmlText.Append(@"</strong>"); if (style.HasFlag(WriteStyle.Italic)) this.htmlText.Append(@"</i>"); if (style.HasFlag(WriteStyle.Bold)) this.htmlText.Append(@"</b>"); }
protected override void WriteInternal(WriteStyle style, string value) { ConsoleColor color = _baseColor; foreach (var lookup in _colorTable) { if ((lookup.WriteStyle & style) != 0) { color = lookup.ConsoleColor; break; } } if (style.HasFlag(WriteStyle.Underline)) { WriteColorUnderlined(color, value); } else { WriteColor(color, value); } }
/// <summary> /// стиль может быть как у одной ячейке, так и у Range и еще бог знает у кого. /// Поэтому работаем прямо со стилем /// </summary> public void ApplyStyle(ExcelStyle excelStyle, WriteStyle style) { switch (style) { case WriteStyle.Orinary: excelStyle.WrapText = true; excelStyle.QuotePrefix = false; break; case WriteStyle.Header: //заголовок - просто жирный обычный текст ApplyStyle(excelStyle, WriteStyle.Orinary); excelStyle.Font.Bold = true; break; case WriteStyle.BigHeader: //заголовок - увеличинный отцентрованный заголовок ApplyStyle(excelStyle, WriteStyle.Header); excelStyle.Font.Size = 1.2f * excelStyle.Font.Size; excelStyle.HorizontalAlignment = ExcelHorizontalAlignment.Center; break; default: //ну не знаем мы, что тут делать. Ничего страшного break; } }
protected override void WriteInternal(WriteStyle style, string value) { // TODO: How do we normalize this with the current design? Perhaps hold lines without a line end until we get one? // MSBuild ALWAYS is a "Writeline" value = value.Trim('\f', '\n', '\r'); if (String.IsNullOrWhiteSpace(value)) { return; } if (style.HasFlag(WriteStyle.Error)) { this.LogError(value); } else if (style.HasFlag(WriteStyle.Critical)) { this.LogWarning(value); } else { MessageImportance importance = MessageImportance.Normal; if (style.HasFlag(WriteStyle.Bold) || style.HasFlag(WriteStyle.Important)) { importance = MessageImportance.High; } BuildMessageEventArgs message = new BuildMessageEventArgs( message: value, helpKeyword: null, senderName: this.taskName, importance: importance); this.buildEngine.LogMessageEvent(message); } }
protected override void WriteInternal(WriteStyle style, string value) { // XmlSpreadsheetLogger logger only logs tables return; }
public void TestAppendFormatedString(WriteStyle style, string value) { this.AppendFormatedString(style, value); }
public void WriteLine(WriteStyle style, string format, params object[] args) { }
protected abstract void WriteInternal(WriteStyle style, string value);
protected override void WriteInternal(WriteStyle style, string value) { this.TestWriteInternal(style, value); }
public void Write(WriteStyle style, string format, params object[] args) { Write(style, String.Format(CultureInfo.CurrentUICulture, format, args)); }
public void WriteLine(WriteStyle style, string format, params object[] args) { Write(style, format, args); WriteLine(); }
public void WriteLine(WriteStyle style, string value) { this.Write(style, value); this.WriteLine(); }
public void WriteLine(WriteStyle style, string value) { }
/// <summary> /// FileWriteBuffer constructor /// </summary> /// <param name="outputFileName">Destination output file name</param> public FileBuffer(string outputFileName) { OutputFileName = outputFileName; OutputStyle = WriteStyle.Append; }
protected override void WriteInternal(WriteStyle style, string value) { // CSV logger only logs tables return; }
public void WriteLine(WriteStyle style, string value) { Write(style, value); WriteLine(); }
public void TestWriteInternal(WriteStyle style, string value) { }
/// <summary> /// FileWriteBuffer constructor /// </summary> /// <param name="outputFileName">Destination output file name</param> /// <param name="outputStyle">Output write style for the buffer</param> public FileBuffer(string outputFileName, WriteStyle outputStyle) { OutputFileName = outputFileName; OutputStyle = outputStyle; }
public void ColorsAreAsExpected(WriteStyle style, ConsoleColor expected) { TestConsoleLogger logger = Substitute.ForPartsOf<TestConsoleLogger>(); logger.Write(style, "Foo"); logger.Received(1).TestWriteColor(expected, Arg.Any<string>()); }