Esempio n. 1
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);
            }
        }
Esempio n. 2
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());
        }
Esempio n. 3
0
        public override string ToString()
        {
            ChoStringMsgBuilder msg = new ChoStringMsgBuilder("APM Settings");

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

            return(msg.ToString());
        }
Esempio n. 4
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());
        }
Esempio n. 6
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());
        }
Esempio n. 7
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());
        }
Esempio n. 8
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());
        }
Esempio n. 9
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("Reset: {0}", ResetFailedCounterAfter);
            msg.AppendFormatLine("RebootMsg: {0}", RebootMessage.GetValue());
            msg.AppendFormatLine("Command: {0}", Command.GetValue());
            msg.AppendFormatLine("Actions: {0}", Actions.GetValue());

            return(msg.ToString());
        }
Esempio n. 11
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);
            }
        }
Esempio n. 12
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());
        }
        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());
        }
Esempio n. 14
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());
        }
Esempio n. 15
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();
        }
Esempio n. 16
0
        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());
        }
        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());
        }
Esempio n. 18
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());
        }
Esempio n. 19
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);
            msg.AppendFormatLine("ShowEnvironmentSelectionWnd: {0}", ShowEnvironmentSelectionWnd);

            return(msg.ToString());
        }
Esempio n. 20
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());
        }
Esempio n. 21
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);
        }
Esempio n. 22
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());
        }
Esempio n. 23
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));
                }
            }
        }
Esempio n. 24
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());
        }
Esempio n. 25
0
        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());
            }
        }
Esempio n. 26
0
        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());
        }
Esempio n. 27
0
        public override string ToString()
        {
            ChoStringMsgBuilder msg = new ChoStringMsgBuilder("{0} Settings", GetType().Name);

            msg.AppendFormatLine("AppEnvironment: {0}", AppEnvironment);
            msg.AppendFormatLine("SharedEnvironmentConfigFilePath: {0}", SharedEnvironmentConfigFilePath);
            msg.AppendFormatLine("AppDomainName: {0}", AppDomainName);
            msg.AppendFormatLine("ProcessId: {0}", ProcessId);
            msg.AppendFormatLine("ProcessFilePath: {0}", ProcessFilePath);
            msg.AppendFormatLine("UnmanagedCodePermissionAvailable: {0}", UnmanagedCodePermissionAvailable);
            msg.AppendFormatLine("ApplicationName: {0}", ApplicationName);
            msg.AppendFormatLine("ApplicationNameWithoutExtension: {0}", ApplicationNameWithoutExtension);
            msg.AppendFormatLine("EntryAssemblyLocation: {0}", EntryAssemblyLocation);
            msg.AppendFormatLine("EntryAssemblyFileName: {0}", EntryAssemblyFileName);
            msg.AppendFormatLine("ApplicationConfigFilePath: {0}", ApplicationConfigFilePath);
            msg.AppendFormatLine("ApplicationBaseDirectory: {0}", ApplicationBaseDirectory);
            msg.AppendFormatLine("ApplicationLogDirectory: {0}", ApplicationLogDirectory);
            msg.AppendFormatLine("HostName: {0}", HostName);

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

            msg.AppendFormatLine("Description: {0}", Description);
            msg.AppendFormatLine("ServiceName: {0}", ServiceName);
            msg.AppendFormatLine("ServiceStartMode: {0}", ServiceStartMode);
            msg.AppendFormatLine("Depends: {0}", Depends);
            msg.AppendFormatLine("Account: {0}", Account);
            msg.AppendFormatLine("UserName: {0}", UserName);
            msg.AppendFormatLine("Timeout: {0}", Timeout);

            msg.AppendFormatLine("CanHandlePowerEvent: {0}", CanHandlePowerEvent);
            msg.AppendFormatLine("CanHandleSessionChangeEvent: {0}", CanHandleSessionChangeEvent);
            msg.AppendFormatLine("CanPauseAndContinue: {0}", CanPauseAndContinue);
            msg.AppendFormatLine("CanShutdown: {0}", CanShutdown);
            msg.AppendFormatLine("CanStop: {0}", CanStop);
            msg.AppendFormatLine("AutoLog: {0}", AutoLog);
            msg.AppendFormatLine("ExitCode: {0}", ExitCode);

            msg.AppendFormatLine(RecoverySettings.ToString().Indent());

            return(msg.ToString());
        }
Esempio n. 29
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());
        }
