コード例 #1
0
        public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            LocalizationService.SavedDictionaryItem    += SavedDictionaryItem;
            LocalizationService.DeletingDictionaryItem += DeletingDictionaryItem;

            DictionaryCache.Fill();
        }
コード例 #2
0
 private void SavedDictionaryItem(ILocalizationService sv, SaveEventArgs <IDictionaryItem> args)
 {
     foreach (var e in args.SavedEntities)
     {
         foreach (var t in e.Translations)
         {
             DictionaryCache.AddOrUpdate(e.ItemKey, t.Key, t.Value, t.Language.IsoCode);
         }
     }
 }
コード例 #3
0
        private void DeletingDictionaryItem(ILocalizationService sv, DeleteEventArgs <IDictionaryItem> args)
        {
            foreach (var e in args.DeletedEntities)
            {
                foreach (var t in e.Translations)
                {
                    DictionaryCache.Remove(e.ItemKey + "-" + t.Language.IsoCode);
                }

                var children = sv.GetDictionaryItemDescendants(e.Key);

                if (children.Any())
                {
                    foreach (var c in children)
                    {
                        foreach (var t in c.Translations)
                        {
                            DictionaryCache.Remove(c.ItemKey + "-" + t.Language.IsoCode);
                        }
                    }
                }
            }
        }