protected virtual void TraceOutput(bool isDirty)
        {
            if (!LogCondition)
            {
                return;
            }

            if (ConfigObject == null)
            {
                throw new ChoConfigurationConstructionException("configObject");
            }

            try
            {
                ChoStringMsgBuilder msg = new ChoStringMsgBuilder(String.Format("{0} {1}", isDirty ? "*" : " ", ChoObject.ToString(ConfigObject, ChoFormattableObject.ExtendedFormatName)));

                if (ConfigSection != null && MetaDataInfo != null)
                {
                    msg.AppendNewLine();
                    ChoStringMsgBuilder metaDataMsg = new ChoStringMsgBuilder(ChoObject.ToString(MetaDataInfo));
                    msg.Append(metaDataMsg.ToString());
                }

                Log(msg.ToString());
            }
            catch (Exception ex)
            {
                Trace.Write(ex);
                if (!Silent)
                {
                    throw;
                }
            }
        }
        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());
        }
Example #3
0
        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());
        }
Example #4
0
        private static void LoadObjectFormatter(ChoStringMsgBuilder formatMethodsMsg, Type type, ChoTypeObjectFormatInfo typeObjectFormatInfo)
        {
            try
            {
                MethodInfo isFormatMethodInfo = ChoType.GetMethod(type, typeof(ChoCanObjectFormattableAttribute), true);
                if (isFormatMethodInfo != null && isFormatMethodInfo.IsStatic)
                {
                    if (isFormatMethodInfo.ReturnParameter == null ||
                        isFormatMethodInfo.ReturnParameter.ParameterType != typeof(bool))
                    {
                        throw new ChoApplicationException(String.Format("{0}: Incorrect Check Format routine signature found. It should have bool return parameter.", type.Name));
                    }

                    ParameterInfo[] parameters = isFormatMethodInfo.GetParameters();
                    if (parameters == null ||
                        parameters.Length != 1 ||
                        parameters[0].ParameterType != typeof(object))
                    {
                        throw new ChoApplicationException(String.Format("{0}: Incorrect Check Format routine signature found. It should have one and only input object parameter.", type.Name));
                    }

                    MethodInfo formatMethodInfo = ChoType.GetMethod(type, typeof(ChoObjectFormatterAttribute), true);
                    if (formatMethodInfo != null)
                    {
                        parameters = formatMethodInfo.GetParameters();
                        if (formatMethodInfo.ReturnParameter == null ||
                            formatMethodInfo.ReturnParameter.ParameterType != typeof(string))
                        {
                            throw new ChoApplicationException(String.Format("{0}: Incorrect Format routine signature found. It should have string return parameter.", type.Name));
                        }

                        if (parameters == null ||
                            parameters.Length != 2 ||
                            parameters[0].ParameterType != typeof(object) ||
                            parameters[1].ParameterType != typeof(string))
                        {
                            throw new ChoApplicationException(String.Format("{0}: Incorrect Format routine signature found. It should have two input parameters of types [object, string].", type.Name));
                        }

                        typeObjectFormatInfo.CanFormat = isFormatMethodInfo.CreateDelegate <Func <object, bool> >();
                        typeObjectFormatInfo.Format    = formatMethodInfo.CreateDelegate <Func <object, string, string> >();

                        formatMethodsMsg.AppendFormatLine(type.FullName);
                    }
                }
            }
            catch (ChoFatalApplicationException)
            {
                throw;
            }
            catch (Exception ex)
            {
                formatMethodsMsg.AppendFormatLine("{0}: [{1}]", type.FullName, ex.Message);
            }

            if (typeObjectFormatInfo.IsValid())
            {
                _typeObjectsFormatInfo.Add(typeObjectFormatInfo);
            }
        }
        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());
        }
Example #6
0
        public new static string ToString()
        {
            ChoStringMsgBuilder msg = new ChoStringMsgBuilder("Available Properties");

            foreach (var propertyReplacer in ChoPropertyManagerSettings.Me.PropertyReplacers)
            {
                ChoStringMsgBuilder msg1 = new ChoStringMsgBuilder("{0} Property Replacer".FormatString(propertyReplacer.Name));

                bool found = false;
                if (propertyReplacer.AvailablePropeties != null)
                {
                    found = false;
                    foreach (KeyValuePair <string, string> keyValue in propertyReplacer.AvailablePropeties)
                    {
                        found = true;
                        msg1.AppendFormatLine("{0} - {1}".FormatString(keyValue.Key, keyValue.Value));
                    }
                }

                if (!found)
                {
                    msg1.AppendFormatLine("No properties found. / Failed to enumerate properties.");
                }

                msg.AppendFormatLine(msg1.ToString());
            }

            return(msg.ToString());
        }
