当前位置: 首页>>代码示例>>C#>>正文


C# ProjectItem.Remove方法代码示例

本文整理汇总了C#中ProjectItem.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# ProjectItem.Remove方法的具体用法?C# ProjectItem.Remove怎么用?C# ProjectItem.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ProjectItem的用法示例。


在下文中一共展示了ProjectItem.Remove方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProcessFolderItem

        public override void ProcessFolderItem(ProjectItem projectItem)
        {
            string ttFileFullName = string.Empty;
            string childFileFullName = string.Empty;
            string targetFileFullName = string.Empty;

            try
            {
                file = folder.ProjectItems.Item(projectItem.Name);
                // Add tableProject .tt child to targetProject.
                if (file != null)
                {
                    ttFileFullName = GetLocalPath(file);
                    childFileFullName = GetPathToT4Child(file);

                    targetProject = FindProjectInTargetSolution(targetSolution2, project.UniqueName);
                    targetFolder = FindFolderInTargetProject(targetProject, folder);

                    // Add the Table .cs file to the TargetFolder. (automatically adds it to file system)
                    targetFileFullName = string.Format(@"{0}{1}\{2}", targetProject.FullName.Substring(0, targetProject.FullName.LastIndexOf("\\")+1),
                        targetFolder.Name, childFileFullName.Substring(childFileFullName.LastIndexOf("\\")+1));
                    if (Connect.settingsObject.RemoveEntity == true)
                    {
                        targetFile = targetFolder.ProjectItems.Item(childFileFullName.Substring(childFileFullName.LastIndexOf("\\") + 1));
                        if (targetFile != null)
                        {
                            targetFile.Remove();
                            if (File.Exists(targetFileFullName)) { File.Delete(targetFileFullName); }
                        }
                    }
                    else
                    {
                        if (File.Exists(targetFileFullName)) { File.Delete(targetFileFullName); }
                        File.Copy(childFileFullName, targetFileFullName);
                        targetFolder.ProjectItems.AddFromFile(targetFileFullName);
                    }

                    MessageService.WriteMessage(string.Format("GCFile renamed. {0}", childFileFullName));
                }
                else
                {
                    MessageService.WriteMessage(string.Format("File: {0} not found", projectItem.Name));
                }
            }
            catch (Exception ex)
            {
                if (ex.Message == "Value does not fall within the expected range.")
                {
                    MessageService.WriteMessage(string.Format("Template: {0} not found", projectItem.Name));
                }
                else
                {
                    throw ex;
                }
            }
        }
开发者ID:ronlemire2,项目名称:PrismRT-CodeGen-v2,代码行数:56,代码来源:ProjectTreeOperations.cs

示例2: RenameItem

        private void RenameItem(ProjectItem item, string newFileName)
        {
            var templateFile = item.get_FileNames(1);

            var newFile = Path.Combine(Path.GetDirectoryName(templateFile), newFileName);
            File.Copy(templateFile, newFile);
            item.Collection.AddFromFile(newFile);

            item.Remove();
            File.Delete(templateFile);
        }
开发者ID:569550384,项目名称:Rafy,代码行数:11,代码来源:DomainLibraryProjectWizard.cs

示例3: ProjectItemFinishedGenerating

        public override void ProjectItemFinishedGenerating(ProjectItem projectItem)
        {
            if (!projectItem.Name.Contains(".g.cs"))
            {
                _entityRepoFile = projectItem;
            }
            else
            {
                //把生成文件变为实体文件的子文件。
                if (_entityRepoFile != null)
                {
                    projectItem.Remove();
                    _entityRepoFile.ProjectItems.AddFromFile(projectItem.get_FileNames(1));
                }
            }

            base.ProjectItemFinishedGenerating(projectItem);
        }
开发者ID:569550384,项目名称:Rafy,代码行数:18,代码来源:DomainEntityRepositoryItemWizard.cs