Esempio n. 30
0
        private static string ToString(object target, bool collectErrMsgs, ChoMemberFormatterAttribute memberFormaterAttribute1,
                                       ChoMemberItemFormatterAttribute memberItemFormaterAttribute1, BindingFlags bindingFlags)
        {
            if (target == null)
            {
                return(String.Empty);
            }

            if (memberFormaterAttribute1 != null && memberFormaterAttribute1.CanFormat())
            {
                if (target.GetType().IsSimple())
                {
                    return(memberFormaterAttribute1.FormatObject(target));
                }
                else
                {
                    ChoStringMsgBuilder msg = new ChoStringMsgBuilder();
                    //msg.AppendLineIfNoNL(memberFormaterAttribute1.FormatObject(target));
                    msg.Append(memberFormaterAttribute1.FormatObject(target));
                    //msg.AppendNewLine();
                    if (collectErrMsgs)
                    {
                        GetErrorMsgs(target, msg);
                    }
                    return(msg.ToString());
                }
            }
            else if (target.GetType().IsSimple() || target.GetType().IsMethodImplemented("ToString"))
            {
                return(target.ToString());
            }
            else if (target is Delegate)
            {
                return(String.Format("{0}.{1}", ((Delegate)target).Target == null ? "[Static]" : ((Delegate)target).Target.GetType().FullName, ((Delegate)target).Method.Name));
            }
            else if (target is IEnumerable)
            {
                StringBuilder arrMsg = new StringBuilder();

                int count = 0;
                foreach (object item in (IEnumerable)target)
                {
                    count++;
                    arrMsg.AppendFormat("{0}{1}", ToString(item, collectErrMsgs, memberItemFormaterAttribute1, null, bindingFlags), Environment.NewLine);
                }

                return("[Count: {0}]{1}{2}".FormatString(count, Environment.NewLine, arrMsg.ToString()));
            }

            else
            {
                bool   foundMatchingFormatter = false;
                string retValue = ChoObject.Format(target, null, out foundMatchingFormatter);

                if (foundMatchingFormatter)
                {
                    if (target.GetType().IsSimple())
                    {
                        return(retValue);
                    }
                    else
                    {
                        ChoStringMsgBuilder msg = new ChoStringMsgBuilder();
                        msg.AppendFormat(retValue);
                        msg.AppendNewLine();
                        if (collectErrMsgs)
                        {
                            GetErrorMsgs(target, msg);
                        }
                        return(msg.ToString());
                    }
                }
                else
                {
                    ChoInterceptableObject interceptableObject = null;
                    try
                    {
                        if (ChoType.IsRealProxyObject(target.GetType()))
                        {
                            interceptableObject = ChoInterceptableObject.Silentable(target as ChoInterceptableObject);
                        }

                        ChoTypeFormatterAttribute objectFormatter = ChoType.GetAttribute(target.GetType(), typeof(ChoTypeFormatterAttribute)) as ChoTypeFormatterAttribute;
                        if (objectFormatter == null)
                        {
                            ChoStringMsgBuilder msg = new ChoStringMsgBuilder(memberFormaterAttribute1 == null ? String.Format("{0} State", target.GetType().FullName)
                                : memberFormaterAttribute1.Name);

                            //MemberInfo[] memberInfos = target.GetType().GetMembers(bindingFlags /*BindingFlags.Public | BindingFlags.Instance /*| BindingFlags.DeclaredOnly*/ /*| BindingFlags.GetField | BindingFlags.GetProperty*/);
                            IEnumerable <MemberInfo> memberInfos = ChoType.GetGetFieldsNProperties(target.GetType(), bindingFlags);
                            if (memberInfos == null || memberInfos.Count() == 0)
                            {
                                msg.AppendFormatLine(ChoStringMsgBuilder.Empty);
                            }
                            else
                            {
                                foreach (MemberInfo memberInfo in memberInfos)
                                {
                                    if (!ChoType.IsValidObjectMember(memberInfo))
                                    {
                                        continue;
                                    }

                                    ChoIgnoreMemberFormatterAttribute memberFormatterIgnoreAttribute = ChoType.GetMemberAttribute(memberInfo, typeof(ChoIgnoreMemberFormatterAttribute)) as ChoIgnoreMemberFormatterAttribute;
                                    if (memberFormatterIgnoreAttribute != null)
                                    {
                                        continue;
                                    }

                                    string memberText = GetNFormatMemberValue(target, memberInfo, collectErrMsgs, null, null, bindingFlags);

                                    int count = 0;
                                    if (GetCountFromMsg(ref memberText, ref count))
                                    {
                                        msg.AppendFormatLine("{0} [Length: {2}]: {1}", memberInfo.Name, memberText, count);
                                    }
                                    else if (!memberText.ContainsHeader())
                                    {
                                        msg.AppendFormatLine("{0}: {1}", memberInfo.Name, memberText);
                                    }
                                    else
                                    {
                                        msg.AppendFormatLine("{0}: {1}", memberInfo.Name, memberText);
                                    }
                                }
                            }
                            msg.AppendNewLine();

                            if (collectErrMsgs)
                            {
                                GetErrorMsgs(target, msg);
                            }

                            return(msg.ToString());
                        }
                        else
                        {
                            ChoStringMsgBuilder msg = new ChoStringMsgBuilder(ChoString.ExpandProperties(target, objectFormatter.Header));;
                            if (objectFormatter.HasFormatSpecified)
                            {
                                msg.AppendFormat(objectFormatter.FormatObject(target));
                            }
                            else
                            {
                                //MemberInfo[] memberInfos = target.GetType().GetMembers(bindingFlags /*BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance /*| BindingFlags.DeclaredOnly*/ /*| BindingFlags.GetField | BindingFlags.GetProperty*/);
                                IEnumerable <MemberInfo> memberInfos = ChoType.GetGetFieldsNProperties(target.GetType(), bindingFlags);

                                if (memberInfos == null || memberInfos.Count() == 0)
                                {
                                    msg.AppendFormatLine(ChoStringMsgBuilder.Empty);
                                }
                                else
                                {
                                    bool isPublicMember = true;
                                    foreach (MemberInfo memberInfo in memberInfos)
                                    {
                                        if (!ChoType.IsValidObjectMember(memberInfo))
                                        {
                                            continue;
                                        }

                                        isPublicMember = true;

                                        ChoIgnoreMemberFormatterAttribute memberFormatterIgnoreAttribute = ChoType.GetMemberAttribute(memberInfo, typeof(ChoIgnoreMemberFormatterAttribute)) as ChoIgnoreMemberFormatterAttribute;
                                        if (memberFormatterIgnoreAttribute != null)
                                        {
                                            continue;
                                        }

                                        ChoMemberFormatterAttribute     memberFormaterAttribute     = ChoType.GetMemberAttribute(memberInfo, typeof(ChoMemberFormatterAttribute)) as ChoMemberFormatterAttribute;
                                        ChoMemberItemFormatterAttribute memberItemFormaterAttribute = ChoType.GetMemberAttribute(memberInfo, typeof(ChoMemberItemFormatterAttribute)) as ChoMemberItemFormatterAttribute;

                                        if (memberInfo is PropertyInfo)
                                        {
                                            MethodInfo getMethod = ((PropertyInfo)memberInfo).GetGetMethod(true);
                                            isPublicMember = getMethod != null && getMethod.IsPublic;
                                        }
                                        else if (memberInfo is FieldInfo)
                                        {
                                            isPublicMember = ((FieldInfo)memberInfo).IsPublic;
                                        }
                                        else
                                        {
                                            continue;
                                        }

                                        if (isPublicMember || (!isPublicMember && memberFormaterAttribute != null))
                                        {
                                            object memberValue = ChoType.GetMemberValue(target, memberInfo);
                                            if (memberValue == target)
                                            {
                                                return(null);
                                            }

                                            string memberText = GetNFormatMemberValue(target, memberInfo, collectErrMsgs, memberFormaterAttribute, memberItemFormaterAttribute, bindingFlags);
                                            string memberName = memberFormaterAttribute == null || memberFormaterAttribute.Name.IsNullOrEmpty() ? memberInfo.Name : ChoPropertyManager.ExpandProperties(target, memberFormaterAttribute.Name);

                                            if (memberFormaterAttribute == null || !memberFormaterAttribute.CanFormat())
                                            {
                                                int count = 0;
                                                if (GetCountFromMsg(ref memberText, ref count))
                                                {
                                                    msg.AppendFormatLine("{0} [Length: {2}]: {1}", memberName, memberText, count);
                                                }
                                                else if (memberText.ContainsHeader())
                                                {
                                                    msg.AppendFormatLine("{0}: {1}", memberName, memberText);
                                                }
                                                else
                                                {
                                                    msg.AppendFormatLine("{0}: {1}", memberName, memberText);
                                                }
                                            }
                                            else if (memberFormaterAttribute.Name == ChoNull.NullString)
                                            {
                                                msg.Append(memberFormaterAttribute.PostFormat(memberName, memberText));
                                            }
                                            else
                                            {
                                                msg.AppendFormat(memberFormaterAttribute.PostFormat(memberName, memberText));
                                            }
                                        }
                                    }
                                }
                            }
                            //msg.AppendNewLine();
                            if (collectErrMsgs)
                            {
                                GetErrorMsgs(target, msg);
                            }

                            return(msg.ToString());
                        }
                    }
                    finally
                    {
                        if (interceptableObject != null)
                        {
                            interceptableObject.Dispose();
                        }
                    }
                }
            }
        }