Example #1
0
        private static PageStructureRecord GetPageStructureRecord(Guid pageId)
        {
            var cacheKey = pageId;
            ExtendedNullable <PageStructureRecord> cachedValue = _pageStructureCache.Get(cacheKey);

            if (cachedValue != null)
            {
                Verify.That(cachedValue.HasValue, "Incorrect usage of cache.");
                return(cachedValue.Value);
            }

            PageStructureRecord result =
                (from ps in DataFacade.GetData <IPageStructure>(false)
                 where ps.Id == pageId
                 select new PageStructureRecord
            {
                ParentId = ps.ParentId,
                LocalOrdering = ps.LocalOrdering
            }).FirstOrDefault();

            if (result == null)
            {
                Log.LogWarning(LogTitle, $"No IPageStructure entries found for Page with Id '{pageId}'");
            }

            _pageStructureCache.Add(cacheKey, result);

            return(result);
        }
Example #2
0
        /// <exclude />
        public static string GetString(string section, string stringName, bool throwOnError)
        {
            Verify.ArgumentNotNullOrEmpty(section, "section");
            Verify.ArgumentNotNullOrEmpty(stringName, "stringName");

            var culture = Thread.CurrentThread.CurrentUICulture;

            string cacheKey = culture.Name + section + stringName;
            ExtendedNullable <string> cachedValue = _resourceCache.Get(cacheKey);

            if (cachedValue != null)
            {
                return(cachedValue.Value);
            }

            if (throwOnError)
            {
                Verify.ArgumentCondition(!section.Contains(','), "section", "providerName may not contain ',' symbol");
                Verify.ArgumentCondition(!stringName.Contains(','), "stringName", "stringName may not contain ',' symbol");
            }


            string result = ResourceProviderPluginFacade.GetStringValue(section, stringName, culture);

            if (result != null)
            {
                _resourceCache.Add(cacheKey, new ExtendedNullable <string> {
                    Value = result
                });
                return(result);
            }

            if (!throwOnError)
            {
                return(null);
            }

            if (!ResourceProviderPluginFacade.LocalizationSectionDefined(section))
            {
                Log.LogVerbose(LogTitle, "Localization section not defined '{0}:{1}'".FormatWith(section, stringName));

                return(Error_SectionNotDefined);
            }


            Log.LogVerbose(LogTitle, "Localization string not defined '{0}:{1}'".FormatWith(section, stringName));

            return(Error_StringNotDefined);
        }
        private static void OnSystemActiveLocaleStoreChanged(object sender, StoreEventArgs storeEventArgs)
        {
            if (!storeEventArgs.DataEventsFired)
            {
                _urlMappingCache.Clear();
                _cultureUrlCache.Clear();

                lock (_syncRoot)
                {
                    _urlMappings = null;
                    _activeCultureNames = null;
                    _defaultUrlMappingCulture = null;
                    _defaultCulture = null;
                }
            }
        }
        public static int Get(Type type)
        {
            Verify.ArgumentNotNull(type, "type");

            if (typeof(IMediaFile).IsAssignableFrom(type))
            {
                type = typeof(IMediaFileData);
            }

            EnsureSubscribtion(type);

            string key = GetKey(type);
            ExtendedNullable <int> record = _versionNumbers[key];

            return(_flushCounter + (record == null ? 0 : record.Value));
        }
Example #5
0
        private static void OnSystemActiveLocaleStoreChanged(object sender, StoreEventArgs storeEventArgs)
        {
            if (!storeEventArgs.DataEventsFired)
            {
                _urlMappingCache.Clear();
                _cultureUrlCache.Clear();

                lock (_syncRoot)
                {
                    _urlMappings              = null;
                    _activeCultureNames       = null;
                    _defaultUrlMappingCulture = null;
                    _defaultCulture           = null;
                }
            }
        }
        private static void OnSystemActiveLocaleChanged(object sender, DataEventArgs dataEventArgs)
        {
            var locale = dataEventArgs.Data as ISystemActiveLocale;
            
            if (locale != null)
            {
                _urlMappingCache.Remove(locale.UrlMappingName);
                _cultureUrlCache.Remove(locale.CultureName);

                lock (_syncRoot)
                {
                    _urlMappings = null;
                    _activeCultureNames = null;
                    _defaultUrlMappingCulture = null;
                    _defaultCulture = null;
                }
            }
        }
Example #7
0
        private static void OnSystemActiveLocaleChanged(object sender, DataEventArgs dataEventArgs)
        {
            var locale = dataEventArgs.Data as ISystemActiveLocale;

            if (locale != null)
            {
                _urlMappingCache.Remove(locale.UrlMappingName);
                _cultureUrlCache.Remove(locale.CultureName);

                lock (_syncRoot)
                {
                    _urlMappings              = null;
                    _activeCultureNames       = null;
                    _defaultUrlMappingCulture = null;
                    _defaultCulture           = null;
                }
            }
        }