diff --git a/ExtendedConsole/TextBuilder.cs b/ExtendedConsole/TextBuilder.cs
index 5c9bf43..ede5301 100644
--- a/ExtendedConsole/TextBuilder.cs
+++ b/ExtendedConsole/TextBuilder.cs
@@ -1,13 +1,19 @@
-using System;
+using System;
using System.Collections.Generic;
namespace ExtendedConsole
{
+ ///
+ /// Builds the text and colors to write to Console.
+ ///
internal class TextBuilder
{
private readonly List _actions;
private ConsoleColor _foreground, _background;
+ ///
+ /// Initialize a new instance of the TextBuilder class.
+ ///
internal TextBuilder()
{
_actions = new List();
@@ -15,11 +21,20 @@ internal TextBuilder()
_background = Console.BackgroundColor;
}
+ ///
+ /// Adds text to write to the console.
+ ///
+ /// Text to write to the console.
internal void AddText(string text)
{
_actions.Add(() => Console.Write(text));
}
+ ///
+ /// Adds a foreground color change, and returns the previous foreground color.
+ ///
+ /// A member of the ConsoleColor enum to set the foreground color to.
+ /// A nullable member of the ConsoleColor enum.
internal ConsoleColor? SetForegroundColor(ConsoleColor color)
{
var returnValue = _foreground;
@@ -28,6 +43,11 @@ internal void AddText(string text)
return returnValue;
}
+ ///
+ /// Adds a background color change, and returns the previous background color.
+ ///
+ /// A member of the ConsoleColor enum to set the background color to.
+ /// A nullable member of the ConsoleColor enum.
internal ConsoleColor? SetBackgroundColor(ConsoleColor color)
{
var returnValue = _background;
@@ -36,6 +56,11 @@ internal void AddText(string text)
return returnValue;
}
+ ///
+ /// Adds a foreground / background color change. If an argument is null, it has no effect.
+ ///
+ /// A nullable member of the ConsoleColor enum to set as foreground.
+ /// A nullable member of the ConsoleColor enum to set as background.
internal void ResetColors(ConsoleColor? foreground, ConsoleColor? background)
{
if (foreground.HasValue)
@@ -50,6 +75,9 @@ internal void ResetColors(ConsoleColor? foreground, ConsoleColor? background)
}
}
+ ///
+ /// Writes the content of the TextBuilder to the Console and clears it.
+ ///
internal void Write()
{
foreach (var action in _actions)
@@ -59,14 +87,13 @@ internal void Write()
_actions.Clear();
}
+ ///
+ /// Writes the content of the TextBuilder to the Console, clears it and adds a new line.
+ ///
internal void WriteLine()
{
_actions.Add(() => Console.WriteLine());
- foreach (var action in _actions)
- {
- action();
- }
- _actions.Clear();
+ Write();
}
}