mirror of
				https://github.com/spectreconsole/spectre.console.git
				synced 2025-10-25 15:19:23 +00:00 
			
		
		
		
	Add convenience methods for writing values to the Console (#1)
* Remove IAnsiConsole.WriteLine * Add WriteLine extensions for IAnsiConsole * Add Write extensions for IAnsiConsole * Add Write and WriteLine method for AnsiConsole
This commit is contained in:
		
				
					committed by
					
						 Patrik Svensson
						Patrik Svensson
					
				
			
			
				
	
			
			
			
						parent
						
							36e2034a1c
						
					
				
				
					commit
					6a7733cabf
				
			| @@ -45,7 +45,6 @@ AnsiConsole.WriteLine("Hello World!"); | ||||
|  | ||||
| AnsiConsole.Reset(); | ||||
| AnsiConsole.WriteLine("Good bye!"); | ||||
| AnsiConsole.WriteLine(); | ||||
| ``` | ||||
|  | ||||
| If you want to get a reference to the default `IAnsiConsole`,  | ||||
|   | ||||
| @@ -1,9 +1,4 @@ | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.IO; | ||||
| using System.Linq; | ||||
| using System.Reflection; | ||||
| using System.Runtime.InteropServices; | ||||
| using Spectre.Console; | ||||
|  | ||||
| namespace Sample | ||||
| @@ -17,7 +12,7 @@ namespace Sample | ||||
|             AnsiConsole.Style = Styles.Underline | Styles.Bold; | ||||
|             AnsiConsole.WriteLine("Hello World!"); | ||||
|             AnsiConsole.Reset(); | ||||
|             AnsiConsole.WriteLine($"Capabilities: {AnsiConsole.Capabilities}"); | ||||
|             AnsiConsole.WriteLine("Capabilities: {0}", AnsiConsole.Capabilities); | ||||
|             AnsiConsole.WriteLine($"Width={AnsiConsole.Width}, Height={AnsiConsole.Height}"); | ||||
|             AnsiConsole.WriteLine("Good bye!"); | ||||
|             AnsiConsole.WriteLine(); | ||||
| @@ -41,7 +36,7 @@ namespace Sample | ||||
|             console.WriteLine("Hello World!"); | ||||
|             console.ResetColors(); | ||||
|             console.ResetStyle(); | ||||
|             console.WriteLine($"Capabilities: {console.Capabilities}"); | ||||
|             console.WriteLine("Capabilities: {0}", AnsiConsole.Capabilities); | ||||
|             console.WriteLine($"Width={AnsiConsole.Width}, Height={AnsiConsole.Height}"); | ||||
|             console.WriteLine("Good bye!"); | ||||
|             console.WriteLine(); | ||||
|   | ||||
| @@ -11,13 +11,13 @@ namespace Spectre.Console.Tests | ||||
|  | ||||
|         public string Output => _writer.ToString(); | ||||
|  | ||||
|         public AnsiConsoleFixture(ColorSystem system) | ||||
|         public AnsiConsoleFixture(ColorSystem system, AnsiSupport ansi = AnsiSupport.Yes) | ||||
|         { | ||||
|             _writer = new StringWriter(); | ||||
|  | ||||
|             Console = AnsiConsole.Create(new AnsiConsoleSettings | ||||
|             { | ||||
|                 Ansi = AnsiSupport.Yes, | ||||
|                 Ansi = ansi, | ||||
|                 ColorSystem = (ColorSystemSupport)system, | ||||
|                 Out = _writer, | ||||
|             }); | ||||
|   | ||||
| @@ -1,3 +1,5 @@ | ||||
| using System; | ||||
| using System.Globalization; | ||||
| using Shouldly; | ||||
| using Xunit; | ||||
|  | ||||
| @@ -68,5 +70,351 @@ namespace Spectre.Console.Tests | ||||
|             // Then | ||||
|             fixture.Output.ShouldBe("\u001b[90;47mHello\u001b[0m"); | ||||
|         } | ||||
|  | ||||
|         public sealed class Write | ||||
|         { | ||||
|             [Theory] | ||||
|             [InlineData(AnsiSupport.Yes)] | ||||
|             [InlineData(AnsiSupport.No)] | ||||
|             public void Should_Write_Int32_With_Format_Provider(AnsiSupport ansi) | ||||
|             { | ||||
|                 // Given | ||||
|                 var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi); | ||||
|  | ||||
|                 // When | ||||
|                 fixture.Console.Write(CultureInfo.InvariantCulture, 32); | ||||
|  | ||||
|                 // Then | ||||
|                 fixture.Output.ShouldBe("32"); | ||||
|             } | ||||
|  | ||||
|             [Theory] | ||||
|             [InlineData(AnsiSupport.Yes)] | ||||
|             [InlineData(AnsiSupport.No)] | ||||
|             public void Should_Write_UInt32_With_Format_Provider(AnsiSupport ansi) | ||||
|             { | ||||
|                 // Given | ||||
|                 var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi); | ||||
|  | ||||
|                 // When | ||||
|                 fixture.Console.Write(CultureInfo.InvariantCulture, 32U); | ||||
|  | ||||
|                 // Then | ||||
|                 fixture.Output.ShouldBe("32"); | ||||
|             } | ||||
|  | ||||
|             [Theory] | ||||
|             [InlineData(AnsiSupport.Yes)] | ||||
|             [InlineData(AnsiSupport.No)] | ||||
|             public void Should_Write_Int64_With_Format_Provider(AnsiSupport ansi) | ||||
|             { | ||||
|                 // Given | ||||
|                 var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi); | ||||
|  | ||||
|                 // When | ||||
|                 fixture.Console.Write(CultureInfo.InvariantCulture, 32L); | ||||
|  | ||||
|                 // Then | ||||
|                 fixture.Output.ShouldBe("32"); | ||||
|             } | ||||
|  | ||||
|             [Theory] | ||||
|             [InlineData(AnsiSupport.Yes)] | ||||
|             [InlineData(AnsiSupport.No)] | ||||
|             public void Should_Write_UInt64_With_Format_Provider(AnsiSupport ansi) | ||||
|             { | ||||
|                 // Given | ||||
|                 var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi); | ||||
|  | ||||
|                 // When | ||||
|                 fixture.Console.Write(CultureInfo.InvariantCulture, 32UL); | ||||
|  | ||||
|                 // Then | ||||
|                 fixture.Output.ShouldBe("32"); | ||||
|             } | ||||
|  | ||||
|             [Theory] | ||||
|             [InlineData(AnsiSupport.Yes)] | ||||
|             [InlineData(AnsiSupport.No)] | ||||
|             public void Should_Write_Single_With_Format_Provider(AnsiSupport ansi) | ||||
|             { | ||||
|                 // Given | ||||
|                 var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi); | ||||
|  | ||||
|                 // When | ||||
|                 fixture.Console.Write(CultureInfo.InvariantCulture, 32.432F); | ||||
|  | ||||
|                 // Then | ||||
|                 fixture.Output.ShouldBe("32.432"); | ||||
|             } | ||||
|  | ||||
|             [Theory] | ||||
|             [InlineData(AnsiSupport.Yes)] | ||||
|             [InlineData(AnsiSupport.No)] | ||||
|             public void Should_Write_Double_With_Format_Provider(AnsiSupport ansi) | ||||
|             { | ||||
|                 // Given | ||||
|                 var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi); | ||||
|  | ||||
|                 // When | ||||
|                 fixture.Console.Write(CultureInfo.InvariantCulture, (double)32.432); | ||||
|  | ||||
|                 // Then | ||||
|                 fixture.Output.ShouldBe("32.432"); | ||||
|             } | ||||
|  | ||||
|             [Theory] | ||||
|             [InlineData(AnsiSupport.Yes)] | ||||
|             [InlineData(AnsiSupport.No)] | ||||
|             public void Should_Write_Decimal_With_Format_Provider(AnsiSupport ansi) | ||||
|             { | ||||
|                 // Given | ||||
|                 var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi); | ||||
|  | ||||
|                 // When | ||||
|                 fixture.Console.Write(CultureInfo.InvariantCulture, 32.432M); | ||||
|  | ||||
|                 // Then | ||||
|                 fixture.Output.ShouldBe("32.432"); | ||||
|             } | ||||
|  | ||||
|             [Theory] | ||||
|             [InlineData(AnsiSupport.Yes)] | ||||
|             [InlineData(AnsiSupport.No)] | ||||
|             public void Should_Write_Boolean_With_Format_Provider(AnsiSupport ansi) | ||||
|             { | ||||
|                 // Given | ||||
|                 var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi); | ||||
|  | ||||
|                 // When | ||||
|                 fixture.Console.Write(CultureInfo.InvariantCulture, true); | ||||
|  | ||||
|                 // Then | ||||
|                 fixture.Output.ShouldBe("True"); | ||||
|             } | ||||
|  | ||||
|             [Theory] | ||||
|             [InlineData(AnsiSupport.Yes)] | ||||
|             [InlineData(AnsiSupport.No)] | ||||
|             public void Should_Write_Char_With_Format_Provider(AnsiSupport ansi) | ||||
|             { | ||||
|                 // Given | ||||
|                 var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi); | ||||
|  | ||||
|                 // When | ||||
|                 fixture.Console.Write(CultureInfo.InvariantCulture, 'P'); | ||||
|  | ||||
|                 // Then | ||||
|                 fixture.Output.ShouldBe("P"); | ||||
|             } | ||||
|  | ||||
|             [Theory] | ||||
|             [InlineData(AnsiSupport.Yes)] | ||||
|             [InlineData(AnsiSupport.No)] | ||||
|             public void Should_Write_Char_Array_With_Format_Provider(AnsiSupport ansi) | ||||
|             { | ||||
|                 // Given | ||||
|                 var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi); | ||||
|  | ||||
|                 // When | ||||
|                 fixture.Console.Write( | ||||
|                     CultureInfo.InvariantCulture, | ||||
|                     new[] { 'P', 'a', 't', 'r', 'i', 'k' }); | ||||
|  | ||||
|                 // Then | ||||
|                 fixture.Output.ShouldBe("Patrik"); | ||||
|             } | ||||
|  | ||||
|             [Theory] | ||||
|             [InlineData(AnsiSupport.Yes)] | ||||
|             [InlineData(AnsiSupport.No)] | ||||
|             public void Should_Write_Formatted_String_With_Format_Provider(AnsiSupport ansi) | ||||
|             { | ||||
|                 // Given | ||||
|                 var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi); | ||||
|  | ||||
|                 // When | ||||
|                 fixture.Console.Write( | ||||
|                     CultureInfo.InvariantCulture, | ||||
|                     "Hello {0}! {1}", | ||||
|                     "World", 32); | ||||
|  | ||||
|                 // Then | ||||
|                 fixture.Output.ShouldBe("Hello World! 32"); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         public sealed class WriteLine | ||||
|         { | ||||
|             [Theory] | ||||
|             [InlineData(AnsiSupport.Yes)] | ||||
|             [InlineData(AnsiSupport.No)] | ||||
|             public void Should_Write_Int32_With_Format_Provider(AnsiSupport ansi) | ||||
|             { | ||||
|                 // Given | ||||
|                 var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi); | ||||
|  | ||||
|                 // When | ||||
|                 fixture.Console.WriteLine(CultureInfo.InvariantCulture, 32); | ||||
|  | ||||
|                 // Then | ||||
|                 fixture.Output.ShouldBe("32" + Environment.NewLine); | ||||
|             } | ||||
|  | ||||
|             [Theory] | ||||
|             [InlineData(AnsiSupport.Yes)] | ||||
|             [InlineData(AnsiSupport.No)] | ||||
|             public void Should_Write_UInt32_With_Format_Provider(AnsiSupport ansi) | ||||
|             { | ||||
|                 // Given | ||||
|                 var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi); | ||||
|  | ||||
|                 // When | ||||
|                 fixture.Console.WriteLine(CultureInfo.InvariantCulture, 32U); | ||||
|  | ||||
|                 // Then | ||||
|                 fixture.Output.ShouldBe("32" + Environment.NewLine); | ||||
|             } | ||||
|  | ||||
|             [Theory] | ||||
|             [InlineData(AnsiSupport.Yes)] | ||||
|             [InlineData(AnsiSupport.No)] | ||||
|             public void Should_Write_Int64_With_Format_Provider(AnsiSupport ansi) | ||||
|             { | ||||
|                 // Given | ||||
|                 var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi); | ||||
|  | ||||
|                 // When | ||||
|                 fixture.Console.WriteLine(CultureInfo.InvariantCulture, 32L); | ||||
|  | ||||
|                 // Then | ||||
|                 fixture.Output.ShouldBe("32" + Environment.NewLine); | ||||
|             } | ||||
|  | ||||
|             [Theory] | ||||
|             [InlineData(AnsiSupport.Yes)] | ||||
|             [InlineData(AnsiSupport.No)] | ||||
|             public void Should_Write_UInt64_With_Format_Provider(AnsiSupport ansi) | ||||
|             { | ||||
|                 // Given | ||||
|                 var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi); | ||||
|  | ||||
|                 // When | ||||
|                 fixture.Console.WriteLine(CultureInfo.InvariantCulture, 32UL); | ||||
|  | ||||
|                 // Then | ||||
|                 fixture.Output.ShouldBe("32" + Environment.NewLine); | ||||
|             } | ||||
|  | ||||
|             [Theory] | ||||
|             [InlineData(AnsiSupport.Yes)] | ||||
|             [InlineData(AnsiSupport.No)] | ||||
|             public void Should_Write_Single_With_Format_Provider(AnsiSupport ansi) | ||||
|             { | ||||
|                 // Given | ||||
|                 var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi); | ||||
|  | ||||
|                 // When | ||||
|                 fixture.Console.WriteLine(CultureInfo.InvariantCulture, 32.432F); | ||||
|  | ||||
|                 // Then | ||||
|                 fixture.Output.ShouldBe("32.432" + Environment.NewLine); | ||||
|             } | ||||
|  | ||||
|             [Theory] | ||||
|             [InlineData(AnsiSupport.Yes)] | ||||
|             [InlineData(AnsiSupport.No)] | ||||
|             public void Should_Write_Double_With_Format_Provider(AnsiSupport ansi) | ||||
|             { | ||||
|                 // Given | ||||
|                 var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi); | ||||
|  | ||||
|                 // When | ||||
|                 fixture.Console.WriteLine(CultureInfo.InvariantCulture, (double)32.432); | ||||
|  | ||||
|                 // Then | ||||
|                 fixture.Output.ShouldBe("32.432" + Environment.NewLine); | ||||
|             } | ||||
|  | ||||
|             [Theory] | ||||
|             [InlineData(AnsiSupport.Yes)] | ||||
|             [InlineData(AnsiSupport.No)] | ||||
|             public void Should_Write_Decimal_With_Format_Provider(AnsiSupport ansi) | ||||
|             { | ||||
|                 // Given | ||||
|                 var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi); | ||||
|  | ||||
|                 // When | ||||
|                 fixture.Console.WriteLine(CultureInfo.InvariantCulture, 32.432M); | ||||
|  | ||||
|                 // Then | ||||
|                 fixture.Output.ShouldBe("32.432" + Environment.NewLine); | ||||
|             } | ||||
|  | ||||
|             [Theory] | ||||
|             [InlineData(AnsiSupport.Yes)] | ||||
|             [InlineData(AnsiSupport.No)] | ||||
|             public void Should_Write_Boolean_With_Format_Provider(AnsiSupport ansi) | ||||
|             { | ||||
|                 // Given | ||||
|                 var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi); | ||||
|  | ||||
|                 // When | ||||
|                 fixture.Console.WriteLine(CultureInfo.InvariantCulture, true); | ||||
|  | ||||
|                 // Then | ||||
|                 fixture.Output.ShouldBe("True" + Environment.NewLine); | ||||
|             } | ||||
|  | ||||
|             [Theory] | ||||
|             [InlineData(AnsiSupport.Yes)] | ||||
|             [InlineData(AnsiSupport.No)] | ||||
|             public void Should_Write_Char_With_Format_Provider(AnsiSupport ansi) | ||||
|             { | ||||
|                 // Given | ||||
|                 var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi); | ||||
|  | ||||
|                 // When | ||||
|                 fixture.Console.WriteLine(CultureInfo.InvariantCulture, 'P'); | ||||
|  | ||||
|                 // Then | ||||
|                 fixture.Output.ShouldBe("P" + Environment.NewLine); | ||||
|             } | ||||
|  | ||||
|             [Theory] | ||||
|             [InlineData(AnsiSupport.Yes)] | ||||
|             [InlineData(AnsiSupport.No)] | ||||
|             public void Should_Write_Char_Array_With_Format_Provider(AnsiSupport ansi) | ||||
|             { | ||||
|                 // Given | ||||
|                 var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi); | ||||
|  | ||||
|                 // When | ||||
|                 fixture.Console.WriteLine( | ||||
|                     CultureInfo.InvariantCulture, | ||||
|                     new[] { 'P', 'a', 't', 'r', 'i', 'k' }); | ||||
|  | ||||
|                 // Then | ||||
|                 fixture.Output.ShouldBe("Patrik" + Environment.NewLine); | ||||
|             } | ||||
|  | ||||
|             [Theory] | ||||
|             [InlineData(AnsiSupport.Yes)] | ||||
|             [InlineData(AnsiSupport.No)] | ||||
|             public void Should_Write_Formatted_String_With_Format_Provider(AnsiSupport ansi) | ||||
|             { | ||||
|                 // Given | ||||
|                 var fixture = new AnsiConsoleFixture(ColorSystem.Standard, ansi); | ||||
|  | ||||
|                 // When | ||||
|                 fixture.Console.WriteLine( | ||||
|                     CultureInfo.InvariantCulture, | ||||
|                     "Hello {0}! {1}", | ||||
|                     "World", 32); | ||||
|  | ||||
|                 // Then | ||||
|                 fixture.Output.ShouldBe("Hello World! 32" + Environment.NewLine); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
							
								
								
									
										245
									
								
								src/Spectre.Console/AnsiConsole.Write.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										245
									
								
								src/Spectre.Console/AnsiConsole.Write.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,245 @@ | ||||
| using System; | ||||
| using System.Globalization; | ||||
|  | ||||
| namespace Spectre.Console | ||||
| { | ||||
|     /// <summary> | ||||
|     /// A console capable of writing ANSI escape sequences. | ||||
|     /// </summary> | ||||
|     public static partial class AnsiConsole | ||||
|     { | ||||
|         /// <summary> | ||||
|         /// Writes the specified string value to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void Write(string value) | ||||
|         { | ||||
|             Console.Write(value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified 32-bit | ||||
|         /// signed integer value to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void Write(int value) | ||||
|         { | ||||
|             Console.Write(CultureInfo.CurrentCulture, value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified 32-bit | ||||
|         /// signed integer value to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void Write(IFormatProvider provider, int value) | ||||
|         { | ||||
|             Console.Write(value.ToString(provider)); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified 32-bit | ||||
|         /// unsigned integer value to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void Write(uint value) | ||||
|         { | ||||
|             Console.Write(CultureInfo.CurrentCulture, value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified 32-bit | ||||
|         /// unsigned integer value to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void Write(IFormatProvider provider, uint value) | ||||
|         { | ||||
|             Console.Write(value.ToString(provider)); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified 64-bit | ||||
|         /// signed integer value to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void Write(long value) | ||||
|         { | ||||
|             Console.Write(CultureInfo.CurrentCulture, value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified 64-bit | ||||
|         /// signed integer value to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void Write(IFormatProvider provider, long value) | ||||
|         { | ||||
|             Console.Write(value.ToString(provider)); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified 64-bit | ||||
|         /// unsigned integer value to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void Write(ulong value) | ||||
|         { | ||||
|             Console.Write(CultureInfo.CurrentCulture, value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified 64-bit | ||||
|         /// unsigned integer value to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void Write(IFormatProvider provider, ulong value) | ||||
|         { | ||||
|             Console.Write(value.ToString(provider)); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified single-precision | ||||
|         /// floating-point value to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void Write(float value) | ||||
|         { | ||||
|             Console.Write(CultureInfo.CurrentCulture, value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified single-precision | ||||
|         /// floating-point value to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void Write(IFormatProvider provider, float value) | ||||
|         { | ||||
|             Console.Write(value.ToString(provider)); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified double-precision | ||||
|         /// floating-point value to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void Write(double value) | ||||
|         { | ||||
|             Console.Write(CultureInfo.CurrentCulture, value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified double-precision | ||||
|         /// floating-point value to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void Write(IFormatProvider provider, double value) | ||||
|         { | ||||
|             Console.Write(value.ToString(provider)); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified decimal value, to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void Write(decimal value) | ||||
|         { | ||||
|             Console.Write(CultureInfo.CurrentCulture, value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified decimal value, to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void Write(IFormatProvider provider, decimal value) | ||||
|         { | ||||
|             Console.Write(value.ToString(provider)); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified boolean value to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void Write(bool value) | ||||
|         { | ||||
|             Console.Write(CultureInfo.CurrentCulture, value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified boolean value to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void Write(IFormatProvider provider, bool value) | ||||
|         { | ||||
|             Console.Write(value.ToString(provider)); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the specified Unicode character to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void Write(char value) | ||||
|         { | ||||
|             Console.Write(CultureInfo.CurrentCulture, value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the specified Unicode character to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void Write(IFormatProvider provider, char value) | ||||
|         { | ||||
|             Console.Write(value.ToString(provider)); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the specified array of Unicode characters to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void Write(char[] value) | ||||
|         { | ||||
|             Console.Write(CultureInfo.CurrentCulture, value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the specified array of Unicode characters to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void Write(IFormatProvider provider, char[] value) | ||||
|         { | ||||
|             Console.Write(provider, value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified array of objects, | ||||
|         /// to the console using the specified format information. | ||||
|         /// </summary> | ||||
|         /// <param name="format">A composite format string.</param> | ||||
|         /// <param name="args">An array of objects to write.</param> | ||||
|         public static void Write(string format, params object[] args) | ||||
|         { | ||||
|             Console.Write(CultureInfo.CurrentCulture, format, args); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified array of objects, | ||||
|         /// to the console using the specified format information. | ||||
|         /// </summary> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="format">A composite format string.</param> | ||||
|         /// <param name="args">An array of objects to write.</param> | ||||
|         public static void Write(IFormatProvider provider, string format, params object[] args) | ||||
|         { | ||||
|             Console.Write(string.Format(provider, format, args)); | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										263
									
								
								src/Spectre.Console/AnsiConsole.WriteLine.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										263
									
								
								src/Spectre.Console/AnsiConsole.WriteLine.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,263 @@ | ||||
| using System; | ||||
| using System.Globalization; | ||||
|  | ||||
| namespace Spectre.Console | ||||
| { | ||||
|     /// <summary> | ||||
|     /// A console capable of writing ANSI escape sequences. | ||||
|     /// </summary> | ||||
|     public static partial class AnsiConsole | ||||
|     { | ||||
|         /// <summary> | ||||
|         /// Writes an empty line to the console. | ||||
|         /// </summary> | ||||
|         public static void WriteLine() | ||||
|         { | ||||
|             Console.WriteLine(); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the specified string value, followed by the current line terminator, to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void WriteLine(string value) | ||||
|         { | ||||
|             Console.WriteLine(value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified 32-bit signed integer value, | ||||
|         /// followed by the current line terminator, to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void WriteLine(int value) | ||||
|         { | ||||
|             Console.WriteLine(CultureInfo.CurrentCulture, value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified 32-bit signed integer value, | ||||
|         /// followed by the current line terminator, to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void WriteLine(IFormatProvider provider, int value) | ||||
|         { | ||||
|             Console.WriteLine(value.ToString(provider)); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified 32-bit unsigned integer value, | ||||
|         /// followed by the current line terminator, to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void WriteLine(uint value) | ||||
|         { | ||||
|             Console.WriteLine(CultureInfo.CurrentCulture, value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified 32-bit unsigned integer value, | ||||
|         /// followed by the current line terminator, to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void WriteLine(IFormatProvider provider, uint value) | ||||
|         { | ||||
|             Console.WriteLine(value.ToString(provider)); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified 64-bit signed integer value, | ||||
|         /// followed by the current line terminator, to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void WriteLine(long value) | ||||
|         { | ||||
|             Console.WriteLine(CultureInfo.CurrentCulture, value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified 64-bit signed integer value, | ||||
|         /// followed by the current line terminator, to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void WriteLine(IFormatProvider provider, long value) | ||||
|         { | ||||
|             Console.WriteLine(value.ToString(provider)); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified 64-bit unsigned integer value, | ||||
|         /// followed by the current line terminator, to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void WriteLine(ulong value) | ||||
|         { | ||||
|             Console.WriteLine(CultureInfo.CurrentCulture, value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified 64-bit unsigned integer value, | ||||
|         /// followed by the current line terminator, to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void WriteLine(IFormatProvider provider, ulong value) | ||||
|         { | ||||
|             Console.WriteLine(value.ToString(provider)); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified single-precision floating-point | ||||
|         /// value, followed by the current line terminator, to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void WriteLine(float value) | ||||
|         { | ||||
|             Console.WriteLine(CultureInfo.CurrentCulture, value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified single-precision floating-point | ||||
|         /// value, followed by the current line terminator, to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void WriteLine(IFormatProvider provider, float value) | ||||
|         { | ||||
|             Console.WriteLine(value.ToString(provider)); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified double-precision floating-point | ||||
|         /// value, followed by the current line terminator, to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void WriteLine(double value) | ||||
|         { | ||||
|             Console.WriteLine(CultureInfo.CurrentCulture, value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified double-precision floating-point | ||||
|         /// value, followed by the current line terminator, to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void WriteLine(IFormatProvider provider, double value) | ||||
|         { | ||||
|             Console.WriteLine(value.ToString(provider)); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified decimal value, | ||||
|         /// followed by the current line terminator, to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void WriteLine(decimal value) | ||||
|         { | ||||
|             Console.WriteLine(CultureInfo.CurrentCulture, value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified decimal value, | ||||
|         /// followed by the current line terminator, to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void WriteLine(IFormatProvider provider, decimal value) | ||||
|         { | ||||
|             Console.WriteLine(value.ToString(provider)); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified boolean value, | ||||
|         /// followed by the current line terminator, to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void WriteLine(bool value) | ||||
|         { | ||||
|             Console.WriteLine(CultureInfo.CurrentCulture, value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified boolean value, | ||||
|         /// followed by the current line terminator, to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void WriteLine(IFormatProvider provider, bool value) | ||||
|         { | ||||
|             Console.WriteLine(value.ToString(provider)); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the specified Unicode character, followed by the current | ||||
|         /// line terminator, value to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void WriteLine(char value) | ||||
|         { | ||||
|             Console.WriteLine(CultureInfo.CurrentCulture, value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the specified Unicode character, followed by the current | ||||
|         /// line terminator, value to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void WriteLine(IFormatProvider provider, char value) | ||||
|         { | ||||
|             Console.WriteLine(value.ToString(provider)); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the specified array of Unicode characters, followed by the current | ||||
|         /// line terminator, value to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void WriteLine(char[] value) | ||||
|         { | ||||
|             Console.WriteLine(CultureInfo.CurrentCulture, value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the specified array of Unicode characters, followed by the current | ||||
|         /// line terminator, value to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void WriteLine(IFormatProvider provider, char[] value) | ||||
|         { | ||||
|             Console.WriteLine(provider, value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified array of objects, | ||||
|         /// followed by the current line terminator, to the console | ||||
|         /// using the specified format information. | ||||
|         /// </summary> | ||||
|         /// <param name="format">A composite format string.</param> | ||||
|         /// <param name="args">An array of objects to write.</param> | ||||
|         public static void WriteLine(string format, params object[] args) | ||||
|         { | ||||
|             Console.WriteLine(CultureInfo.CurrentCulture, format, args); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified array of objects, | ||||
|         /// followed by the current line terminator, to the console | ||||
|         /// using the specified format information. | ||||
|         /// </summary> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="format">A composite format string.</param> | ||||
|         /// <param name="args">An array of objects to write.</param> | ||||
|         public static void WriteLine(IFormatProvider provider, string format, params object[] args) | ||||
|         { | ||||
|             Console.WriteLine(string.Format(provider, format, args)); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -6,7 +6,7 @@ namespace Spectre.Console | ||||
|     /// <summary> | ||||
|     /// A console capable of writing ANSI escape sequences. | ||||
|     /// </summary> | ||||
|     public static class AnsiConsole | ||||
|     public static partial class AnsiConsole | ||||
|     { | ||||
|         private static readonly Lazy<IAnsiConsole> _console = new Lazy<IAnsiConsole>(() => | ||||
|         { | ||||
| @@ -105,31 +105,5 @@ namespace Spectre.Console | ||||
|         { | ||||
|             Console.ResetColors(); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the content to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="content">The content to write.</param> | ||||
|         public static void Write(string content) | ||||
|         { | ||||
|             Console.Write(content); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes an empty line to the console. | ||||
|         /// </summary> | ||||
|         public static void WriteLine() | ||||
|         { | ||||
|             Console.WriteLine(); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes a line to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="content">The content to write.</param> | ||||
|         public static void WriteLine(string content) | ||||
|         { | ||||
|             Console.WriteLine(content); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
							
								
								
									
										339
									
								
								src/Spectre.Console/ConsoleExtensions.Write.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										339
									
								
								src/Spectre.Console/ConsoleExtensions.Write.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,339 @@ | ||||
| using System; | ||||
| using System.Globalization; | ||||
|  | ||||
| namespace Spectre.Console | ||||
| { | ||||
|     /// <summary> | ||||
|     /// Contains extension methods for <see cref="IAnsiConsole"/>. | ||||
|     /// </summary> | ||||
|     public static partial class ConsoleExtensions | ||||
|     { | ||||
|         /// <summary> | ||||
|         /// Writes the specified string value to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void Write(this IAnsiConsole console, string value) | ||||
|         { | ||||
|             if (console is null) | ||||
|             { | ||||
|                 throw new ArgumentNullException(nameof(console)); | ||||
|             } | ||||
|  | ||||
|             if (value != null) | ||||
|             { | ||||
|                 console.Write(value); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified 32-bit | ||||
|         /// signed integer value to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void Write(this IAnsiConsole console, int value) | ||||
|         { | ||||
|             Write(console, CultureInfo.CurrentCulture, value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified 32-bit | ||||
|         /// signed integer value to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void Write(this IAnsiConsole console, IFormatProvider provider, int value) | ||||
|         { | ||||
|             if (console is null) | ||||
|             { | ||||
|                 throw new ArgumentNullException(nameof(console)); | ||||
|             } | ||||
|  | ||||
|             console.Write(value.ToString(provider)); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified 32-bit | ||||
|         /// unsigned integer value to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void Write(this IAnsiConsole console, uint value) | ||||
|         { | ||||
|             Write(console, CultureInfo.CurrentCulture, value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified 32-bit | ||||
|         /// unsigned integer value to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void Write(this IAnsiConsole console, IFormatProvider provider, uint value) | ||||
|         { | ||||
|             if (console is null) | ||||
|             { | ||||
|                 throw new ArgumentNullException(nameof(console)); | ||||
|             } | ||||
|  | ||||
|             console.Write(value.ToString(provider)); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified 64-bit | ||||
|         /// signed integer value to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void Write(this IAnsiConsole console, long value) | ||||
|         { | ||||
|             Write(console, CultureInfo.CurrentCulture, value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified 64-bit | ||||
|         /// signed integer value to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void Write(this IAnsiConsole console, IFormatProvider provider, long value) | ||||
|         { | ||||
|             if (console is null) | ||||
|             { | ||||
|                 throw new ArgumentNullException(nameof(console)); | ||||
|             } | ||||
|  | ||||
|             console.Write(value.ToString(provider)); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified 64-bit | ||||
|         /// unsigned integer value to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void Write(this IAnsiConsole console, ulong value) | ||||
|         { | ||||
|             Write(console, CultureInfo.CurrentCulture, value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified 64-bit | ||||
|         /// unsigned integer value to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void Write(this IAnsiConsole console, IFormatProvider provider, ulong value) | ||||
|         { | ||||
|             if (console is null) | ||||
|             { | ||||
|                 throw new ArgumentNullException(nameof(console)); | ||||
|             } | ||||
|  | ||||
|             console.Write(value.ToString(provider)); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified single-precision | ||||
|         /// floating-point value to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void Write(this IAnsiConsole console, float value) | ||||
|         { | ||||
|             Write(console, CultureInfo.CurrentCulture, value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified single-precision | ||||
|         /// floating-point value to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void Write(this IAnsiConsole console, IFormatProvider provider, float value) | ||||
|         { | ||||
|             if (console is null) | ||||
|             { | ||||
|                 throw new ArgumentNullException(nameof(console)); | ||||
|             } | ||||
|  | ||||
|             console.Write(value.ToString(provider)); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified double-precision | ||||
|         /// floating-point value to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void Write(this IAnsiConsole console, double value) | ||||
|         { | ||||
|             Write(console, CultureInfo.CurrentCulture, value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified double-precision | ||||
|         /// floating-point value to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void Write(this IAnsiConsole console, IFormatProvider provider, double value) | ||||
|         { | ||||
|             if (console is null) | ||||
|             { | ||||
|                 throw new ArgumentNullException(nameof(console)); | ||||
|             } | ||||
|  | ||||
|             console.Write(value.ToString(provider)); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified decimal value, to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void Write(this IAnsiConsole console, decimal value) | ||||
|         { | ||||
|             Write(console, CultureInfo.CurrentCulture, value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified decimal value, to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void Write(this IAnsiConsole console, IFormatProvider provider, decimal value) | ||||
|         { | ||||
|             if (console is null) | ||||
|             { | ||||
|                 throw new ArgumentNullException(nameof(console)); | ||||
|             } | ||||
|  | ||||
|             Write(console, value.ToString(provider)); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified boolean value to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void Write(this IAnsiConsole console, bool value) | ||||
|         { | ||||
|             Write(console, CultureInfo.CurrentCulture, value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified boolean value to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void Write(this IAnsiConsole console, IFormatProvider provider, bool value) | ||||
|         { | ||||
|             if (console is null) | ||||
|             { | ||||
|                 throw new ArgumentNullException(nameof(console)); | ||||
|             } | ||||
|  | ||||
|             Write(console, value.ToString(provider)); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the specified Unicode character to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void Write(this IAnsiConsole console, char value) | ||||
|         { | ||||
|             Write(console, CultureInfo.CurrentCulture, value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the specified Unicode character to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void Write(this IAnsiConsole console, IFormatProvider provider, char value) | ||||
|         { | ||||
|             if (console is null) | ||||
|             { | ||||
|                 throw new ArgumentNullException(nameof(console)); | ||||
|             } | ||||
|  | ||||
|             Write(console, value.ToString(provider)); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the specified array of Unicode characters to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void Write(this IAnsiConsole console, char[] value) | ||||
|         { | ||||
|             Write(console, CultureInfo.CurrentCulture, value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the specified array of Unicode characters to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void Write(this IAnsiConsole console, IFormatProvider provider, char[] value) | ||||
|         { | ||||
|             if (console is null) | ||||
|             { | ||||
|                 throw new ArgumentNullException(nameof(console)); | ||||
|             } | ||||
|  | ||||
|             if (value is null) | ||||
|             { | ||||
|                 throw new ArgumentNullException(nameof(value)); | ||||
|             } | ||||
|  | ||||
|             for (var index = 0; index < value.Length; index++) | ||||
|             { | ||||
|                 console.Write(value[index].ToString(provider)); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified array of objects, | ||||
|         /// to the console using the specified format information. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="format">A composite format string.</param> | ||||
|         /// <param name="args">An array of objects to write.</param> | ||||
|         public static void Write(this IAnsiConsole console, string format, params object[] args) | ||||
|         { | ||||
|             Write(console, CultureInfo.CurrentCulture, format, args); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified array of objects, | ||||
|         /// to the console using the specified format information. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="format">A composite format string.</param> | ||||
|         /// <param name="args">An array of objects to write.</param> | ||||
|         public static void Write(this IAnsiConsole console, IFormatProvider provider, string format, params object[] args) | ||||
|         { | ||||
|             if (console is null) | ||||
|             { | ||||
|                 throw new ArgumentNullException(nameof(console)); | ||||
|             } | ||||
|  | ||||
|             Write(console, string.Format(provider, format, args)); | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										368
									
								
								src/Spectre.Console/ConsoleExtensions.WriteLine.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										368
									
								
								src/Spectre.Console/ConsoleExtensions.WriteLine.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,368 @@ | ||||
| using System; | ||||
| using System.Globalization; | ||||
|  | ||||
| namespace Spectre.Console | ||||
| { | ||||
|     /// <summary> | ||||
|     /// Contains extension methods for <see cref="IAnsiConsole"/>. | ||||
|     /// </summary> | ||||
|     public static partial class ConsoleExtensions | ||||
|     { | ||||
|         /// <summary> | ||||
|         /// Writes an empty line to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         public static void WriteLine(this IAnsiConsole console) | ||||
|         { | ||||
|             if (console is null) | ||||
|             { | ||||
|                 throw new ArgumentNullException(nameof(console)); | ||||
|             } | ||||
|  | ||||
|             console.Write(Environment.NewLine); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the specified string value, followed by the | ||||
|         /// current line terminator, to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void WriteLine(this IAnsiConsole console, string value) | ||||
|         { | ||||
|             if (console is null) | ||||
|             { | ||||
|                 throw new ArgumentNullException(nameof(console)); | ||||
|             } | ||||
|  | ||||
|             if (value != null) | ||||
|             { | ||||
|                 console.Write(value); | ||||
|             } | ||||
|  | ||||
|             console.WriteLine(); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified 32-bit signed integer value, | ||||
|         /// followed by the current line terminator, to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void WriteLine(this IAnsiConsole console, int value) | ||||
|         { | ||||
|             WriteLine(console, CultureInfo.CurrentCulture, value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified 32-bit signed integer value, | ||||
|         /// followed by the current line terminator, to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void WriteLine(this IAnsiConsole console, IFormatProvider provider, int value) | ||||
|         { | ||||
|             if (console is null) | ||||
|             { | ||||
|                 throw new ArgumentNullException(nameof(console)); | ||||
|             } | ||||
|  | ||||
|             console.WriteLine(value.ToString(provider)); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified 32-bit unsigned integer value, | ||||
|         /// followed by the current line terminator, to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void WriteLine(this IAnsiConsole console, uint value) | ||||
|         { | ||||
|             WriteLine(console, CultureInfo.CurrentCulture, value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified 32-bit unsigned integer value, | ||||
|         /// followed by the current line terminator, to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void WriteLine(this IAnsiConsole console, IFormatProvider provider, uint value) | ||||
|         { | ||||
|             if (console is null) | ||||
|             { | ||||
|                 throw new ArgumentNullException(nameof(console)); | ||||
|             } | ||||
|  | ||||
|             console.WriteLine(value.ToString(provider)); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified 64-bit signed integer value, | ||||
|         /// followed by the current line terminator, to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void WriteLine(this IAnsiConsole console, long value) | ||||
|         { | ||||
|             WriteLine(console, CultureInfo.CurrentCulture, value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified 64-bit signed integer value, | ||||
|         /// followed by the current line terminator, to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void WriteLine(this IAnsiConsole console, IFormatProvider provider, long value) | ||||
|         { | ||||
|             if (console is null) | ||||
|             { | ||||
|                 throw new ArgumentNullException(nameof(console)); | ||||
|             } | ||||
|  | ||||
|             console.WriteLine(value.ToString(provider)); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified 64-bit unsigned integer value, | ||||
|         /// followed by the current line terminator, to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void WriteLine(this IAnsiConsole console, ulong value) | ||||
|         { | ||||
|             WriteLine(console, CultureInfo.CurrentCulture, value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified 64-bit unsigned integer value, | ||||
|         /// followed by the current line terminator, to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void WriteLine(this IAnsiConsole console, IFormatProvider provider, ulong value) | ||||
|         { | ||||
|             if (console is null) | ||||
|             { | ||||
|                 throw new ArgumentNullException(nameof(console)); | ||||
|             } | ||||
|  | ||||
|             console.WriteLine(value.ToString(provider)); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified single-precision floating-point | ||||
|         /// value, followed by the current line terminator, to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void WriteLine(this IAnsiConsole console, float value) | ||||
|         { | ||||
|             WriteLine(console, CultureInfo.CurrentCulture, value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified single-precision floating-point | ||||
|         /// value, followed by the current line terminator, to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void WriteLine(this IAnsiConsole console, IFormatProvider provider, float value) | ||||
|         { | ||||
|             if (console is null) | ||||
|             { | ||||
|                 throw new ArgumentNullException(nameof(console)); | ||||
|             } | ||||
|  | ||||
|             console.WriteLine(value.ToString(provider)); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified double-precision floating-point | ||||
|         /// value, followed by the current line terminator, to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void WriteLine(this IAnsiConsole console, double value) | ||||
|         { | ||||
|             WriteLine(console, CultureInfo.CurrentCulture, value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified double-precision floating-point | ||||
|         /// value, followed by the current line terminator, to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void WriteLine(this IAnsiConsole console, IFormatProvider provider, double value) | ||||
|         { | ||||
|             if (console is null) | ||||
|             { | ||||
|                 throw new ArgumentNullException(nameof(console)); | ||||
|             } | ||||
|  | ||||
|             console.WriteLine(value.ToString(provider)); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified decimal value, | ||||
|         /// followed by the current line terminator, to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void WriteLine(this IAnsiConsole console, decimal value) | ||||
|         { | ||||
|             WriteLine(console, CultureInfo.CurrentCulture, value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified decimal value, | ||||
|         /// followed by the current line terminator, to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void WriteLine(this IAnsiConsole console, IFormatProvider provider, decimal value) | ||||
|         { | ||||
|             if (console is null) | ||||
|             { | ||||
|                 throw new ArgumentNullException(nameof(console)); | ||||
|             } | ||||
|  | ||||
|             WriteLine(console, value.ToString(provider)); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified boolean value, | ||||
|         /// followed by the current line terminator, to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void WriteLine(this IAnsiConsole console, bool value) | ||||
|         { | ||||
|             WriteLine(console, CultureInfo.CurrentCulture, value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified boolean value, | ||||
|         /// followed by the current line terminator, to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void WriteLine(this IAnsiConsole console, IFormatProvider provider, bool value) | ||||
|         { | ||||
|             if (console is null) | ||||
|             { | ||||
|                 throw new ArgumentNullException(nameof(console)); | ||||
|             } | ||||
|  | ||||
|             WriteLine(console, value.ToString(provider)); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the specified Unicode character, followed by the current | ||||
|         /// line terminator, value to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void WriteLine(this IAnsiConsole console, char value) | ||||
|         { | ||||
|             WriteLine(console, CultureInfo.CurrentCulture, value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the specified Unicode character, followed by the current | ||||
|         /// line terminator, value to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void WriteLine(this IAnsiConsole console, IFormatProvider provider, char value) | ||||
|         { | ||||
|             if (console is null) | ||||
|             { | ||||
|                 throw new ArgumentNullException(nameof(console)); | ||||
|             } | ||||
|  | ||||
|             WriteLine(console, value.ToString(provider)); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the specified array of Unicode characters, followed by the current | ||||
|         /// line terminator, value to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void WriteLine(this IAnsiConsole console, char[] value) | ||||
|         { | ||||
|             WriteLine(console, CultureInfo.CurrentCulture, value); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the specified array of Unicode characters, followed by the current | ||||
|         /// line terminator, value to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="value">The value to write.</param> | ||||
|         public static void WriteLine(this IAnsiConsole console, IFormatProvider provider, char[] value) | ||||
|         { | ||||
|             if (console is null) | ||||
|             { | ||||
|                 throw new ArgumentNullException(nameof(console)); | ||||
|             } | ||||
|  | ||||
|             if (value is null) | ||||
|             { | ||||
|                 throw new ArgumentNullException(nameof(value)); | ||||
|             } | ||||
|  | ||||
|             for (var index = 0; index < value.Length; index++) | ||||
|             { | ||||
|                 console.Write(value[index].ToString(provider)); | ||||
|             } | ||||
|  | ||||
|             console.WriteLine(); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified array of objects, | ||||
|         /// followed by the current line terminator, to the console | ||||
|         /// using the specified format information. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="format">A composite format string.</param> | ||||
|         /// <param name="args">An array of objects to write.</param> | ||||
|         public static void WriteLine(this IAnsiConsole console, string format, params object[] args) | ||||
|         { | ||||
|             WriteLine(console, CultureInfo.CurrentCulture, format, args); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes the text representation of the specified array of objects, | ||||
|         /// followed by the current line terminator, to the console | ||||
|         /// using the specified format information. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="provider">An object that supplies culture-specific formatting information.</param> | ||||
|         /// <param name="format">A composite format string.</param> | ||||
|         /// <param name="args">An array of objects to write.</param> | ||||
|         public static void WriteLine(this IAnsiConsole console, IFormatProvider provider, string format, params object[] args) | ||||
|         { | ||||
|             if (console is null) | ||||
|             { | ||||
|                 throw new ArgumentNullException(nameof(console)); | ||||
|             } | ||||
|  | ||||
|             WriteLine(console, string.Format(provider, format, args)); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -5,7 +5,7 @@ namespace Spectre.Console | ||||
|     /// <summary> | ||||
|     /// Contains extension methods for <see cref="IAnsiConsole"/>. | ||||
|     /// </summary> | ||||
|     public static class ConsoleExtensions | ||||
|     public static partial class ConsoleExtensions | ||||
|     { | ||||
|         /// <summary> | ||||
|         /// Resets both colors and style for the console. | ||||
| @@ -50,34 +50,5 @@ namespace Spectre.Console | ||||
|             console.Foreground = Color.Default; | ||||
|             console.Background = Color.Default; | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes an empty line to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         public static void WriteLine(this IAnsiConsole console) | ||||
|         { | ||||
|             if (console is null) | ||||
|             { | ||||
|                 throw new ArgumentNullException(nameof(console)); | ||||
|             } | ||||
|  | ||||
|             console.WriteLine(null); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes a line to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="console">The console to write to.</param> | ||||
|         /// <param name="content">The content to write.</param> | ||||
|         public static void WriteLine(this IAnsiConsole console, string content) | ||||
|         { | ||||
|             if (console is null) | ||||
|             { | ||||
|                 throw new ArgumentNullException(nameof(console)); | ||||
|             } | ||||
|  | ||||
|             console.WriteLine(content); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -40,13 +40,5 @@ namespace Spectre.Console | ||||
|         /// </summary> | ||||
|         /// <param name="text">The string to write.</param> | ||||
|         void Write(string text); | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Writes a string followed by a line terminator to the console. | ||||
|         /// </summary> | ||||
|         /// <param name="text"> | ||||
|         /// The string to write. If value is null, only the line terminator is written. | ||||
|         /// </param> | ||||
|         void WriteLine(string text); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -78,23 +78,5 @@ namespace Spectre.Console.Internal | ||||
|                 Foreground, | ||||
|                 Background)); | ||||
|         } | ||||
|  | ||||
|         public void WriteLine(string text) | ||||
|         { | ||||
|             if (text == null) | ||||
|             { | ||||
|                 _out.WriteLine(); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 _out.WriteLine( | ||||
|                     AnsiBuilder.GetAnsi( | ||||
|                         _system, | ||||
|                         text, | ||||
|                         Style, | ||||
|                         Foreground, | ||||
|                         Background)); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -105,17 +105,5 @@ namespace Spectre.Console.Internal | ||||
|         { | ||||
|             _out.Write(text); | ||||
|         } | ||||
|  | ||||
|         public void WriteLine(string text) | ||||
|         { | ||||
|             if (text == null) | ||||
|             { | ||||
|                 _out.WriteLine(); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 _out.WriteLine(text); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -12,6 +12,12 @@ | ||||
|     <Compile Update="Color.*.cs"> | ||||
|       <DependentUpon>Color.cs</DependentUpon> | ||||
|     </Compile> | ||||
|     <Compile Update="AnsiConsole.*.cs"> | ||||
|       <DependentUpon>AnsiConsole.cs</DependentUpon> | ||||
|     </Compile> | ||||
|     <Compile Update="ConsoleExtensions.*.cs"> | ||||
|       <DependentUpon>ConsoleExtensions.cs</DependentUpon> | ||||
|     </Compile> | ||||
|   </ItemGroup> | ||||
|  | ||||
|   <ItemGroup> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user