SetMetadata() public method

Set an attribute on the project element
public SetMetadata ( string attributeName, string attributeValue ) : void
attributeName string Name of the attribute to set
attributeValue string Value to give to the attribute. Use null to delete the metadata definition.
return void
コード例 #1
0
        private ProjectElement GetProjectElementBasedOnInputFromComponentSelectorData()
        {
            ProjectElement element = new ProjectElement(this.ProjectMgr, this.typeName, ProjectFileConstants.COMReference);

            // Set the basic information regarding this COM component
            element.SetMetadata(ProjectFileConstants.Guid, this.typeGuid.ToString("B"));
            element.SetMetadata(ProjectFileConstants.VersionMajor, this.majorVersionNumber);
            element.SetMetadata(ProjectFileConstants.VersionMinor, this.minorVersionNumber);
            element.SetMetadata(ProjectFileConstants.Lcid, this.lcid);
            element.SetMetadata(ProjectFileConstants.Isolated, false.ToString());

            // See if a PIA exist for this component
            TypeLibConverter typelib = new TypeLibConverter();
            string           assemblyName;
            string           assemblyCodeBase;

            if (typelib.GetPrimaryInteropAssembly(this.typeGuid, Int32.Parse(this.majorVersionNumber, CultureInfo.InvariantCulture), Int32.Parse(this.minorVersionNumber, CultureInfo.InvariantCulture), Int32.Parse(this.lcid, CultureInfo.InvariantCulture), out assemblyName, out assemblyCodeBase))
            {
                element.SetMetadata(ProjectFileConstants.WrapperTool, WrapperToolAttributeValue.Primary.ToString().ToLowerInvariant());
            }
            else
            {
                // MSBuild will have to generate an interop assembly
                element.SetMetadata(ProjectFileConstants.WrapperTool, WrapperToolAttributeValue.TlbImp.ToString().ToLowerInvariant());
                element.SetMetadata(ProjectFileConstants.EmbedInteropTypes, true.ToString());
                element.SetMetadata(ProjectFileConstants.Private, true.ToString());
            }
            return(element);
        }