Example #7
0
        public override string ToString()
        {
            ChoStringMsgBuilder msg = new ChoStringMsgBuilder("{0} Settings", GetType().Name);

            msg.AppendFormatLine("ApplicationId: {0}", ApplicationName);
            msg.AppendFormatLine("EventLogSourceName: {0}", EventLogSourceName);
            msg.AppendFormatLine("TurnOnConsoleOutput: {0}", TurnOnConsoleOutput);
            msg.AppendFormatLine("ApplicationConfigFilePath: {0}", ApplicationConfigFilePath);

            msg.AppendFormatLine(String.Empty);

            msg.AppendFormatLine("ApplicationNameWithoutExtension: {0}", ApplicationNameWithoutExtension);
            msg.AppendFormatLine("ApplicationLogDirectory: {0}", ApplicationLogDirectory);
            msg.AppendFormatLine("HostName: {0}", HostName);

            msg.AppendFormatLine(String.Empty);

            if (ApplicationBehaviourSettings != null)
            {
                msg.AppendFormatLine(ApplicationBehaviourSettings.ToString());
            }

            if (TrayApplicationBehaviourSettings != null)
            {
                msg.AppendFormatLine(TrayApplicationBehaviourSettings.ToString());
            }

            if (LogSettings != null)
            {
                msg.AppendFormatLine(LogSettings.ToString());
            }

            return(msg.ToString());
        }
Example #8
0
        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());
            }
        }
Example #9
0
        public override string ToString()
        {
            ChoStringMsgBuilder msg = new ChoStringMsgBuilder("APM Settings");

            msg.AppendFormatLine("MaxNoOfRetry: {0}", MaxNoOfRetry);
            msg.AppendFormatLine("SleepBetweenRetry: {0}", SleepBetweenRetry);

            return(msg.ToString());
        }
Example #10
0
        public override string ToString()
        {
            ChoStringMsgBuilder msg = new ChoStringMsgBuilder("Tray Application Font Settings");

            msg.AppendFormatLine("FontName: {0}", FontName);
            msg.AppendFormatLine("FontSize: {0}", FontSize);
            msg.AppendFormatLine("FontColor: {0}", FontColor);

            return(msg.ToString());
        }
Example #11
0
        public override string ToString()
        {
            ChoStringMsgBuilder msg = new ChoStringMsgBuilder("{0} Settings", GetType().Name);

            msg.AppendFormatLine("Account: {0}", Account);
            msg.AppendFormatLine("UserName: {0}", UserName);
            msg.AppendFormatLine("HelpText: {0}", HelpText);

            return(msg.ToString());
        }
Example #12
0
        public override string ToString()
        {
            ChoStringMsgBuilder msg = new ChoStringMsgBuilder("Console Settings");

            msg.AppendFormatLine("ForegroundColor: {0}", ForegroundColor);
            msg.AppendFormatLine("BackgroundColor: {0}", BackgroundColor);
            msg.AppendFormatLine("ConsoleMode: {0}", ConsoleMode);

            return(msg.ToString());
        }
Example #13
0
        public override string ToString()
        {
            ChoStringMsgBuilder msg = new ChoStringMsgBuilder("INI Settings");

            msg.AppendFormatLine("NameValueDelimiter: {0}", NameValueSeparator);
            msg.AppendFormatLine("CommantChars: {0}", CommentChars);
            msg.AppendFormatLine("IgnoreValueWhiteSpaces: {0}", IgnoreValueWhiteSpaces);

            return(msg.ToString());
        }
        public override string ToString()
        {
            ChoStringMsgBuilder msg = new ChoStringMsgBuilder("{0} Settings", GetType().Name);

            msg.AppendFormatLine("ConfigurationMetaDataFilePath: {0}", OverridenConfigurationMetaDataFilePath);
            msg.AppendFormatLine("PCMetaDataFilePath: {0}", OverridenPCMetaDataFilePath);
            msg.AppendFormatLine("ETLMetaDataFilePath: {0}", OverridenETLMetaDataFilePath);

            return(msg.ToString());
        }
        public override string ToString()
        {
            ChoStringMsgBuilder msg = new ChoStringMsgBuilder("{0} Settings", GetType().Name);

            msg.AppendFormatLine("Reset: {0}", ResetFailedCounterAfter);
            msg.AppendFormatLine("RebootMsg: {0}", RebootMessage.GetValue());
            msg.AppendFormatLine("Command: {0}", Command.GetValue());
            msg.AppendFormatLine("Actions: {0}", Actions.GetValue());

            return(msg.ToString());
        }
