private static string DumpObject(object argument) { var objtype = argument.GetType(); if (objtype == typeof(string) || objtype.IsPrimitive || !objtype.IsClass || objtype.BaseType == typeof(MulticastDelegate) || !objtype.IsSerializable || objtype.Namespace.Contains("Castle.")) { if (objtype == typeof(string)) { return(string.Format("\"{0}\"", argument)); } if (objtype == typeof(char)) { return(string.Format("\'{0}\'", argument)); } return(argument.ToString()); } return(DPHelper.CreateObjectLogString(argument)); }
public static string CreateInvocationCompleteString(IInvocation invocation) { var sb = new StringBuilder(); if (null == invocation.ReturnValue) { return(sb.AppendFormat("Returned null").ToString()); } var retType = invocation.ReturnValue.GetType(); if (retType == typeof(void)) { sb.AppendFormat("Returned void."); } else if (retType == typeof(string)) { sb.AppendFormat("Returned string [\"{0}\"].", invocation.ReturnValue); } else if (retType == typeof(char)) { sb.AppendFormat("Returned char [\'{0}\'].", invocation.ReturnValue); } else if (retType.IsPrimitive || !retType.IsClass) { sb.AppendFormat("Returned {0} [\'{1}\'].", retType, invocation.ReturnValue); } else { sb.AppendFormat( "Returned {0} = [{1}]", retType, DPHelper.CreateObjectLogString(invocation.ReturnValue)); } return(sb.ToString()); }