Пример #1
0
        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);
        }
Пример #2
0
 internal void Remove(IVSProjectItem item)
 {
     childItems.Remove(item);
 }