iox/PrettyPrint.cs
/// <summary>
/// Pretty format the specified object.
/// </summary>
/// <returns>The format.</returns>
/// <param name="obj">Object.</param>
Pretty format the specified object.
Pretty format the specified object .
public static string Format (IodineObject obj) {
			var type = obj.GetType ();
			if (obj.Base?.GetType ().Name == "IodineException") {
				type = obj.Base.GetType ();
			}
			ANSIColor color;
			ColorScheme.TryGetValue (type, out color);
			if (Formatters.ContainsKey (type)) {
				return ANSI.Sanitize (Formatters [type] (obj, color?.fg ?? string.Empty, $"{ANSI.ESC}[0m"));
			}
			Logger.Warn ($"No formatter for type '{type.Name}'");
			return ANSI.Sanitize ($"{color ?? White}{obj}");
		}
public static string Format ( IodineObject obj ) { var type = obj . GetType ( ) ; if ( obj . Base ? . GetType ( ) . Name == " " ) { type = obj . Base . GetType ( ) ; } ANSIColor color ; ColorScheme . TryGetValue ( type , out color ) ; if ( Formatters . ContainsKey ( type ) ) { return ANSI . Sanitize ( Formatters [ type ] ( obj , color ? . fg ?? string . Empty , $" { ANSI . ESC } [0m " ) ) ; } Logger . Warn ( $" No formatter for type ' { type . Name } ' " ) ; return ANSI . Sanitize ( $" { color ?? White } { obj } " ) ; }
Pretty format the specified object.
Pretty format the specified object .
// Get the type of the object // Exceptions are special snowflakes // Try getting the formatting color // Test if the object has a custom formatter // Invoke the formatter // Oops, there's no custom formatter for that object
None
obj
IodineObject
None