using System; using System.Text; using System.Text.RegularExpressions; using HeuristicLab.Persistence.Auxiliary; namespace HeuristicLab.DebugEngine { public static class Utils { public static string TypeName(object obj) { if (obj == null) return "null"; return TypeNameParser.Parse(obj.GetType().ToString()).GetTypeNameInCode(true); } public static string Wrap(string text, int columns) { StringBuilder sb = new StringBuilder(); Regex whitespace = new Regex("\\s"); int lineLength = 0; foreach (var word in whitespace.Split(text)) { if (lineLength + word.Length < columns) { if (lineLength > 0) { sb.Append(' '); lineLength++; } sb.Append(word); lineLength += word.Length; } else { sb.Append(Environment.NewLine).Append(word); lineLength = word.Length; } } return sb.ToString(); } } }