Ejemplo n.º 1
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.PreRender"/> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs"/> object that contains the event data.</param>
        protected override void OnPreRender(EventArgs e)
        {
            if (TextResourceManager == null)
            {
                throw new TextResourceManagerException("TextResourceManager must not be null.");
            }

            this.Text = TextResourceManager.GetResourceText(this.ResourceKey, this.Culture);

            base.OnPreRender(e);
        }
Ejemplo n.º 2
0
        public void Test_LoadTextResource()
        {
            Trace.WriteLine(Configuration.GetGenericHeader());

            TextResourceManager manager = new TextResourceManager("tr_Resources.TwoCultures.xml"
                                                                  , Configuration.TextResourcesRootFolder
                                                                  , "Resources.TwoCultures.xml"
                                                                  , "en-gb"
                                                                  , "resource"
                                                                  , "key");

            Assert.IsTrue(manager.GetResourceText("resource1") == "First resource");
            Assert.IsTrue(manager.GetResourceText("resource2") == "Second resource");
            Assert.IsTrue(manager.GetResourceText("resource3") == "Third resource");
            Assert.IsTrue(manager.GetResourceText("resource1", "de-at") == "Erster text");
            Assert.IsTrue(manager.GetResourceText("resource2", "de-at") == "Zweiter text");
            Assert.IsTrue(manager.GetResourceText("resource3", "de-at") == "Third resource");

            manager = new TextResourceManager("tr_Resources.OneCulture.xml"
                                              , Configuration.TextResourcesRootFolder
                                              , "Resources.OneCulture.xml"
                                              , "en-gb"
                                              , "resource"
                                              , "key");

            Assert.IsTrue(manager.GetResourceText("resource1") == "First resource");
            Assert.IsTrue(manager.GetResourceText("resource2") == "Second resource");
            Assert.IsTrue(manager.GetResourceText("resource3") == "Third resource");
            Assert.IsTrue(manager.GetResourceText("resource1", "de-at") == "First resource");
            Assert.IsTrue(manager.GetResourceText("resource2", "de-at") == "Second resource");
            Assert.IsTrue(manager.GetResourceText("resource3", "de-at") == "Third resource");

            Trace.WriteLine(Configuration.GetGenericFooter());
        }