Exemple #1
0
        //------------------------------------------------------------
        // ConsoleOutput.FormatString
        //
        /// <summary></summary>
        /// <param name="fmt"></param>
        /// <param name="args"></param>
        /// <returns></returns>
        //------------------------------------------------------------
        protected string FormatString(string fmt, params Object[] args)
        {
            string    buffer;
            Exception excp = null;

            if (FormatStringUtil.FormatString(out buffer, out excp, fmt, args))
            {
                return(buffer);
            }

            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("{0}: ",
                            (excp != null ? excp.Message : "Failed to Format"));
            foreach (Object obj in args)
            {
                sb.AppendFormat(", {0}", obj);
            }
            return(sb.ToString());
        }
Exemple #2
0
        //------------------------------------------------------------
        // ErrorUtil.FormatErrorMessage (1)
        //
        /// <summary>
        /// <para>Get the format string by id, create an error message with args</para>
        /// </summary>
        /// <param name="formatted"></param>
        /// <param name="excp"></param>
        /// <param name="strID"></param>
        /// <param name="args"></param>
        /// <returns>Return false if failed to make an error message.</returns>
        //------------------------------------------------------------
        static internal bool FormatErrorMessage(
            out string formatted,
            out Exception excp,
            ResNo resNo,
            params Object[] args)
        {
            formatted = null;
            int    argCount = 0;
            string format   = null;

            excp = null;

            if (CResources.GetString(resNo, out format, out argCount, out excp))
            {
                return(FormatStringUtil.FormatString(
                           out formatted,
                           out excp,
                           format,
                           argCount,
                           args));
            }
            return(false);
        }