mirror of
				https://github.com/nsnail/spectre.console.git
				synced 2025-11-04 10:35:27 +08:00 
			
		
		
		
	Adds overloads for MarkUp methods without args
These methods don't require a string.format call so we'll directly call the Render method without a call to string.format. Added bonus of a a couple fewer allocations too.
This commit is contained in:
		
				
					committed by
					
						
						Patrik Svensson
					
				
			
			
				
	
			
			
			
						parent
						
							da9c6ee4c2
						
					
				
				
					commit
					e4dda283bb
				
			@@ -28,7 +28,17 @@ namespace Spectre.Console
 | 
			
		||||
        /// <param name="args">An array of objects to write.</param>
 | 
			
		||||
        public static void Markup(this IAnsiConsole console, IFormatProvider provider, string format, params object[] args)
 | 
			
		||||
        {
 | 
			
		||||
            console.Render(MarkupParser.Parse(string.Format(provider, format, args)));
 | 
			
		||||
            Markup(console, string.Format(provider, format, args));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Writes the specified markup to the console.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="console">The console to write to.</param>
 | 
			
		||||
        /// <param name="value">The value to write.</param>
 | 
			
		||||
        public static void Markup(this IAnsiConsole console, string value)
 | 
			
		||||
        {
 | 
			
		||||
            console.Render(MarkupParser.Parse(value));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
@@ -42,6 +52,16 @@ namespace Spectre.Console
 | 
			
		||||
            MarkupLine(console, CultureInfo.CurrentCulture, format, args);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Writes the specified markup, 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 MarkupLine(this IAnsiConsole console, string value)
 | 
			
		||||
        {
 | 
			
		||||
            Markup(console, value + Environment.NewLine);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Writes the specified markup, followed by the current line terminator, to the console.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
@@ -54,4 +74,4 @@ namespace Spectre.Console
 | 
			
		||||
            Markup(console, provider, format + Environment.NewLine, args);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user