Microsoft.VisualStudio.Project.ProjectContainerNode.GetRegisteredProject C# (CSharp) Method

GetRegisteredProject() protected method

Get information from the registry based for the project factory corresponding to the TypeGuid of the element
protected GetRegisteredProject ( ProjectElement element ) : RegisteredProjectType
element ProjectElement
return RegisteredProjectType
        protected virtual RegisteredProjectType GetRegisteredProject(ProjectElement element)
        {
            ProjectElement elementToUse = (element == null) ? this.nestedProjectElement : element;

            if(elementToUse == null)
            {
                throw new ArgumentNullException("element");
            }

            // Get the project type guid from project elementToUse
            string typeGuidString = elementToUse.GetMetadataAndThrow(ProjectFileConstants.TypeGuid, new Exception());
            Guid projectFactoryGuid = new Guid(typeGuidString);

            EnvDTE.DTE dte = this.ProjectManager.Site.GetService(typeof(EnvDTE.DTE)) as EnvDTE.DTE;
            Debug.Assert(dte != null, "Could not get the automation object from the services exposed by this project");

            if(dte == null)
                throw new InvalidOperationException();

            RegisteredProjectType registeredProjectType = RegisteredProjectType.CreateRegisteredProjectType(projectFactoryGuid);
            Debug.Assert(registeredProjectType != null, "Could not read the registry setting associated to this project.");
            if(registeredProjectType == null)
            {
                throw new InvalidOperationException();
            }
            return registeredProjectType;
        }