Exemplo n.º 1
0
 /// <summary>
 /// Constructor for the DependentFileNode
 /// </summary>
 /// <param name="root">Root of the hierarchy</param>
 /// <param name="e">Associated project element</param>
 public DependentFileNode(ProjectNode root, MsBuildProjectElement element)
     : base(root, element)
 {
     this.HasParentNodeNameRelation = false;
 }
Exemplo n.º 2
0
 public JNonCodeFileNode(CommonProjectNode root, MsBuildProjectElement e)
     : base(root, e)
 {
 }
Exemplo n.º 3
0
        /// <summary>
        /// Links a reference node to the project and hierarchy.
        /// </summary>
        protected override void BindReferenceData()
        {
            Debug.Assert(_filename != null, "The _filename field has not been initialized");

            // If the item has not been set correctly like in case of a new reference added it now.
            // The constructor for the AssemblyReference node will create a default project item. In that case the Item is null.
            // We need to specify here the correct project element.
            if (ItemNode == null || ItemNode is VirtualProjectElement) {
                ItemNode = new MsBuildProjectElement(ProjectMgr, _filename, ProjectFileConstants.Reference);
            }

            // Set the basic information we know about
            ItemNode.SetMetadata(ProjectFileConstants.Name, Path.GetFileName(_filename));
            string relativePath = CommonUtils.GetRelativeFilePath(ProjectMgr.ProjectFolder, _filename);
            ItemNode.SetMetadata(JConstants.JExtension, relativePath);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Links a reference node to the project and hierarchy.
        /// </summary>
        protected override void BindReferenceData()
        {
            Debug.Assert(_feed != null, "The _filename field has not been initialized");

            // If the item has not been set correctly like in case of a new reference added it now.
            // The constructor for the AssemblyReference node will create a default project item. In that case the Item is null.
            // We need to specify here the correct project element.
            if (ItemNode == null || ItemNode is VirtualProjectElement) {
                ItemNode = new MsBuildProjectElement(
                    ProjectMgr,
                    _feed + "?" + _productId,
                    ProjectFileConstants.WebPiReference
                );
            }

            // Set the basic information we know about
            ItemNode.SetMetadata("Feed", _feed);
            ItemNode.SetMetadata("ProductId", _productId);
            ItemNode.SetMetadata("FriendlyName", _friendlyName);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Adds references to this container from a MSBuild project.
        /// </summary>
        public void LoadReferencesFromBuildProject(MSBuild.Project buildProject)
        {
            foreach (string referenceType in SupportedReferenceTypes)
            {
                IEnumerable<MSBuild.ProjectItem> refererncesGroup = this.ProjectMgr.BuildProject.GetItems(referenceType);

                bool isAssemblyReference = referenceType == ProjectFileConstants.Reference;
                // If the project was loaded for browsing we should still create the nodes but as not resolved.
                if (isAssemblyReference &&
                    (!ProjectMgr.BuildProject.Targets.ContainsKey(MsBuildTarget.ResolveAssemblyReferences) || this.ProjectMgr.Build(MsBuildTarget.ResolveAssemblyReferences) != MSBuildResult.Successful))
                {
                    continue;
                }

                foreach (MSBuild.ProjectItem item in refererncesGroup)
                {
                    ProjectElement element = new MsBuildProjectElement(this.ProjectMgr, item);

                    ReferenceNode node = CreateReferenceNode(referenceType, element);

                    if (node != null)
                    {
                        // Make sure that we do not want to add the item twice to the ui hierarchy
                        // We are using here the UI representation of the Node namely the Caption to find that out, in order to
                        // avoid different representation problems.
                        // Example :<Reference Include="EnvDTE80, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
                        //		  <Reference Include="EnvDTE80" />
                        bool found = false;
                        for (HierarchyNode n = this.FirstChild; n != null && !found; n = n.NextSibling)
                        {
                            if (String.Compare(n.Caption, node.Caption, StringComparison.OrdinalIgnoreCase) == 0)
                            {
                                found = true;
                            }
                        }

                        if (!found)
                        {
                            this.AddChild(node);
                        }
                    }
                }
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// Constructor for the FileNode
 /// </summary>
 /// <param name="root">Root of the hierarchy</param>
 /// <param name="e">Associated project element</param>
 public FileNode(ProjectNode root, MsBuildProjectElement element)
     : base(root, element)
 {
     if (this.ProjectMgr.NodeHasDesigner(this.ItemNode.GetMetadata(ProjectFileConstants.Include)))
     {
         this.HasDesigner = true;
     }
 }
Exemplo n.º 7
0
 public virtual CommonFileNode CreateNonCodeFileNode(MsBuildProjectElement item)
 {
     return new CommonNonCodeFileNode(this, item);
 }
Exemplo n.º 8
0
        /// <summary>
        /// Create a file node based on an msbuild item.
        /// </summary>
        /// <param name="item">The msbuild item to be analyzed</param>        
        public override FileNode CreateFileNode(MsBuildProjectElement item)
        {
            Utilities.ArgumentNotNull("item", item);

            CommonFileNode newNode;
            if (IsCodeFile(item.GetFullPathForElement())) {
                newNode = CreateCodeFileNode(item);
            } else {
                newNode = CreateNonCodeFileNode(item);
            }

            string link = item.GetMetadata(ProjectFileConstants.Link);
            if (!String.IsNullOrWhiteSpace(link) ||
                !CommonUtils.IsSubpathOf(ProjectHome, item.GetFullPathForElement())) {
                newNode.SetIsLinkFile(true);
            }

            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);

            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(CreateServices), false);
            return newNode;
        }
Exemplo n.º 9
0
        public override DependentFileNode CreateDependentFileNode(MsBuildProjectElement 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(CreateServices), false);
                }
            }

            return node;
        }
Exemplo n.º 10
0
 internal JFileNode(CommonProjectNode root, MsBuildProjectElement e)
     : base(root, e)
 {
 }
Exemplo n.º 11
0
 public CommonFileNode(CommonProjectNode root, MsBuildProjectElement e)
     : base(root, e)
 {
     _project = root;
 }