Dumps the specified input to the console, decorating the input with a custom function
and colorizing per the specified color.
Namespace: CleanCode.DiagnosticsAssembly: CleanCode (in CleanCode.dll) Version: 1.2.3.0 (1.2.03)
Syntax
public static IEnumerable<T> Dump<T>( this IEnumerable<T> input, Func<T, string> toString, ConsoleColor textColor )
Parameters
- input
- Type: System.Collections.Generic IEnumerable T
The input.
- toString
- Type: System Func T, String
Anonymous method to convert input elements to strings.
- textColor
- Type: System ConsoleColor
Color of the text.
Type Parameters
- T
- The type of the elements of source.
Return Value
Input unchanged.Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerable T . When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).Examples
return words .Dump(w => "ORIGINAL: " + w, ConsoleColor.Yellow) .Select(word => word.Trim()) .Dump(w => "TRIMMED: " + w, ConsoleColor.Yellow) .Select(word => word.ToLower()) .Dump(w => "LOWERCASE: " + w, ConsoleColor.Green) .Where(word => word.StartsWith("k")) .Dump(w => "FILTERED to 'K': " + w, ConsoleColor.Red) .OrderBy(word => word) .Dump(w => "SORTED: " + w, ConsoleColor.Blue);
See Also