Example #16
0
        private static void LoadObjectParser(ChoStringMsgBuilder parseMethodsMsg, Type type, ChoTypeObjectParseInfo typeObjectParseInfo)
        {
            try
            {
                MethodInfo isParseMethodInfo = ChoType.GetMethod(type, typeof(ChoIsStringToObjectConvertable), true);
                if (isParseMethodInfo != null && isParseMethodInfo.IsStatic)
                {
                    if (isParseMethodInfo.ReturnParameter == null ||
                        isParseMethodInfo.ReturnParameter.ParameterType != typeof(bool))
                    {
                        throw new ChoApplicationException(String.Format("{0}: Incorrect Check Parse routine signature found. It should have bool return parameter.", type.Name));
                    }

                    ParameterInfo[] parameters = isParseMethodInfo.GetParameters();
                    if (parameters == null ||
                        parameters.Length != 1 ||
                        parameters[0].ParameterType != typeof(string))
                    {
                        throw new ChoApplicationException(String.Format("{0}: Incorrect Check Parse routine signature found. It should have one and only input string parameter.", type.Name));
                    }

                    MethodInfo parseMethodInfo = ChoType.GetMethod(type, typeof(ChoStringToObjectConverterAttribute), true);

                    if (parseMethodInfo != null)
                    {
                        parameters = parseMethodInfo.GetParameters();
                        if (parameters == null ||
                            parameters.Length != 1 ||
                            parameters[0].ParameterType != typeof(string))
                        {
                            throw new ChoApplicationException(String.Format("{0}: Incorrect Parse routine signature found. It should have one and only input string parameter.", type.Name));
                        }

                        typeObjectParseInfo.CheckParse = isParseMethodInfo.CreateDelegate <Func <string, bool> >();
                        typeObjectParseInfo.Parse      = parseMethodInfo.CreateDelegate <Func <string, object> >();

                        parseMethodsMsg.AppendFormatLine(type.FullName);
                    }
                }
            }
            catch (ChoFatalApplicationException)
            {
                throw;
            }
            catch (Exception ex)
            {
                parseMethodsMsg.AppendFormatLine("{0}: [{1}]", type.FullName, ex.Message);
            }

            if (typeObjectParseInfo.IsValid())
            {
                _typeObjectsParseInfo.Add(typeObjectParseInfo);
            }
        }
Example #17
0
        public override string ToString()
        {
            ChoStringMsgBuilder msg = new ChoStringMsgBuilder("Log Settings");

            msg.AppendFormatLine("TraceLevel: {0}", TraceLevel);
            msg.AppendFormatLine("LogFolder: {0}", LogFolder);
            msg.AppendFormatLine("LogFileName: {0}", LogFileName);
            msg.AppendFormatLine("LogTimeStampFormat: {0}", LogTimeStampFormat);

            return(msg.ToString());
        }
        public override string ToString()
        {
            ChoStringMsgBuilder msg = new ChoStringMsgBuilder("{0} Settings", GetType().Name);

            msg.AppendFormatLine("DelayedAutoStart: {0}", DelayedAutoStart);
            msg.AppendFormatLine("Description: {0}", Description);
            msg.AppendFormatLine("DisplayName: {0}", DisplayName);
            msg.AppendFormatLine("ServiceName: {0}", ServiceName);
            msg.AppendFormatLine("ServiceStartMode: {0}", ServiceStartMode);

            return(msg.ToString());
        }
Example #19
0
        public override string ToString()
        {
            ChoStringMsgBuilder msg = new ChoStringMsgBuilder("CommandLine Parser Settings");

            msg.AppendFormatLine("SwitchChars: {0}", new ChoArrayToStringFormatter().Format(SwitchChars, true));
            msg.AppendFormatLine("valueSeperators: {0}", new ChoArrayToStringFormatter().Format(ValueSeperators, true));
            msg.AppendFormatLine("UsageSwitches: {0}", new ChoArrayToStringFormatter().Format(UsageSwitches, true));
            msg.AppendFormatLine("FileArgSwitches: {0}", new ChoArrayToStringFormatter().Format(FileArgSwitches, true));
            msg.AppendFormatLine("IgnoreCase: {0}", IgnoreCase);

            return(msg.ToString());
        }
