예제 #1
0
        public virtual ExcelContentRoot TranslateContentRoots(JsonContentRoot jsonContentRoot)
        {
            var result = new ExcelContentRoot();

            if (string.IsNullOrEmpty(jsonContentRoot.Value))
            {
                return(null);
            }
            if (jsonContentRoot.ContentRootType == ContentRootTypes.IDS)
            {
                var contentIds = jsonContentRoot.Value.Split(',');
                foreach (var id in contentIds)
                {
                    int      contentId;
                    IContent content;
                    if (int.TryParse(id, out contentId) && _contentRepository.TryGet(new ContentReference(contentId), out content))
                    {
                        result.ContentRoots.Add(content);
                    }
                    else
                    {
                        result.ContentRoots = new List <IContent>();
                        break;
                    }
                }
            }
            else if (jsonContentRoot.ContentRootType == ContentRootTypes.FUNCTION)
            {
                var rootLoader = LoadInstance <IContentRootLoader>(jsonContentRoot.Value);
                if (rootLoader == null)
                {
                    return(null);
                }
                result.ContentRoots = rootLoader.GetRoots();
            }
            var dictChildrenLoaders = GetContentChildrenLoaders();
            IContentChildrenLoader childrenLoader;

            if (dictChildrenLoaders.TryGetValue(jsonContentRoot.GetChildren, out childrenLoader))
            {
                result.ChildrenLoader = childrenLoader;
            }
            return(result);
        }
예제 #2
0
        private List <IContent> GetTargetContents(ExcelContentRoot contentRoots, Type targetPageType)
        {
            var childrenLoader = contentRoots.ChildrenLoader;

            return(contentRoots.ContentRoots.SelectMany(x => childrenLoader.GetChildren(x, targetPageType)).ToList());
        }