Example #1
0
        /// <summary>
        /// Get all container components on a page
        /// </summary>
        /// <param name="page"></param>
        /// <returns></returns>
        static public IList <Container> GetContainers(Page page)
        {
            int containerCount                 = 0;
            int pageIndex                      = 0;
            IList <Container> containers       = new List <Container>();
            Container         currentContainer = null;

            foreach (ComponentPresentation cp in page.ComponentPresentations)
            {
                if (IsContainer(cp))
                {
                    currentContainer           = new Container(page, cp.Component, cp.ComponentTemplate);
                    currentContainer.Index     = ++containerCount;
                    currentContainer.pageIndex = pageIndex;
                    containers.Add(currentContainer);
                }
                else
                {
                    if (currentContainer != null && currentContainer.Owns(cp))
                    {
                        ComponentPresentationInfo cpInfo = currentContainer.AddToComponentPresentationList(cp, pageIndex);
                    }
                }
                pageIndex++;
            }

            return(containers);
        }
Example #2
0
        private ComponentPresentationInfo AddToComponentPresentationList(ComponentPresentation componentPresentation, int pageIndex)
        {
            ComponentPresentationInfo cpInfo = new ComponentPresentationInfo(componentPresentation, this, pageIndex);

            this.ComponentPresentations.Add(cpInfo);
            return(cpInfo);
        }
Example #3
0
 /// <summary>
 /// Extract container index from component presentation.
 /// </summary>
 /// <param name="componentPresentation"></param>
 /// <returns></returns>
 static public int ExtractContainerIndex(ComponentPresentationInfo componentPresentation)
 {
     return(ExtractContainerIndex(componentPresentation.ComponentPresentation.ComponentTemplate.Id));
 }