public void AddItem(string fileNameSource, string itemType, IVSProjectItem dependentUpon) { int count; ProjectMetadataElement metadataElement; var fileInfo = new FileInfo(projectFileName); string fileRelativePath; var projectDirectory = fileInfo.DirectoryName; ProjectItemElement itemElement; var itemGroup = rootElementContainer.Children.OfType <ProjectItemGroupElement>() .Where(p => p.Children.Cast <ProjectItemElement>() .Any(i => i.ItemType == "Compile")).Single(); fileInfo = new FileInfo(fileNameSource); itemCollection = (ICollection)s_ProjectRootElement_Items.GetValue(rootElement, null); count = itemCollection.Count; fileRelativePath = fileInfo.GetRelativePath(projectDirectory); itemElement = itemGroup.AddItem(itemType, fileRelativePath); itemCollection = (ICollection)s_ProjectRootElement_Items.GetValue(rootElement, null); count = itemCollection.Count; metadataElement = (ProjectMetadataElement)VSProjectItem.s_ProjectItemElement_AddMetadata.Invoke(itemElement, new object[] { "DependentUpon", Path.GetFileName(dependentUpon.FileName) }); AddToItems(fileNameSource, itemElement); }
internal void Remove(IVSProjectItem item) { childItems.Remove(item); }