Ejemplo n.º 1
0
        public void GetMessageDefaultsToCurrentUICulture()
        {
            StaticMessageSource msgSource = new StaticMessageSource();

            msgSource.AddMessage("code", CultureInfo.CurrentUICulture, "{0}");
            Assert.AreEqual("my message", msgSource.GetMessage("code", "my message"), "message");

            try
            {
                msgSource.GetMessage("code", CultureInfo.CurrentCulture);
                Assert.Fail("message");
            }
            catch (NoSuchMessageException)
            {}
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Associate the given message with the given code.
        /// </summary>
        /// <param name="code">The lookup code.</param>
        /// <param name="cultureInfo">
        /// The <see cref="System.Globalization.CultureInfo"/> that the message should be found within.
        /// </param>
        /// <param name="defaultMessage">The message associated with the lookup code.</param>
        public void AddMessage(string code, CultureInfo cultureInfo, string defaultMessage)
        {
            StaticMessageSource messageSource = (StaticMessageSource)GetObject(MessageSourceObjectName);

            messageSource.AddMessage(code, cultureInfo, defaultMessage);
        }