Esempio n. 1
0
        /// <summary>
        /// Finds the page that contains the specified ModuleInstance. If no page
        /// in this Package contains the ModuleInstance then null is returned.
        /// </summary>
        /// <param name="module">The ModuleInstance to search for.</param>
        /// <returns>The PageInstance that contains the ModuleInstance or null if not found.</returns>
        public PageInstance ParentOfModule(ModuleInstance module)
        {
            foreach (PageInstance parent in Pages)
            {
                PageInstance parentPage = ParentOfModule(parent, module);

                if (parentPage != null)
                {
                    return(parentPage);
                }
            }

            return(null);
        }
Esempio n. 2
0
        /// <summary>
        /// Determine if the module is on either the specified page or a child
        /// page and returns the matching page. This method is recursive.
        /// </summary>
        /// <param name="parentPage">The PageInstance to begin searching at.</param>
        /// <param name="module">The ModuleInstance to look for.</param>
        /// <returns>PageInstance containing module or null if not found.</returns>
        private PageInstance ParentOfModule(PageInstance parentPage, ModuleInstance module)
        {
            if (parentPage.Modules.Contains(module))
            {
                return(parentPage);
            }

            foreach (PageInstance parent in parentPage.Pages)
            {
                PageInstance tmp = ParentOfModule(parent, module);

                if (tmp != null)
                {
                    return(tmp);
                }
            }

            return(null);
        }