Example #20
0
        public override string ToString()
        {
            ChoStringMsgBuilder msg = new ChoStringMsgBuilder("Tray Application Context Menu Settings");

            msg.AppendFormatLine("DisplayAlwaysOnTopMenuItem: {0}", DisplayAlwaysOnTopMenuItem);
            msg.AppendFormatLine("DisplayRunAtSystemsStartupMenuItem: {0}", DisplayRunAtSystemsStartupMenuItem);
            msg.AppendFormatLine("DisplayShowInTaskbarMenuItem: {0}", DisplayShowInTaskbarMenuItem);
            msg.AppendFormatLine("DisplayAboutMenuItem: {0}", DisplayAboutMenuItem);
            msg.AppendFormatLine("DisplayHelpMenuItem: {0}", DisplayHelpMenuItem);
            msg.AppendFormatLine("DisplayExitMenuItem: {0}", DisplayExitMenuItem);

            return(msg.ToString());
        }
Example #21
0
        public override string ToString()
        {
            ChoStringMsgBuilder msg = new ChoStringMsgBuilder("Application Behaviour Settings");

            msg.AppendFormatLine("HideWindow: {0}", HideWindow);
            msg.AppendFormatLine("BringWindowToTop: {0}", BringWindowToTop);
            msg.AppendFormatLine("AlwaysOnTop: {0}", AlwaysOnTop);
            msg.AppendFormatLine("RunAtStartup: {0}", RunAtStartup);
            msg.AppendFormatLine("RunOnceAtStartup: {0}", RunOnceAtStartup);
            msg.AppendFormatLine("SingleInstanceApp: {0}", SingleInstanceApp);
            msg.AppendFormatLine("ActivateFirstInstance: {0}", ActivateFirstInstance);

            return(msg.ToString());
        }
Example #22
0
        public override string ToString()
        {
            ChoStringMsgBuilder msg = new ChoStringMsgBuilder(GetType().Name);

            msg.AppendFormatLine("ErrorCode: {0}".FormatString(ErrorCode));
            msg.AppendFormatLine("ErrorMsg: {0}".FormatString(ErrorMsg));
            msg.AppendFormatLine("Exception: ");
            if (Exception != null)
            {
                msg.AppendFormatLine(Exception.ToString().Indent());
            }

            return(msg.ToString());
        }
Example #23
0
        public override string ToString()
        {
            ChoStringMsgBuilder msg = new ChoStringMsgBuilder("Tray Application Behaviour Settings");

            msg.AppendFormatLine("TurnOn: {0}", TurnOn);
            msg.AppendFormatLine("HideMainWindowAtStartup: {0}", HideMainWindowAtStartup);
            msg.AppendFormatLine("HideTrayIconWhenMainWindowShown: {0}", HideTrayIconWhenMainWindowShown);
            msg.AppendFormatLine("TooltipText: {0}", TooltipText);
            msg.AppendFormatLine("BalloonTipText: {0}", BalloonTipText);
            msg.AppendFormatLine("TrayAppTurnOnMode: {0}", TrayAppTurnOnMode);
            msg.AppendFormatLine("ShowInTaskbar: {0}", ShowInTaskbar);
            msg.AppendFormatLine("TrayIcon: {0}", TrayIcon);

            return(msg.ToString());
        }
