public static String AsMessageOnly(this Exception exception) { var result = String.Empty; if (exception != null) { var message = new DelimitedStringBuilder(); message.Add(exception.Message); if (exception.InnerException != null) { message.Add(exception.InnerException.AsMessageOnly()); } result = message.ToDelimitedString(" "); } return(result); }
private Tuple <String, String> ExceptionMessages(Exception exception) { DelimitedStringBuilder exceptionMessages = new DelimitedStringBuilder(); DelimitedStringBuilder exceptionStackTraces = new DelimitedStringBuilder(); while (exception != null) { exceptionMessages.Add(exception.Message); exceptionStackTraces.Add(exception.StackTrace); exception = exception.InnerException; } return(new Tuple <String, String>(exceptionMessages.ToDelimitedString("<br/>"), exceptionStackTraces.ToDelimitedString("<br/>"))); }
public override String ToString() { if (InternalValue.Count == 0) { return(String.Empty); } DelimitedStringBuilder builder = new DelimitedStringBuilder(InternalValue.Count); foreach (KeyValuePair <String, String> keyValue in InternalValue) { builder.Add(Pattern.FormatX(keyValue.Key, KeyValueDelimiter, keyValue.Value)); } return(builder.ToDelimitedString(PairDelimiter)); }
public static String ToCsv(this IEnumerable <String> items) { if (items.IsEmpty()) { return(String.Empty); } DelimitedStringBuilder csvBuilder = new DelimitedStringBuilder(); foreach (String item in items) { csvBuilder.Add(ToCsvValue(item)); } return(csvBuilder.ToDelimitedString(ValueLib.Comma.CharValue)); }
public static String ToDescription(this Object value) { String result; if (value == null) { result = ValueLib.NullDescription.StringValue; } else if (value is DBNull) { result = ValueLib.DbNullDescription.StringValue; } else if (IsStateEmpty(value as IStateEmpty)) { result = ValueLib.EmptyDescription.StringValue; } else if (value is IStateValid && !((IStateValid)value).IsValid) { result = ValueLib.InvalidDescription.StringValue; } else if (value is IStateAged && !((IStateAged)value).IsAged) { result = ValueLib.NotAgedDescription.StringValue; } else if (value is TimeSpan) { result = TimeSpanArticulator.Articulate((TimeSpan)value); } else if (value is Type) { result = ((Type)value).Name; } else if (value is IDictionary) { IDictionary dictionary = value as IDictionary; DelimitedStringBuilder innerResult = new DelimitedStringBuilder(dictionary.Count); foreach (Object key in dictionary.Keys) { innerResult.Add("{0}{1}{2}", key.ToDescription(), ValueLib.KeyValueDelimiter.StringValue, dictionary[key].ToDescription()); } result = innerResult.ToDelimitedString(ValueLib.ValueMark.CharValue); } else { result = value.ToString(); } return(result); }
public static String ToLogString(this Exception exception) { var result = String.Empty; if (exception != null) { var message = new DelimitedStringBuilder(); message.Add("Exception:{0}", exception.GetType().Name); message.Add("Message:{0}", exception.Message); if (exception.Source != null) { message.Add("Source:" + exception.Source.Replace(ValueLib.EndOfLine.StringValue, ValueLib.Space.StringValue)); } if (exception.Data.Count > 0) { message.Add("Addition Information:"); message.Add(exception.Data.ToDescription()); } if (!exception.HelpLink.IsEmpty()) { message.Add("Help Link:" + exception.HelpLink); } if (exception.StackTrace != null) { message.Add("Stack Trace:" + exception.StackTrace); } if (exception.InnerException != null) { message.Add("Inner " + exception.InnerException.ToLogString()); } result = message.ToDelimitedString(ValueLib.Comma.CharValue); } return(result); }