コード例 #1
0
        public IList <IComponentPresentation> GetComponentPresentations(string[] componentUris)
        {
            List <IComponentPresentation> cps = new List <IComponentPresentation>();

            foreach (string content in ComponentPresentationProvider.GetContentMultiple(componentUris))
            {
                cps.Add(GetIComponentPresentationObject(content));
            }
            return(cps);
        }
コード例 #2
0
        ///// <summary>
        ///// Get or set the CacheAgent
        ///// </summary>
        //public override ICacheAgent CacheAgent
        //{
        //    get
        //    {
        //        if (_cacheAgent == null)
        //        {
        //            _cacheAgent = new NullCacheAgent();
        //            // the next line is the only reason we are overriding this property: to set a callback
        //            _cacheAgent.GetLastPublishDateCallBack = GetLastPublishedDateCallBack;
        //        }
        //        return _cacheAgent;
        //    }
        //    set
        //    {
        //        _cacheAgent = value;
        //        _cacheAgent.GetLastPublishDateCallBack = GetLastPublishedDateCallBack;
        //    }
        //}



        public bool TryGetComponentPresentation(out IComponentPresentation cp, string componentUri, string templateUri = "")
        {
            cp = null;

            string[] cacheUris = { componentUri };

            if (!String.IsNullOrEmpty(templateUri))
            {
                cacheUris = new string[] { componentUri, templateUri };
            }

            string cacheKey = CacheKeyFactory.GenerateKey(CacheRegion, cacheUris);

            cp = (IComponentPresentation)CacheAgent.Load(cacheKey);

            if (cp != null)
            {
                LoggerService.Debug("<<TryGetComponentPresentation ({0}) - from cache", LoggingCategory.Performance, componentUri);
                return(true);
            }

            string content = !String.IsNullOrEmpty(templateUri) ?
                             ComponentPresentationProvider.GetContent(componentUri, templateUri) :
                             ComponentPresentationProvider.GetContent(componentUri);

            if (string.IsNullOrEmpty(content))
            {
                LoggerService.Debug("<<TryGetComponentPresentationOrComponent - no content found by provider for uris {0} and {1}", LoggingCategory.Performance, componentUri, templateUri);
                return(false);
            }
            LoggerService.Debug("about to create IComponentPresentation from content ({0})", LoggingCategory.Performance, componentUri);
            cp = GetIComponentPresentationObject(content);
            LoggerService.Debug("finished creating IComponentPresentation from content ({0})", LoggingCategory.Performance, componentUri);

            // if there is no ComponentTemplate, the content of this CP probably represents a component instead of a component PRESENTATION
            // in that case, we should at least add the template uri method parameter (if there is one) to the object
            if (cp.ComponentTemplate == null)
            {
                ((ComponentPresentation)cp).ComponentTemplate = new ComponentTemplate();
            }
            if (cp.ComponentTemplate.Id == null)
            {
                ((ComponentPresentation)cp).ComponentTemplate.Id = templateUri;
            }

            LoggerService.Debug("about to store IComponentPresentation in cache ({0})", LoggingCategory.Performance, componentUri);
            CacheAgent.Store(cacheKey, CacheRegion, cp, new List <string> {
                cp.Component.Id
            });
            LoggerService.Debug("finished storing IComponentPresentation in cache ({0})", LoggingCategory.Performance, componentUri);
            LoggerService.Debug("<<TryGetComponentPresentation ({0})", LoggingCategory.Performance, componentUri);

            return(cp != null);
        }
コード例 #3
0
        public IList <IComponentPresentation> FindComponentPresentations(IQuery queryParameters)
        {
            LoggerService.Debug(">>FindComponentPresentations ({0})", LoggingCategory.Performance, queryParameters.ToString());

            var results = ComponentPresentationProvider.FindComponents(queryParameters)
                          .Select(c => { IComponentPresentation cp = null; TryGetComponentPresentation(out cp, c); return(cp); })
                          .Where(cp => cp != null)
                          .ToList();

            LoggerService.Debug("<<FindComponentPresentations ({0})", LoggingCategory.Performance, queryParameters.ToString());
            return(results);
        }
コード例 #4
0
        public IList <IComponentPresentation> FindComponentPresentations(IQuery queryParameters, int pageIndex, int pageSize, out int totalCount)
        {
            LoggerService.Debug(">>FindComponentPresentations ({0},{1})", LoggingCategory.Performance, queryParameters.ToString(), Convert.ToString(pageIndex));
            totalCount = 0;
            IList <string> results = ComponentPresentationProvider.FindComponents(queryParameters);

            totalCount = results.Count;

            var pagedResults = results
                               .Skip(pageIndex * pageSize)
                               .Take(pageSize)
                               .Select(c => { IComponentPresentation cp = null; TryGetComponentPresentation(out cp, c); return(cp); })
                               .Where(cp => cp != null)
                               .ToList();

            LoggerService.Debug("<<FindComponentPresentations ({0},{1})", LoggingCategory.Performance, queryParameters.ToString(), Convert.ToString(pageIndex));
            return(pagedResults);
        }
コード例 #5
0
 public DateTime GetLastPublishedDate(string componentUri, string templateUri = "")
 {
     return(ComponentPresentationProvider.GetLastPublishedDate(componentUri));
 }