public string Format(object value, bool indentMsg) { ChoStringMsgBuilder msg = new ChoStringMsgBuilder(); if (((Hashtable)value).Count == 0) { msg.Append(ChoString.EmptyString); } else { msg.AppendLine(); if (indentMsg) { msg.AppendLine("["); foreach (object token in ((Hashtable)value).Values) { msg.AppendFormatLine(ChoObject.ToString(token)); } msg.Append("]"); } else { foreach (object token in ((Hashtable)value).Values) { msg.AppendLine(ChoObject.ToString(token)); } } } return(msg.ToString()); }
public string Format(object value, bool indentMsg) { ChoStringMsgBuilder msg = new ChoStringMsgBuilder(); if (((IDictionary)value).Count == 0) { msg.Append(ChoString.EmptyString); } else { msg.AppendLine(); if (indentMsg) { msg.AppendLine("["); foreach (object token in ((IDictionary)value).Keys) { msg.AppendFormatLine(String.Format("{0} - {1}", ChoObject.ToString(token), ChoObject.ToString(((IDictionary)value)[token]))); } msg.Append("]"); } else { foreach (object token in ((Hashtable)value).Keys) { msg.AppendLine(token.ToString()); } } } return(msg.ToString()); }
public string Format(object value, bool indentMsg) { ChoStringMsgBuilder msg = new ChoStringMsgBuilder(); if (((Array)value).Length == 0) { msg.AppendLine(ChoString.EmptyString); } else { if (indentMsg) { msg.AppendLine("["); foreach (object token in (Array)value) { msg.AppendFormatLine(ChoObject.ToString(token)); } msg.AppendLine("]"); } else { foreach (object token in (Array)value) { msg.AppendLine(ChoObject.ToString(token)); } } } return(msg.ToString()); }
private static void ReportMemoryLeak(IChoDisposable target) { return; ChoGuard.ArgumentNotNull(target, "Target"); if (target.IsDisposed) { return; } ChoDisposableObjectAttribute disposableObjectAttribute = ChoType.GetAttribute <ChoDisposableObjectAttribute>(target.GetType()); if (disposableObjectAttribute == null || !disposableObjectAttribute.ContainsUnmanagedResources) { return; } AppDomain currentDomain = AppDomain.CurrentDomain; if (!currentDomain.IsFinalizingForUnload() && !Environment.HasShutdownStarted) { ChoStringMsgBuilder msg = new ChoStringMsgBuilder(target.GetType().FullName); //Console.WriteLine("Object allocated at:"); for (int index = 0; index < target.ObjectCreationStackTrace.FrameCount; ++index) { StackFrame frame = target.ObjectCreationStackTrace.GetFrame(index); msg.AppendLine(" {0}", frame.ToString()); } //ChoProfile.DefaultContext.AppendLine(msg.ToString()); } }
private static void GetErrorMsgs(object target, ChoStringMsgBuilder msg) { MemberInfo[] memberInfos = ChoType.GetMembers(target.GetType()); //, typeof(ChoMemberInfoAttribute)); List <string> errMsgs = new List <string>(); string errMsg; if (memberInfos != null && memberInfos.Length >= 0) { foreach (MemberInfo memberInfo in memberInfos) { errMsg = ChoConfigurationObjectErrorManagerService.GetObjectMemberError(target, memberInfo.Name); if (errMsg != null) { errMsgs.Add(String.Format("{0}: {1}", memberInfo.Name, errMsg)); } } } if (errMsgs.Count > 0) { msg.AppendLine(); ChoStringMsgBuilder errReport = new ChoStringMsgBuilder("Following errors occurred while construction"); foreach (string errMsg1 in errMsgs) { errReport.AppendFormatLine(errMsg1); } msg.AppendLine(errReport.ToString().Indent(1)); } else { errMsg = ChoConfigurationObjectErrorManagerService.GetObjectError(target); if (!errMsg.IsNullOrEmpty()) { msg.AppendLine(); ChoStringMsgBuilder errReport = new ChoStringMsgBuilder("Following errors occurred while construction"); errReport.AppendFormatLine(errMsg); msg.AppendLine(errReport.ToString().Indent(1)); } } }
public string Format(object value) { if (!CanFormat(value.GetType())) { return(value.ToString()); } else { ChoStringMsgBuilder msg = new ChoStringMsgBuilder(); msg.AppendLine(); msg.AppendLine("["); foreach (string token in value as string[]) { msg.AppendFormatLine(token); } msg.AppendLine("]"); return(msg.ToString()); } }
public string Format(object value, bool indentMsg) { ChoStringMsgBuilder msg = new ChoStringMsgBuilder(); msg.AppendLine(); if (indentMsg) { msg.AppendLine("["); foreach (string token in value as string[]) { msg.AppendFormatLine(token); } msg.AppendLine("]"); } else { foreach (string token in value as string[]) { msg.AppendLine(token); } } return(msg.ToString()); }
public new string ToString() { ChoStringMsgBuilder msg = new ChoStringMsgBuilder("{0} ChoThreadPool Settings", Name); msg.AppendNewLine(); msg.AppendLine("MaxWorkerThreads: {0}", _maxWorkerThreads); msg.AppendLine("MinWorkerThreads: {0}", _minWorkerThreads); msg.AppendLine("IdleTimeout: {0}", _idleTimeout); msg.AppendLine("DisposeOfStateObjects: {0}", _disposeOfStateObjects); msg.AppendLine("UseCallerContext: {0}", _useCallerContext); msg.AppendLine("PostExecuteWorkItemCallback: {0}", _postExecuteWorkItemCallback); msg.AppendLine("CallToPostExecute: {0}", _callToPostExecute); msg.AppendLine("BlockIfPoolBusy: {0}", _blockIfPoolBusy); msg.AppendNewLine(); return(msg.ToString()); }
public static string ToString(object configObject) { if (configObject == null) { return(String.Empty); } string configObjectString = ChoObject.ToString(configObject); ChoConfigurationElementMapAttribute configurationElementMap = ChoType.GetAttribute(configObject.GetType(), typeof(ChoConfigurationElementMapAttribute)) as ChoConfigurationElementMapAttribute; if (configurationElementMap == null) { return(configObjectString); } else if (configObjectString == configObject.GetType().FullName) { ChoStringMsgBuilder msg = new ChoStringMsgBuilder(configurationElementMap.Description); MemberInfo[] memberInfos = ChoType.GetMembers(configObject.GetType(), typeof(ChoMemberInfoAttribute)); if (memberInfos == null || memberInfos.Length == 0) { msg.AppendLine(ChoStringMsgBuilder.Empty); } else { string errMsg; foreach (MemberInfo memberInfo in memberInfos) { errMsg = ChoType.GetAttributeNameParameterValue(configObject.GetType(), memberInfo.Name, typeof(ChoMemberInfoAttribute), "ErrMsg") as string; if (errMsg == null) { msg.AppendFormatLine("{0}: {1}", memberInfo.Name, ChoType.GetMemberValue(configObject, memberInfo.Name)); } else { msg.AppendFormatLine("{0}: {1} [ERROR: {2}]", memberInfo.Name, ChoType.GetMemberValue(configObject, memberInfo.Name), errMsg); } } } msg.AppendNewLine(); return(msg.ToString()); } else { StringBuilder msg = new StringBuilder(configObjectString); MemberInfo[] memberInfos = ChoType.GetMembers(configObject.GetType(), typeof(ChoMemberInfoAttribute)); List <string> errMsgs = new List <string>(); if (memberInfos != null && memberInfos.Length >= 0) { string errMsg; foreach (MemberInfo memberInfo in memberInfos) { errMsg = ChoType.GetAttributeNameParameterValue(configObject.GetType(), memberInfo.Name, typeof(ChoMemberInfoAttribute), "ErrMsg") as string; if (errMsg != null) { errMsgs.Add(String.Format("{0}: {1}", memberInfo.Name, errMsg)); } } } if (errMsgs.Count > 0) { ChoStringMsgBuilder errReport = new ChoStringMsgBuilder("Following errors produced while construction"); foreach (string errMsg in errMsgs) { errReport.AppendFormatLine(errMsg); } msg.AppendLine(errReport.ToString()); } return(msg.ToString()); } }