Example #1
0
        public int get_CanonicalName(out string pbstrCanonicalName)
        {
            // Get the output assembly path (including the name)
            pbstrCanonicalName = output.GetMetadata(ProjectFileConstants.Include);
            Debug.Assert(!String.IsNullOrEmpty(pbstrCanonicalName), "Output Assembly not defined");

            // Make sure we have a full path
            if (!System.IO.Path.IsPathRooted(pbstrCanonicalName))
            {
                pbstrCanonicalName = new Url(project.BaseURI, pbstrCanonicalName).AbsoluteUrl;
            }
            return(VSConstants.S_OK);
        }
        /// <summary>
        /// Based on the Template and TypeGuid properties of the
        /// element, generate the full template path.
        ///
        /// TypeGuid should be the Guid of a registered project factory.
        /// Template can be a full path, a project template (for projects
        /// that support VsTemplates) or a relative path (for other projects).
        /// </summary>
        protected virtual string GetProjectTemplatePath(ProjectElement element)
        {
            ProjectElement elementToUse = (element == null) ? this.nestedProjectElement : element;

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

            string templateFile = elementToUse.GetMetadata(ProjectFileConstants.Template);

            Debug.Assert(!String.IsNullOrEmpty(templateFile), "No template file has been specified in the template attribute in the project file");

            string fullPath = templateFile;

            if (!Path.IsPathRooted(templateFile))
            {
                RegisteredProjectType registeredProjectType = this.GetRegisteredProject(elementToUse);

                // This is not a full path
                Debug.Assert(registeredProjectType != null && (!String.IsNullOrEmpty(registeredProjectType.DefaultProjectExtensionValue) || !String.IsNullOrEmpty(registeredProjectType.WizardTemplatesDirValue)), " Registered wizard directory value not set in the registry.");

                // See if this specify a VsTemplate file
                fullPath = registeredProjectType.GetVsTemplateFile(templateFile);
                if (String.IsNullOrEmpty(fullPath))
                {
                    // Default to using the WizardTemplateDir to calculate the absolute path
                    fullPath = Path.Combine(registeredProjectType.WizardTemplatesDirValue, templateFile);
                }
            }

            return(fullPath);
        }
        /// <summary>
        /// Creates a file node for a project element.
        /// </summary>
        /// <param name="element">The project element.</param>
        /// <returns>An instance of the <see cref="FileNode"/> class.</returns>
        public override FileNode CreateFileNode(ProjectElement element)
        {
            if (element == null)
                throw new ArgumentNullException("element");

            MultiverseInterfaceFileNode node = null;

            // Get the SubType for the project element.
            string subType = element.GetMetadata(ProjectFileConstants.SubType);

            switch (subType)
            {
                case MultiverseInterfaceSubType.Code:
                    node = new MultiverseInterfacePythonFileNode(this, element);
                    break;
                case MultiverseInterfaceSubType.Frame:
                    node = new MultiverseInterfaceXmlFileNode(this, element);
                    break;
                case MultiverseInterfaceSubType.TableOfContents:
                    node = new MultiverseInterfaceTocFileNode(this, element);
                    break;
                default:
                    // We could not recognize the file subtype, just create a WowFileNode
                    node = new MultiverseInterfaceFileNode(this, element);
                    break;
            }

            // Check whether this file should be added to the language service
            if (subType == MultiverseInterfaceSubType.Frame || subType == MultiverseInterfaceSubType.Code)
            {
                IPythonLanguageService languageService = (IPythonLanguageService)this.GetService(typeof(IPythonLanguageService));

                // Make sure the language service is available
                if (languageService != null)
                {
                    switch (subType)
                    {
                        case MultiverseInterfaceSubType.Frame:
                            languageService.AddFrameXmlFile(node.GetMkDocument());
                            break;
                        case MultiverseInterfaceSubType.Code:
                            languageService.AddPythonFile(node.GetMkDocument());
                            break;
                    }
                }
            }

            return node;
        }
        /// <summary>
        /// Creates a file node for a project element.
        /// </summary>
        /// <param name="element">The project element.</param>
        /// <returns>An instance of the <see cref="DependentFileNode"/> class.</returns>
        public override DependentFileNode CreateDependentFileNode(ProjectElement element)
        {
            if (element == null)
                throw new ArgumentNullException("element");

            string subType = element.GetMetadata(ProjectFileConstants.SubType);

            if (subType == MultiverseInterfaceSubType.Code)
            {
                DependentFileNode node = new MultiverseInterfaceIronPythonDependentFileNode(this, element);

                IPythonLanguageService languageService = (IPythonLanguageService)this.GetService(typeof(IPythonLanguageService));

                // Make sure the language service is available
                if (languageService != null)
                    languageService.AddPythonFile(node.GetMkDocument());

                return node;
            }

            return base.CreateDependentFileNode(element);
        }
        /// <summary>
        /// Create a file node based on an msbuild item.
        /// </summary>
        /// <param name="item">The msbuild item to be analyzed</param>
        /// <returns>PythonFileNode or FileNode</returns>
        public override FileNode CreateFileNode(ProjectElement item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            string include = item.GetMetadata(ProjectFileConstants.Include);
            PythonFileNode newNode = new PythonFileNode(this, item);
            newNode.OleServiceProvider.AddService(typeof(EnvDTE.Project), new OleServiceProvider.ServiceCreatorCallback(this.CreateServices), false);
            newNode.OleServiceProvider.AddService(typeof(EnvDTE.ProjectItem), newNode.ServiceCreator, false);
            if (!string.IsNullOrEmpty(include) && Path.GetExtension(include).Equals(".xaml", StringComparison.OrdinalIgnoreCase))
            {
                //Create a DesignerContext for the XAML designer for this file
                newNode.OleServiceProvider.AddService(typeof(DesignerContext), newNode.ServiceCreator, false);
            }
            newNode.OleServiceProvider.AddService(typeof(VSLangProj.VSProject), new OleServiceProvider.ServiceCreatorCallback(this.CreateServices), false);
            if (IsCodeFile(include))
            {
                newNode.OleServiceProvider.AddService(
                    typeof(SVSMDCodeDomProvider), new OleServiceProvider.ServiceCreatorCallback(this.CreateServices), false);
            }

            return newNode;
        }
        public override DependentFileNode CreateDependentFileNode(ProjectElement item)
        {
            DependentFileNode node = base.CreateDependentFileNode(item);
            if (null != node)
            {
                string include = item.GetMetadata(ProjectFileConstants.Include);
                if (IsCodeFile(include))
                {
                    node.OleServiceProvider.AddService(
                        typeof(SVSMDCodeDomProvider), new OleServiceProvider.ServiceCreatorCallback(this.CreateServices), false);
                }
            }

            return node;
        }
        public override FileNode CreateFileNode(ProjectElement item)
        {
            RubyFileNode newNode = new RubyFileNode(this, item);

            string include = item.GetMetadata(ProjectFileConstants.Include);

            newNode.OleServiceProvider.AddService(typeof(EnvDTE.Project), new OleServiceProvider.ServiceCreatorCallback(CreateServices), false);
            newNode.OleServiceProvider.AddService(typeof(EnvDTE.ProjectItem), newNode.ServiceCreator, false);
            newNode.OleServiceProvider.AddService(typeof(VSLangProj.VSProject), new OleServiceProvider.ServiceCreatorCallback(CreateServices), false);

            if (IsCodeFile(include))
                newNode.OleServiceProvider.AddService(typeof(SVSMDCodeDomProvider), newNode.ServiceCreator, false);
                // new OleServiceProvider.ServiceCreatorCallback(CreateServices), false);

            return newNode;
        }