public DynamicText GetDynamicText(string name, string scope, CultureInfo cultureInfo) { if (string.IsNullOrEmpty(scope)) { scope = m_configuration.DefaultScope; } var culture = GetCachedCultureByNameOrGetDefault(cultureInfo.Name); var dictionaryScope = GetCachedDictionaryScope(scope); var staticText = m_staticTextUoW.GetByNameAndCultureAndScope( name, culture.Name, dictionaryScope.Name ); if (staticText == null) { return(null); } return(new DynamicText { FallBack = staticText.Culture.Name != cultureInfo.Name, Culture = staticText.Culture.Name, DictionaryScope = staticText.DictionaryScope.Name, Format = staticText.Format, ModificationTime = staticText.ModificationTime, ModificationUser = staticText.ModificationUser, Name = staticText.Name, Text = staticText.Text, }); }
public void StaticTextCreateReadTest() { var cultureUoW = new CultureUoW(m_sessionFactory); var dictionaryScopeUoW = new DictionaryScopeUoW(m_sessionFactory); var staticTextUoW = new StaticTextUoW(m_sessionFactory); cultureUoW.AddCulture("cs"); dictionaryScopeUoW.AddScope("dictionaryScope"); Assert.IsNull(staticTextUoW.GetStaticTextById(0)); Assert.IsNull(staticTextUoW.GetByNameAndCultureAndScope("not-exist", "not-exist", "not-exist")); var time = DateTime.UtcNow; staticTextUoW.AddStaticText( "name", 0, "text", "cs", "dictionaryScope", "modificationUser", time ); var allStaticTexts = staticTextUoW.FindAllStaticTexts(); Assert.AreEqual(1, allStaticTexts.Count); Assert.AreEqual("name", allStaticTexts.First().Name); Assert.AreEqual("name", staticTextUoW.GetStaticTextById(1).Name); var staticText = staticTextUoW.GetByNameAndCultureAndScope( "name", "cs", "dictionaryScope" ); Assert.AreEqual("name", staticText.Name); Assert.AreEqual("text", staticText.Text); var nullStaticText1 = staticTextUoW.GetByNameAndCultureAndScope( "not-exist", "cs", "dictionaryScope" ); var nullStaticText2 = staticTextUoW.GetByNameAndCultureAndScope( "name", "en", "dictionaryScope" ); var nullStaticText3 = staticTextUoW.GetByNameAndCultureAndScope( "name", "cs", "not-exist" ); Assert.IsNull(nullStaticText1); Assert.IsNull(nullStaticText2); Assert.IsNull(nullStaticText3); }
public void StaticTextCreateUpdateTest() { var cultureUoW = new CultureUoW(m_sessionFactory); var dictionaryScopeUoW = new DictionaryScopeUoW(m_sessionFactory); var staticTextUoW = new StaticTextUoW(m_sessionFactory); cultureUoW.AddCulture("cs"); dictionaryScopeUoW.AddScope("dictionaryScope"); var time = DateTime.UtcNow; staticTextUoW.AddStaticText( "name", 0, "text", "cs", "dictionaryScope", "modificationUser", time ); var staticText = staticTextUoW.GetByNameAndCultureAndScope( "name", "cs", "dictionaryScope" ); Assert.AreEqual("name", staticText.Name); Assert.AreEqual("text", staticText.Text); staticTextUoW.UpdateStaticText( "name", "cs", "dictionaryScope", 0, "modifiedText", "modificationUser", time ); var staticTextReFetched = staticTextUoW.GetByNameAndCultureAndScope( "name", "cs", "dictionaryScope" ); Assert.AreEqual("modifiedText", staticTextReFetched.Text); }
public LocalizedString DatabaseTranslate(string text, CultureInfo cultureInfo, string scope) { var culture = GetCachedCultureByNameOrGetDefault(cultureInfo.Name); var dictionaryScope = GetCachedDictionaryScope(scope); var staticText = m_staticTextUoW.GetByNameAndCultureAndScope( text, culture.Name, dictionaryScope.Name ); if (staticText == null) { return(null); } return(new LocalizedString(text, staticText.Text, false)); }