Kooboo.Commerce.Multilingual.Storage.CachedTranslactionStore.Find C# (CSharp) Method

Find() public method

public Find ( System culture, EntityKey key ) : EntityTransaltion
culture System
key EntityKey
return EntityTransaltion
        public EntityTransaltion Find(System.Globalization.CultureInfo culture, EntityKey key)
        {
            return Find(culture, new EntityKey[] { key })[0];
        }

Same methods

CachedTranslactionStore::Find ( System culture ) : EntityTransaltion[]

Usage Example

        public void should_cache_by_culture()
        {
            var zh_CN = CultureInfo.GetCultureInfo("zh-CN");
            var nl_NL = CultureInfo.GetCultureInfo("nl-NL");

            var brandKey = EntityKey.Create<Brand>(15);

            var cnTranslation = CreateBrandTranslation(15, zh_CN, "Apple China");
            var nlTranslation = CreateBrandTranslation(15, nl_NL, "Apple Dutch");

            var underlyingStoreMock = new Mock<ITranslationStore>();
            underlyingStoreMock.Setup(it => it.Find(zh_CN, new[] { brandKey }))
                               .Returns(new[] { cnTranslation });

            underlyingStoreMock.Setup(it => it.Find(nl_NL, new[] { brandKey }))
                               .Returns(new[] { nlTranslation });

            var store = new CachedTranslactionStore(underlyingStoreMock.Object, new[] { typeof(Brand) });

            var translation = store.Find(zh_CN, brandKey);
            Assert.Equal("Apple China", translation.PropertyTranslations[0].TranslatedText);

            translation = store.Find(nl_NL, brandKey);
            Assert.Equal("Apple Dutch", translation.PropertyTranslations[0].TranslatedText);
        }
All Usage Examples Of Kooboo.Commerce.Multilingual.Storage.CachedTranslactionStore::Find