示例4: ProjectItemFinishedGenerating

        public override void ProjectItemFinishedGenerating(ProjectItem projectItem)
        {
            if (!projectItem.Name.Contains(".g.cs"))
            {
                _entityFile = projectItem;

                //给父实体添加列表属性。
                if (_isChild)
                {
                    WriteChildrenProperty(projectItem);
                }
            }
            else
            {
                //把生成文件变为实体文件的子文件。
                if (_entityFile != null)
                {
                    projectItem.Remove();
                    _entityFile.ProjectItems.AddFromFile(projectItem.get_FileNames(1));
                }
            }

            base.ProjectItemFinishedGenerating(projectItem);
        }
开发者ID:569550384,项目名称:Rafy,代码行数:24,代码来源:DomainEntityItemWizard.cs

示例5: csharpItemAdded

        private void csharpItemAdded(ProjectItem item)
        {
            try
            {
                if(item == null)
                {
                    return;
                }

                if(String.IsNullOrEmpty(item.Name) || item.ContainingProject == null)
                {
                    return;
                }

                if(!Util.isSliceBuilderEnabled(item.ContainingProject))
                {
                    return;
                }

                if(!Util.isSliceFilename(item.Name))
                {
                    return;
                }

                string fullPath = item.Properties.Item("FullPath").Value.ToString();
                Project project = item.ContainingProject;

                String csPath = getCSharpGeneratedFileName(project, item, "cs");
                ProjectItem csItem = Util.findItem(csPath, project.ProjectItems);

                if(File.Exists(csPath) || csItem != null)
                {
                    MessageBox.Show("A file named '" + Path.GetFileName(csPath) +
                                    "' already exists.\n" + "If you want to add '" +
                                    Path.GetFileName(fullPath) + "' first remove " +
                                    " '" + Path.GetFileName(csPath) + "'.",
                                    "Ice Visual Studio Add-in",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error,
                                    MessageBoxDefaultButton.Button1,
                                    (MessageBoxOptions)0);
                    _deleted.Add(fullPath);
                    item.Remove();
                    return;
                }

                clearErrors(project);
                buildProject(project, false, vsBuildScope.vsBuildScopeProject);
            }
            catch(Exception ex)
            {
                Util.unexpectedExceptionWarning(ex);
                throw;
            }
        }
开发者ID:bholl,项目名称:zeroc-ice,代码行数:55,代码来源:Builder.cs

示例6: RemoveItemFromItems

        /// <summary>
        /// 移除项目中的项
        /// </summary>
        /// <param name="projectItem"></param>
        /// <param name="itemName">项名称</param>
        /// <param name="isDelete">是否删除或者移除</param>
        private bool RemoveItemFromItems(ProjectItem projectItem, string itemName, bool isDelete)
        {
            bool isRemove = false;
            ProjectItem item;
            if (projectItem.Name == itemName)
            {
                item = projectItem;
                if (isDelete)
                {
                    item.Delete();
                }
                else
                {
                    item.Remove();
                }
                isRemove = true;
            }
            else if (projectItem.ProjectItems.Count > 0)
            {
                item = FindProjectItem(projectItem, itemName);
                if (item.Name == itemName)
                {
                    if (isDelete)
                    {
                        item.Delete();
                    }
                    else
                    {
                        item.Remove();
                    }
                    isRemove = true;
                }
            }

            return isRemove;
        }
开发者ID:Allen-Zhou,项目名称:AF,代码行数:42,代码来源:ModelExtendEvent.cs

示例7: DeleteItem

        private void DeleteItem(ProjectItem projectItem, DTE vs)
        {
            string itemPath = DteHelper.BuildPath(projectItem);
            itemPath = DteHelper.GetPathFull(vs, itemPath);

            projectItem.Remove();
            projectItem.Delete();
        }
开发者ID:riseandcode,项目名称:open-wscf-2010,代码行数:8,代码来源:DeleteProjectItemsAction.cs


注:本文中的ProjectItem.Remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。