本文整理汇总了C#中Microsoft.VisualStudio.Project.ProjectElement.SetMetadata方法的典型用法代码示例。如果您正苦于以下问题:C# ProjectElement.SetMetadata方法的具体用法?C# ProjectElement.SetMetadata怎么用?C# ProjectElement.SetMetadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.VisualStudio.Project.ProjectElement
的用法示例。
在下文中一共展示了ProjectElement.SetMetadata方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetProjectElementBasedOnInputFromComponentSelectorData
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: return
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;
}
示例3: AddNonMemberFileItems
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();
}
}
示例4: AddNonmemberFileItems
/// <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();
}
}
}
示例5: BindReferenceData
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;
}
}
示例6: return
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;
}
示例7: AddNonMemberFileItems
/// <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));
}
}
}
示例8: AddFolderToMSBuild
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);
}
}