Esempio n. 1
0
        public void ColorsAreAsExpected(WriteStyle style, ConsoleColor expected)
        {
            TestConsoleLogger logger = Substitute.ForPartsOf <TestConsoleLogger>();

            logger.Write(style, "Foo");
            logger.Received(1).TestWriteColor(expected, Arg.Any <string>());
        }
Esempio n. 2
0
 protected override void WriteInternal(WriteStyle style, string value)
 {
     foreach (ILogger logger in _loggers)
     {
         logger.Write(style, value);
     }
 }
Esempio n. 3
0
 protected override void WriteInternal(WriteStyle style, string value)
 {
     foreach (ILogger logger in _loggers)
     {
         logger.Write(style, value);
     }
 }
Esempio n. 4
0
        public void TestFormatting(WriteStyle style, string value, string expected)
        {
            TestHtmlLogger logger = new TestHtmlLogger();

            logger.TestAppendFormatedString(style, value);
            logger.HtmlTextBuffer.Should().EndWith(expected);
        }
Esempio n. 5
0
        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);
            }
        }
Esempio n. 6
0
        public void TestFormatting(WriteStyle style, string value, string expected)
        {
            TestRichTextLogger logger = new TestRichTextLogger();

            logger.Write(style, value);
            logger.RichTextBuffer.Should().Be(expected);
        }
Esempio n. 7
0
        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 {}
        }
Esempio n. 8
0
        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>");
        }
Esempio n. 9
0
        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>");
        }
Esempio n. 10
0
 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);
     }
 }
Esempio n. 11
0
 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>");
     }
 }
Esempio n. 12
0
 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);
     }
 }
Esempio n. 13
0
 protected override void WriteInternal(WriteStyle style, string value)
 {
     if (style.HasFlag(WriteStyle.Underline))
     {
         this.Output.Append(Strings.Underline(value));
     }
     else
     {
         this.Output.Append(value);
     }
 }
Esempio n. 14
0
 protected override void WriteInternal(WriteStyle style, string value)
 {
     if (style.HasFlag(WriteStyle.Underline))
     {
         this.Output.Append(Strings.Underline(value));
     }
     else
     {
         this.Output.Append(value);
     }
 }
Esempio n. 15
0
        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 {}
        }
        /// <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");
            }
        }
Esempio n. 17
0
 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>");
 }
Esempio n. 18
0
        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;
            }
        }
Esempio n. 20
0
        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);
            }
        }
Esempio n. 21
0
 protected override void WriteInternal(WriteStyle style, string value)
 {
     // XmlSpreadsheetLogger logger only logs tables
     return;
 }
Esempio n. 22
0
 public void TestAppendFormatedString(WriteStyle style, string value)
 {
     this.AppendFormatedString(style, value);
 }
Esempio n. 23
0
 public void WriteLine(WriteStyle style, string format, params object[] args)
 {
 }
Esempio n. 24
0
 protected abstract void WriteInternal(WriteStyle style, string value);
Esempio n. 25
0
 protected override void WriteInternal(WriteStyle style, string value)
 {
     this.TestWriteInternal(style, value);
 }
Esempio n. 26
0
 public void Write(WriteStyle style, string format, params object[] args)
 {
     Write(style, String.Format(CultureInfo.CurrentUICulture, format, args));
 }
Esempio n. 27
0
 public void WriteLine(WriteStyle style, string format, params object[] args)
 {
     Write(style, format, args);
     WriteLine();
 }
Esempio n. 28
0
 protected override void WriteInternal(WriteStyle style, string value)
 {
     this.TestWriteInternal(style, value);
 }
Esempio n. 29
0
 public void WriteLine(WriteStyle style, string format, params object[] args)
 {
 }
Esempio n. 30
0
 protected override void WriteInternal(WriteStyle style, string value)
 {
     // XmlSpreadsheetLogger logger only logs tables
     return;
 }
Esempio n. 31
0
 public void WriteLine(WriteStyle style, string value)
 {
     this.Write(style, value);
     this.WriteLine();
 }
Esempio n. 32
0
 public void WriteLine(WriteStyle style, string value)
 {
 }
Esempio n. 33
0
 /// <summary>
 /// FileWriteBuffer constructor
 /// </summary>
 /// <param name="outputFileName">Destination output file name</param>
 public FileBuffer(string outputFileName)
 {
     OutputFileName = outputFileName;
     OutputStyle    = WriteStyle.Append;
 }
Esempio n. 34
0
 public void Write(WriteStyle style, string format, params object[] args)
 {
     Write(style, String.Format(CultureInfo.CurrentUICulture, format, args));
 }
Esempio n. 35
0
 public void TestAppendFormatedString(WriteStyle style, string value)
 {
     this.AppendFormatedString(style, value);
 }
Esempio n. 36
0
 protected override void WriteInternal(WriteStyle style, string value)
 {
     // CSV logger only logs tables
     return;
 }
Esempio n. 37
0
 public void WriteLine(WriteStyle style, string value)
 {
     Write(style, value);
     WriteLine();
 }
Esempio n. 38
0
 protected abstract void WriteInternal(WriteStyle style, string value);
Esempio n. 39
0
 public void TestFormatting(WriteStyle style, string value, string expected)
 {
     TestRichTextLogger logger = new TestRichTextLogger();
     logger.Write(style, value);
     logger.RichTextBuffer.Should().Be(expected);
 }
Esempio n. 40
0
 public void WriteLine(WriteStyle style, string format, params object[] args)
 {
     Write(style, format, args);
     WriteLine();
 }
Esempio n. 41
0
 public void TestWriteInternal(WriteStyle style, string value)
 {
 }
Esempio n. 42
0
 public void WriteLine(WriteStyle style, string value)
 {
     Write(style, value);
     WriteLine();
 }
Esempio n. 43
0
 /// <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;
 }
Esempio n. 44
0
 public void ColorsAreAsExpected(WriteStyle style, ConsoleColor expected)
 {
     TestConsoleLogger logger = Substitute.ForPartsOf<TestConsoleLogger>();
     logger.Write(style, "Foo");
     logger.Received(1).TestWriteColor(expected, Arg.Any<string>());
 }
Esempio n. 45
0
 public void WriteLine(WriteStyle style, string value)
 {
 }
Esempio n. 46
0
 protected override void WriteInternal(WriteStyle style, string value)
 {
     // CSV logger only logs tables
     return;
 }
Esempio n. 47
0
 public void TestFormatting(WriteStyle style, string value, string expected)
 {
     TestHtmlLogger logger = new TestHtmlLogger();
     logger.TestAppendFormatedString(style, value);
     logger.HtmlTextBuffer.Should().EndWith(expected);
 }
Esempio n. 48
0
 public void TestWriteInternal(WriteStyle style, string value)
 {
 }