Example #24
0
        internal static void Initialize()
        {
            //ChoStreamProfile.Clean(ChoReservedDirectoryName.Others, ChoType.GetLogFileName(typeof(ChoTypesManager)));

            StringBuilder topMsg = new StringBuilder();

            ChoStringMsgBuilder parseMethodsMsg  = new ChoStringMsgBuilder("Below are the loaded parse methods");
            ChoStringMsgBuilder formatMethodsMsg = new ChoStringMsgBuilder("Below are the loaded format methods");
            ChoStringMsgBuilder msg = new ChoStringMsgBuilder("Below are the loaded type objects");

            foreach (Type type in ChoType.GetTypes(typeof(ChoStringObjectFormattableAttribute)))
            {
                if (ChoTypesManagerSettings.IsExcludedType(type))
                {
                    continue;
                }

                ChoTypeObjectParseInfo  typeObjectParseInfo  = new ChoTypeObjectParseInfo();
                ChoTypeObjectFormatInfo typeObjectFormatInfo = new ChoTypeObjectFormatInfo();
                try
                {
                    //typeObjectFormatInfo.TypeObject = typeObjectParseInfo.TypeObject = ChoObject.CreateInstance(type);
                    msg.AppendFormatLine(type.FullName);
                }
                catch (ChoFatalApplicationException)
                {
                    throw;
                }
                catch (Exception ex)
                {
                    msg.AppendFormatLine("{0}: [{1}]", type.FullName, ex.Message);
                }

                LoadObjectParser(parseMethodsMsg, type, typeObjectParseInfo);
                LoadObjectFormatter(formatMethodsMsg, type, typeObjectFormatInfo);
            }

            _typeObjectsParseInfoArr  = TypeObjectsParseInfo.Values.ToArray();
            _typeObjectsFormatInfoArr = TypeObjectsFormatInfo.Values.ToArray();

            //_typeObjectsParseInfo.Clear();
            //_typeObjectsFormatInfo.Clear();

            topMsg.Append(parseMethodsMsg.ToString() + Environment.NewLine + Environment.NewLine);
            topMsg.Append(formatMethodsMsg.ToString() + Environment.NewLine + Environment.NewLine);
            topMsg.Append(msg.ToString() + Environment.NewLine + Environment.NewLine);
            _helpText = topMsg.ToString();
        }
Example #25
0
        private bool IsExists(ArrayList list, object element)
        {
            foreach (object item in list)
            {
                if (item.Equals(element))
                {
                    ChoStringMsgBuilder msg = new ChoStringMsgBuilder("Duplicate entry found");
                    msg.AppendFormatLine(ChoObject.ToString(element));

                    ChoTrace.Debug(msg.ToString());
                    return(true);
                }
            }

            return(false);
        }
Example #26
0
        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());
        }
Example #27
0
        public static new string ToString()
        {
            ChoStringMsgBuilder msg = new ChoStringMsgBuilder("{0} Settings", typeof(ChoApplication).Name);

            msg.AppendFormatLine("AppEnvironment: {0}", AppEnvironment);
            msg.AppendFormatLine("ApplicationMode: {0}", ApplicationMode);
            msg.AppendFormatLine("AppDomainName: {0}", AppDomainName);
            msg.AppendFormatLine("ProcessId: {0}", ProcessId);
            msg.AppendFormatLine("ProcessFilePath: {0}", ProcessFilePath);
            msg.AppendFormatLine("UnmanagedCodePermissionAvailable: {0}", UnmanagedCodePermissionAvailable);
            msg.AppendFormatLine("EntryAssemblyLocation: {0}", EntryAssemblyLocation);
            msg.AppendFormatLine("EntryAssemblyFileName: {0}", EntryAssemblyFileName);
            msg.AppendFormatLine("ApplicationBaseDirectory: {0}", ApplicationBaseDirectory);
            msg.AppendFormatLine("ApplicationConfigDirectory: {0}", ApplicationConfigDirectory);
            msg.AppendFormatLine("ApplicationLogDirectory: {0}", ApplicationLogDirectory);

            return(msg.ToString());
        }
Example #28
0
        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));
                }
            }
        }
Example #29
0
        public string GetHelpText()
        {
            StringBuilder msg = new StringBuilder("List of available properties" + Environment.NewLine);

            msg.AppendLine();
            msg.AppendLine("@this - Context info will be replaced.");
            msg.AppendLine();

            foreach (IChoPropertyReplacer propertyReplacer in PropertyReplacers)
            {
                if (propertyReplacer.AvailablePropeties == null)
                {
                    continue;
                }

                ChoStringMsgBuilder msg1 = new ChoStringMsgBuilder(propertyReplacer.Name);

                foreach (KeyValuePair <string, string> keyValue in propertyReplacer.AvailablePropeties)
                {
                    msg1.AppendFormatLine("{0} - {1}", keyValue.Key, keyValue.Value);
                }

                msg.AppendLine(msg1.ToString());
            }

            ChoStringMsgBuilder msg2 = new ChoStringMsgBuilder("Application Propeties");

            foreach (Dictionary <string, string> dict in ChoApplication.GetPropertyHelpTexts())
            {
                if (dict == null)
                {
                    continue;
                }

                foreach (KeyValuePair <string, string> keyValue in dict)
                {
                    msg2.AppendFormatLine("{0} - {1}", keyValue.Key, keyValue.Value);
                }
            }
            msg.AppendLine(msg2.ToString());

            return(msg.ToString());
        }
        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());
            }
        }