示例#1
0
        private Dictionary <int, AbTestPersistentData> GetCachedTests()
        {
            var onScreenContext    = _onScreenContextProvider.GetContext();
            var isStage            = onScreenContext?.AbtestsIsStageOverrided ?? _abTestingQpSettings.IsStage; //isStage может быть переопределен для Onscreen
            var getOnlyActiveTests = onScreenContext == null || !onScreenContext.Enabled;                      //в режиме Onscreen нам нужны не только активные сейчас тесты
            var cacheTags          = new string[1] {
                _qpContentCacheTagNamingProvider.GetByNetName(_abTestRepository.AbTestNetName, _abTestingQpSettings.SiteId, isStage)
            }
            .Where(t => t != null)
            .ToArray();

            return(_cacheProvider.GetOrAdd($"AbTestService.GetCachedTests_{_abTestingQpSettings.SiteId}_{isStage}_{getOnlyActiveTests}",
                                           cacheTags,
                                           _abTestingCacheSettings.TestsCachePeriod,
                                           () => getOnlyActiveTests ?
                                           _abTestRepository.GetActiveTests(_abTestingQpSettings.SiteId, isStage).ToDictionary(_ => _.Id) :
                                           _abTestRepository.GetAllTests(_abTestingQpSettings.SiteId, isStage).ToDictionary(_ => _.Id)));
        }
示例#2
0
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            var onScreenContext = _onScreenContextProvider.GetContext();
            var isEditMode      = onScreenContext != null?onScreenContext.HasFeature(OnScreenFeatures.Widgets) : false;

            if (isEditMode)
            {
                output.PreContent.SetHtmlContent($"<!--start article {Id} {{ title='{Title}' contentId='{ContentId}' published='{(Published ? "true" : "false")}' }} -->");
                output.PostContent.SetHtmlContent($"<!--end article {Id}-->");
            }
            else
            {
                output.PreContent.SetHtmlContent($"<!--start article-->");
                output.PostContent.SetHtmlContent($"<!--end article-->");
            }
            output.TagName = null;
            base.Process(context, output);
        }