Example #1
0
        ///////////////////////////////////////////////////////////////////////

        public static string Format(
            string prefix,
            ReturnCode code,
            Result result,
            int errorLine,
            bool exceptions,
            bool display
            )
        {
            bool   haveResult    = !String.IsNullOrEmpty(result);
            bool   haveErrorLine = (errorLine != 0);
            string format;

            if (IsSuccess(code, exceptions))
            {
                if (haveResult)
                {
                    format = resultOnlyFormat;
                }
                else
                {
                    format = emptyFormat;
                }
            }
            else
            {
                if (haveResult)
                {
                    if (haveErrorLine)
                    {
                        format = codeResultAndErrorLineFormat;
                    }
                    else
                    {
                        format = codeAndResultFormat;
                    }
                }
                else
                {
                    if (haveErrorLine)
                    {
                        format = codeAndErrorLineFormat;
                    }
                    else
                    {
                        format = codeOnlyFormat;
                    }
                }
            }

            string formatted = String.Format(
                format, prefix, code, result, errorLine);

            if (display)
            {
                formatted = FormatOps.DisplayResult(
                    formatted, false, false);
            }

            return(formatted);
        }