コード例 #1
0
        /// <summary>
        /// Loads the message from the resource associated with the enum type and formats it
        /// using 'String.Format'. Because this function is intended to be used during error
        /// handling it never raises an exception.
        /// </summary>
        /// <param name="id">The type of the parameter identifies the resource
        /// and the name of the enum identifies the message in the resource.</param>
        /// <param name="args">Parameters passed through 'String.Format'.</param>
        /// <returns>The formatted message.</returns>
        public static string Format(PSXMsgID id, params object[] args)
        {
            string message;

            try
            {
                message = GetString(id);
                if (message != null)
                {
                    message = Format(message, args);
                }
                else
                {
                    message = "INTERNAL ERROR: Message not found in resources.";
                }
                return(message);
            }
            catch (Exception ex)
            {
                message = String.Format("UNEXPECTED ERROR while formatting message with ID {0}: {1}", id.ToString(), ex.ToString());
            }
            return(message);
        }
コード例 #2
0
ファイル: PSXSR.cs プロジェクト: bossaia/alexandrialibrary
 /// <summary>
 /// Gets the localized message identified by the specified DomMsgID.
 /// </summary>
 public static string GetString(PSXMsgID id)
 {
   return PSXSR.ResMngr.GetString(id.ToString());
 }
コード例 #3
0
ファイル: PSXSR.cs プロジェクト: bossaia/alexandrialibrary
 /// <summary>
 /// Loads the message from the resource associated with the enum type and formats it
 /// using 'String.Format'. Because this function is intended to be used during error
 /// handling it never raises an exception.
 /// </summary>
 /// <param name="id">The type of the parameter identifies the resource
 /// and the name of the enum identifies the message in the resource.</param>
 /// <param name="args">Parameters passed through 'String.Format'.</param>
 /// <returns>The formatted message.</returns>
 public static string Format(PSXMsgID id, params object[] args)
 {
   string message;
   try
   {
     message = PSXSR.GetString(id);
     if (message != null)
       message = Format(message, args);
     else
       message = "INTERNAL ERROR: Message not found in resources.";
     return message;
   }
   catch (Exception ex)
   {
     message = String.Format("UNEXPECTED ERROR while formatting message with ID {0}: {1}", id.ToString(), ex.ToString());
   }
   return message;
 }
コード例 #4
0
 /// <summary>
 /// Gets the localized message identified by the specified DomMsgID.
 /// </summary>
 public static string GetString(PSXMsgID id)
 {
     return(ResMngr.GetString(id.ToString()));
 }