コード例 #2
0
        private static void AddNonMemberFileItems(XProjectNode project, IList <string> fileList)
        {
            Utilities.ArgumentNotNull("fileList", fileList);

            foreach (string fileKey in fileList)
            {
                HierarchyNode parentNode = project;
                string[]      pathItems  = fileKey.Split(new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar });

                if (String.Equals(fileKey, project.ProjectFile, StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }

                XFolderNode topFolderNode = null;
                foreach (string fileOrDir in pathItems)
                {
                    string   childNodeId   = Path.Combine(parentNode.VirtualNodeName, fileOrDir);
                    FileInfo fileOrDirInfo = new FileInfo(Path.Combine(project.ProjectFolder, childNodeId));
                    if ((fileOrDirInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
                    {
                        break;
                    }

                    //HierarchyNode childNode = project.FindURL(fileOrDirInfo.FullName);
                    HierarchyNode childNode = parentNode.FindChild(childNodeId);
                    if (childNode == null)
                    {
                        if (topFolderNode == null)
                        {
                            topFolderNode = parentNode as XFolderNode;
                            if (topFolderNode != null && (!topFolderNode.IsNonMemberItem) && topFolderNode.IsExpanded)
                            {
                                topFolderNode = null;
                            }
                        }

                        ProjectElement element = new ProjectElement(project, null, true);
                        element.Rename(childNodeId);
                        element.SetMetadata(ProjectFileConstants.Name, childNodeId);
                        childNode = project.CreateFileNode(element);
                        parentNode.AddChild(childNode);
                        break;
                    }

                    parentNode = childNode;
                }
                ThreadHelper.ThrowIfNotOnUIThread();

                if (topFolderNode != null)
                {
                    topFolderNode.CollapseFolder();
                }
            }
        }
コード例 #3
0
        private ProjectElement GetProjectElementBasedOnInputFromComponentSelectorData()
        {

            ProjectElement element = new ProjectElement(this.ProjectMgr, this.typeName, ProjectFileConstants.COMReference);

            // Set the basic information regarding this COM component
            element.SetMetadata(ProjectFileConstants.Guid, this.typeGuid.ToString("B"));
            element.SetMetadata(ProjectFileConstants.VersionMajor, this.majorVersionNumber);
            element.SetMetadata(ProjectFileConstants.VersionMinor, this.minorVersionNumber);
            element.SetMetadata(ProjectFileConstants.Lcid, this.lcid);
            element.SetMetadata(ProjectFileConstants.Isolated, false.ToString());

            // See if a PIA exist for this component
            TypeLibConverter typelib = new TypeLibConverter();
            string assemblyName;
            string assemblyCodeBase;
            if(typelib.GetPrimaryInteropAssembly(this.typeGuid, Int32.Parse(this.majorVersionNumber, CultureInfo.InvariantCulture), Int32.Parse(this.minorVersionNumber, CultureInfo.InvariantCulture), Int32.Parse(this.lcid, CultureInfo.InvariantCulture), out assemblyName, out assemblyCodeBase))
            {
                element.SetMetadata(ProjectFileConstants.WrapperTool, WrapperToolAttributeValue.Primary.ToString().ToLowerInvariant());
            }
            else
            {
                // MSBuild will have to generate an interop assembly
                element.SetMetadata(ProjectFileConstants.WrapperTool, WrapperToolAttributeValue.TlbImp.ToString().ToLowerInvariant());
                element.SetMetadata(ProjectFileConstants.EmbedInteropTypes, true.ToString());
                element.SetMetadata(ProjectFileConstants.Private, true.ToString());
            }
            return element;
        }
コード例 #4
0
        private static void AddNonMemberFileItems(ProjectNode project, IEnumerable<string> fileList)
        {
            ErrorHelper.ThrowIsNull(fileList, "fileList");

            foreach (string fileKey in fileList)
            {
                HierarchyNode parentNode = project;
                string[] pathItems = fileKey.Split(new[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar });

                if (StringComparer.OrdinalIgnoreCase.Equals(fileKey, project.ProjectFile))
                    continue;

                NemerleFolderNode topFolderNode = null;
                foreach (string fileOrDir in pathItems)
                {
                    string childNodeId = Path.Combine(parentNode.VirtualNodeName, fileOrDir);
                    FileInfo fileOrDirInfo = new FileInfo(Path.Combine(project.ProjectFolder, childNodeId));
                    if ((fileOrDirInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
                        break;

                    HierarchyNode childNode = parentNode.FindChild(childNodeId);
                    if (childNode == null)
                    {
                        if (topFolderNode == null)
                        {
                            topFolderNode = parentNode as NemerleFolderNode;
                            if (topFolderNode != null && (!topFolderNode.IsNonMemberItem) && topFolderNode.IsExpanded)
                                topFolderNode = null;
                        }

                        ProjectElement element = new ProjectElement(project, null, true);
                        element.Rename(childNodeId);
                        element.SetMetadata(ProjectFileConstants.Name, childNodeId);
                        childNode = project.CreateFileNode(element);
                        parentNode.AddChild(childNode);
                        break;
                    }

                    parentNode = childNode;
                }

                if (topFolderNode != null)
                    topFolderNode.CollapseFolder();
            }
        }
コード例 #5
0
ファイル: NemerleFolderNode.cs プロジェクト: vestild/nemerle
        int IProjectSourceNode.ExcludeFromProject()
        {
            NemerleProjectNode projectNode = ProjectMgr as NemerleProjectNode;
            if (projectNode == null || projectNode.IsClosed)
                return (int)OleConstants.OLECMDERR_E_NOTSUPPORTED;

            if (IsNonMemberItem)
                return VSConstants.S_OK; // do nothing, just ignore it.

            ((NemerlePackage)ProjectMgr.Package).SetWaitCursor();

            // Check out the project file.
            if (!projectNode.QueryEditProjectFile(false))
                throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED);

            // remove children, if any, before removing from the hierarchy
            for (HierarchyNode child = FirstChild; child != null; child = child.NextSibling)
            {
                IProjectSourceNode node = child as IProjectSourceNode;
                if (node == null) continue;

                int result = node.ExcludeFromProject();
                if (result != VSConstants.S_OK)
                    return result;
            }

            if (projectNode.ShowAllFilesEnabled && Directory.Exists(Url))
            {
                string url = Url;
                SetProperty((int)__VSHPROPID.VSHPROPID_IsNonMemberItem, true);
                ItemNode.RemoveFromProjectFile();
                ItemNode = new ProjectElement(ProjectMgr, null, true);  // now we have to create a new ItemNode to indicate that this is virtual node.
                ItemNode.Rename(url);
                ItemNode.SetMetadata(ProjectFileConstants.Name, Url);
                ReDraw(UIHierarchyElement.Icon); // we have to redraw the icon of the node as it is now not a member of the project and shoul be drawn using a different icon.
            }
            else if (Parent != null) // the project node has no parentNode
            {
                // this is important to make it non member item. otherwise, the multi-selection scenario would
                // not work if it has any parent child relation.
                SetProperty((int)__VSHPROPID.VSHPROPID_IsNonMemberItem, true);

                // remove from the hierarchy
                OnItemDeleted();
                Parent.RemoveChild(this);
                ItemNode.RemoveFromProjectFile();
            }

            HierarchyHelpers.RefreshPropertyBrowser(this);

            return VSConstants.S_OK;
        }
コード例 #6
0
ファイル: ProjectNode.cs プロジェクト: sharwell/MPFProj10
        /// <summary>
        /// Adds non member file items to the hierarcy.
        /// </summary>
        /// <param name="project">The project to modify.</param>
        /// <param name="fileList">Files containing the information about the non member file items.</param>
        protected virtual void AddNonmemberFileItems(IList<string> fileList)
        {
            if (fileList == null)
                throw new ArgumentNullException("fileList");

            foreach (string fileKey in fileList)
            {
                HierarchyNode parentNode = this;
                FolderNode topFolderNode = null;

                string canonicalName = fileKey;
                if (!Path.IsPathRooted(canonicalName))
                    canonicalName = Path.Combine(ProjectManager.BaseUri.AbsoluteUrl, fileKey);

                if (fileKey.IndexOfAny(new[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }) < 0)
                {
                    // the parent is the project node, just make sure this isn't the project file itself
                    if (NativeMethods.IsSamePath(ProjectFile, canonicalName))
                        continue;
                }
                else
                {
                    string directoryCanonicalName = Path.GetDirectoryName(canonicalName) + '\\';
                    ReadOnlyCollection<HierarchyNode> parentFolderNodes = itemIdMap.GetNodesByName(directoryCanonicalName);
                    if (parentFolderNodes.Count == 1)
                    {
                        parentNode = parentFolderNodes[0];
                        for (HierarchyNode parentChain = parentNode; parentChain != null; parentChain = parentChain.Parent)
                        {
                            FolderNode folderNode = parentChain as FolderNode;
                            if (folderNode != null)
                                topFolderNode = folderNode;
                        }

                        if (topFolderNode != null && !topFolderNode.IsNonmemberItem && topFolderNode.IsExpanded)
                            topFolderNode = null;
                    }
                }

                ProjectElement element = new ProjectElement(this, null, true);
                element.Rename(canonicalName);
                element.SetMetadata(ProjectFileConstants.Name, canonicalName);
                HierarchyNode childNode = this.CreateFileNode(element);
                parentNode.AddChild(childNode);

                if (topFolderNode != null)
                {
                    topFolderNode.CollapseFolder();
                }
            }
        }
コード例 #7
0
        protected override void BindReferenceData()
        {
            if (ItemNode == null || ItemNode.Item == null)
            {
                ProjectElement element = new ProjectElement(ProjectManager, ProjectRelativeFilePath, DartProjectFileConstants.JarReference);

                // Set the basic information about this reference
                element.SetMetadata(DartProjectFileConstants.IncludeInBuild, true.ToString());
                element.SetMetadata(ProjectFileConstants.Private, false.ToString());

                ItemNode = element;
            }
        }
コード例 #8
0
ファイル: NemerleFileNode.cs プロジェクト: vestild/nemerle
        int IProjectSourceNode.ExcludeFromProject()
        {
            if (ProjectMgr == null || ProjectMgr.IsClosed)
                return (int)OleConstants.OLECMDERR_E_NOTSUPPORTED;

            if (IsNonMemberItem)
                return VSConstants.S_OK; // do nothing, just ignore it.

            ((NemerlePackage)ProjectMgr.Package).SetWaitCursor();
            // Ask Document tracker listeners if we can remove the item.
            { // just to limit the scope.
                string documentToRemove = GetMkDocument();
                string[] filesToBeDeleted = new[] { documentToRemove };
                VSQUERYREMOVEFILEFLAGS[] queryRemoveFlags = GetQueryRemoveFileFlags(filesToBeDeleted);
                if (!ProjectMgr.Tracker.CanRemoveItems(filesToBeDeleted, queryRemoveFlags))
                    return (int)OleConstants.OLECMDERR_E_CANCELED;

                // Close the document if it has a manager.
                DocumentManager manager = GetDocumentManager();
                if (manager != null)
                {
                    if (manager.Close(__FRAMECLOSE.FRAMECLOSE_PromptSave) == VSConstants.E_ABORT)
                        return VSConstants.OLE_E_PROMPTSAVECANCELLED;
                }

                if (!ProjectMgr.QueryEditProjectFile(false))
                    throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED);
            }

            // close the document window if open.
            CloseDocumentWindow(this);

            NemerleProjectNode projectNode = ProjectMgr as NemerleProjectNode;

            if (projectNode != null && projectNode.ShowAllFilesEnabled && File.Exists(Url))
            {
                string url = Url; // need to store before removing the node.
                ItemNode.RemoveFromProjectFile();
                ProjectMgr.Tracker.OnItemRemoved(url, VSREMOVEFILEFLAGS.VSREMOVEFILEFLAGS_NoFlags);
                SetProperty((int)__VSHPROPID.VSHPROPID_IsNonMemberItem, true); // Set it as non member item
                ItemNode = new ProjectElement(ProjectMgr, null, true); // now we have to set a new ItemNode to indicate that this is virtual node.
                ItemNode.Rename(url);
                ItemNode.SetMetadata(ProjectFileConstants.Name, url);

                //ProjectMgr.OnItemDeleted();
                var proj = ProjectInfo.FindProject(ProjectMgr);
                if (proj != null)
                    proj.RemoveSource(this.Url);

                ReDraw(UIHierarchyElement.Icon); // We have to redraw the icon of the node as it is now not a member of the project and should be drawn using a different icon.
                ReDraw(UIHierarchyElement.SccState); // update the SCC state icon.
            }
            else if (Parent != null) // the project node has no parentNode
            {
                // Remove from the Hierarchy
                OnItemDeleted();
                Parent.RemoveChild(this);
                ItemNode.RemoveFromProjectFile();
            }

            ResetProperties();

            HierarchyHelpers.RefreshPropertyBrowser(this);

            return VSConstants.S_OK;
        }
コード例 #9
0
ファイル: ProjectNode.cs プロジェクト: julianhaslinger/SHFB
        /// <summary>
        /// Add non-member file items to the hierarchy
        /// </summary>
        /// <param name="filesToAdd">An enumerable list of the files to add</param>
        private void AddNonMemberFileItems(IEnumerable<string> filesToAdd)
        {
            IVsUIHierarchyWindow uiWindow = UIHierarchyUtilities.GetUIHierarchyWindow(this.Site, SolutionExplorer);
            HierarchyNode parent, child, first;
            ProjectElement element;
            string[] pathParts;
            string childId;

            foreach(string relativePath in filesToAdd)
            {
                // TODO: Probably should exclude the .user file too.  Any others?
                // Don't add the project file itself
                if(String.Equals(relativePath, this.ProjectFile, StringComparison.OrdinalIgnoreCase))
                    continue;

                parent = this;
                first = null;
                pathParts = relativePath.Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);

                // Find the parent folder item
                foreach(string name in pathParts)
                {
                    childId = Path.Combine(parent.VirtualNodeName, name);
                    child = parent.FindChild(childId);

                    if(child == null)
                    {
                        // Note the first folder so that we can collapse it when done if necessary
                        if(first == null)
                        {
                            first = parent as FolderNode;

                            if(first != null && !first.IsNonMemberItem && first.IsExpanded)
                                first = null;
                        }

                        element = new ProjectElement(this, null, true);
                        element.Rename(childId);
                        element.SetMetadata(ProjectFileConstants.Name, childId);
                        child = this.CreateFileNode(element);
                        child.IsNonMemberItem = true;
                        parent.AddChild(child);
                        break;
                    }

                    parent = child;
                }

                if(first != null)
                {
                    first.IsExpanded = false;
                    first.SetProperty((int)__VSHPROPID.VSHPROPID_Expanded, false);
                    ErrorHandler.ThrowOnFailure(uiWindow.ExpandItem(this, first.ID, EXPANDFLAGS.EXPF_CollapseFolder));
                }
            }
        }
コード例 #10
0
ファイル: DartProjectNode.cs プロジェクト: modulexcite/DartVS
 protected override ProjectElement AddFolderToMSBuild(string folder, string itemType)
 {
     if (itemType == ProjectFileConstants.Folder)
     {
         ProjectElement folderElement = new ProjectElement(this, null, true);
         folderElement.Rename(folder);
         folderElement.SetMetadata(ProjectFileConstants.Name, folder);
         folderElement.SetMetadata(ProjectFileConstants.BuildAction, itemType);
         return folderElement;
     }
     else
     {
         return base.AddFolderToMSBuild(folder, itemType);
     }
 }