private static StringBuilder GetTraceMessage(string exceptionMessage, string traceMessageStart) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine(string.Concat(traceMessageStart, "\nMessage = ", exceptionMessage)); stringBuilder.AppendLine("Stack Trace"); stringBuilder.AppendLine(StackTraceHelper.GetStrackTrace(2)); return(stringBuilder); }
public static void ThrowIfNull(this object instance, string parameterName, string message, object[] args) { string empty; if (instance != null) { return; } else { if (string.IsNullOrEmpty(message)) { empty = string.Empty; } else { empty = string.Format(CultureInfo.CurrentCulture, message, args); } string str = empty; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("Throwing null argument exception. \nCause"); object[] objArray = new object[2]; objArray[0] = parameterName; objArray[1] = str; stringBuilder.AppendLine(string.Format(CultureInfo.CurrentCulture, Resources.NullParameter, objArray)); stringBuilder.AppendLine("Stack Trace"); stringBuilder.AppendLine(StackTraceHelper.GetStrackTrace(2)); TraceHelper.Current.DebugMessage(stringBuilder.ToString()); if (!string.IsNullOrEmpty(message)) { throw new ArgumentNullException(parameterName, str); } else { throw new ArgumentNullException(parameterName); } } }