Esempio n. 1
0
        /// <summary>
        ///   Lookup the license header file within a project , if there is none on this level, moving up to next level.
        /// </summary>
        /// <param name="projectItem"></param>
        /// <returns>A dictionary, which contains the extensions and the corresponding lines</returns>
        private static IDictionary <string, string[]> SearchWithinProjectGetHeaderDefinitionForItem(ProjectItem projectItem)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            //Check for License-file within this level
            string headerFile;

            try
            {
                headerFile = SearchItemsDirectlyGetHeaderDefinitionFileName(projectItem.ProjectItems);
            }
            catch (COMException)
            {
                return(new Dictionary <string, string[]>());
            }

            if (!string.IsNullOrEmpty(headerFile))
            {
                return(LicenseHeadersPackage.Instance.LicenseHeaderExtractor.ExtractHeaderDefinitions(headerFile)); //Found a License header file on this level
            }
            var projectItemParent = ProjectItemParentFinder.GetProjectItemParent(projectItem);

            //Lookup in the parent --> Go Up!
            return(SearchWithinProjectGetHeaderDefinitionForProjectOrItem(projectItemParent));
        }
        /// <summary>
        /// Lookup the license header file within a project , if there is none on this level, moving up to next level.
        /// </summary>
        /// <param name="projectItem"></param>
        /// <returns>A dictionary, which contains the extensions and the corresponding lines</returns>
        private static IDictionary <string, string[]> SearchWithinProjectGetHeaderDefinitionForItem(ProjectItem projectItem)
        {
            //Check for License-file within this level
            var headerFile = SearchItemsDirectlyGetHeaderDefinitionFileName(projectItem.ProjectItems);

            if (!string.IsNullOrEmpty(headerFile))
            {
                return(LoadHeaderDefinition(headerFile)); //Found a License header file on this level
            }
            var projectItemParent = ProjectItemParentFinder.GetProjectItemParent(projectItem);

            //Lookup in the parent --> Go Up!
            return(SearchWithinProjectGetHeaderDefinitionForProjectOrItem(projectItemParent));
        }