<small id='CxrmM'></small><noframes id='CxrmM'>

  • <i id='CxrmM'><tr id='CxrmM'><dt id='CxrmM'><q id='CxrmM'><span id='CxrmM'><b id='CxrmM'><form id='CxrmM'><ins id='CxrmM'></ins><ul id='CxrmM'></ul><sub id='CxrmM'></sub></form><legend id='CxrmM'></legend><bdo id='CxrmM'><pre id='CxrmM'><center id='CxrmM'></center></pre></bdo></b><th id='CxrmM'></th></span></q></dt></tr></i><div id='CxrmM'><tfoot id='CxrmM'></tfoot><dl id='CxrmM'><fieldset id='CxrmM'></fieldset></dl></div>
  • <tfoot id='CxrmM'></tfoot>
      <bdo id='CxrmM'></bdo><ul id='CxrmM'></ul>

      <legend id='CxrmM'><style id='CxrmM'><dir id='CxrmM'><q id='CxrmM'></q></dir></style></legend>

        一次删除整个项目或解决方案中未使用的命名空间

        Remove unused namespaces across a whole project or solution at once(一次删除整个项目或解决方案中未使用的命名空间)

      1. <tfoot id='cijtV'></tfoot>

        <i id='cijtV'><tr id='cijtV'><dt id='cijtV'><q id='cijtV'><span id='cijtV'><b id='cijtV'><form id='cijtV'><ins id='cijtV'></ins><ul id='cijtV'></ul><sub id='cijtV'></sub></form><legend id='cijtV'></legend><bdo id='cijtV'><pre id='cijtV'><center id='cijtV'></center></pre></bdo></b><th id='cijtV'></th></span></q></dt></tr></i><div id='cijtV'><tfoot id='cijtV'></tfoot><dl id='cijtV'><fieldset id='cijtV'></fieldset></dl></div>

            • <legend id='cijtV'><style id='cijtV'><dir id='cijtV'><q id='cijtV'></q></dir></style></legend>
                <bdo id='cijtV'></bdo><ul id='cijtV'></ul>

                • <small id='cijtV'></small><noframes id='cijtV'>

                    <tbody id='cijtV'></tbody>
                • 本文介绍了一次删除整个项目或解决方案中未使用的命名空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我知道你可以逐个文件地做.

                  I know you can do it file by file.

                  是否有任何方法可以一步完成项目中的所有文件?

                  Is there any way to do this in one step for all files in a project?

                  推荐答案

                  你的意思是使用语句吗?首先,请注意,它们通常不会伤害其他占用空间的东西.ReSharper 等工具提供了自动执行此操作的技巧,但是:有一个 链接到VS提要一会儿前;归结为:

                  Do you mean using statements? First, note that they generally do no harm other that take space. Tools like ReSharper offer automated tricks to do this, however: there was a link in the VS feed a little while ago; it boils down to:

                  • 转到工具 -> 宏 -> 宏 IDE...
                  • 在 Project Explorer 中,添加 -> 添加模块...(输入名称 - 我使用了 OrganiseUsings)
                  • 粘贴下面的代码
                  • 文件 -> 保存 MyMacros,退出

                  现在,如果您右键单击工具栏并自定义... - 您应该能够找到 MyMacros.OrganiseUsings.RemoveAndSortAll - 将其拖到方便的地方(可能是工具菜单;您可能还想在放置后更改名称它).

                  Now if you right-click on the toolbar and Customize... - you should be able to find MyMacros.OrganiseUsings.RemoveAndSortAll - drag this somewhere handy (maybe the Tools menu; you might also want to change the name after placing it).

                  您现在可以使用此选项为整个解决方案运行删除和排序命令.大大节省时间.

                  You can now use this option to run the Remove and Sort command for an entire solution. A big time-saver.

                  ==== 代码 ====

                  ==== code ====

                  Imports System
                  Imports EnvDTE
                  Imports EnvDTE80
                  Imports EnvDTE90
                  Imports System.Diagnostics
                  
                  Public Module OrganiseUsings
                  
                      Public Sub RemoveAndSortAll()
                          On Error Resume Next
                          Dim sol As Solution = DTE.Solution
                  
                          For i As Integer = 1 To sol.Projects.Count    
                              Dim proj As Project = sol.Projects.Item(i)    
                              For j As Integer = 1 To proj.ProjectItems.Count    
                                  RemoveAndSortSome(proj.ProjectItems.Item(j))    
                              Next    
                          Next    
                      End Sub    
                  
                      Private Sub RemoveAndSortSome(ByVal projectItem As ProjectItem)
                          On Error Resume Next
                          If projectItem.Kind = Constants.vsProjectItemKindPhysicalFile Then    
                              If projectItem.Name.LastIndexOf(".cs") = projectItem.Name.Length - 3 Then
                                  Dim window As Window = projectItem.Open(Constants.vsViewKindCode)
                  
                                  window.Activate()
                  
                                  projectItem.Document.DTE.ExecuteCommand("Edit.RemoveAndSort")
                  
                                  window.Close(vsSaveChanges.vsSaveChangesYes)
                              End If    
                          End If    
                  
                          For i As Integer = 1 To projectItem.ProjectItems.Count    
                              RemoveAndSortSome(projectItem.ProjectItems.Item(i))    
                          Next
                      End Sub   
                  
                  End Module
                  

                  这篇关于一次删除整个项目或解决方案中未使用的命名空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  C# namespace alias - what#39;s the point?(C# 命名空间别名 - 有什么意义?)
                  Using Xpath With Default Namespace in C#(在 C# 中使用具有默认命名空间的 Xpath)
                  IBM.Data.DB2.Core connection problems(IBM.Data.DB2.Core 连接问题)
                  Generating an EDMX from a DB2 Database(从 DB2 数据库生成 EDMX)
                  Datetime field overflow with IBM Data Server Client v9.7fp5(IBM Data Server Client v9.7fp5 的日期时间字段溢出)
                  IBM .NET Data Provider Connection String issue with Library List(库列表的 IBM .NET 数据提供程序连接字符串问题)
                  <tfoot id='l1iiY'></tfoot>

                  • <bdo id='l1iiY'></bdo><ul id='l1iiY'></ul>
                      <tbody id='l1iiY'></tbody>

                          • <legend id='l1iiY'><style id='l1iiY'><dir id='l1iiY'><q id='l1iiY'></q></dir></style></legend>
                          • <small id='l1iiY'></small><noframes id='l1iiY'>

                            <i id='l1iiY'><tr id='l1iiY'><dt id='l1iiY'><q id='l1iiY'><span id='l1iiY'><b id='l1iiY'><form id='l1iiY'><ins id='l1iiY'></ins><ul id='l1iiY'></ul><sub id='l1iiY'></sub></form><legend id='l1iiY'></legend><bdo id='l1iiY'><pre id='l1iiY'><center id='l1iiY'></center></pre></bdo></b><th id='l1iiY'></th></span></q></dt></tr></i><div id='l1iiY'><tfoot id='l1iiY'></tfoot><dl id='l1iiY'><fieldset id='l1iiY'></fieldset></dl></div>