Is there any way to edit all classes in a folder to inherit from certain base class?

I have 60 or so classes in a folder and I created a base class for those classes to inherit from.

Is there any automatic way to do this other than copy&paste method in Visual Studio?

I hoped resharper has some functionality for that but can't find one.

Answers


You can automate the cut/paste process by using the search and replace feature of Visual Studio to find all declarations, and replace them with declarations that inherit from your base class.

  • Press [Ctrl+H] to open Quick Replace
  • Enter public class {:i} in the "Find what" box
  • Enter public class \1 : MyBaseClass in the "Replace with:" box
  • Choose "Current Project" in the "Look in:" box
  • Check the "Use:" checkbox, and pick "Regular expressions" in the dropdown

Keep clicking [Find Next] to find the next occurrence of a class declaration. If the search highlights one of the sixty declarations that you want to modify, click [Replace], otherwise keep clicking [Find Next].


Need Your Help

Managing IntelliJ Tool Windows, how to

intellij-idea

Currently my IntelliJ shows amongst other things

filter-name element is missing in generated web.xml

weblogic-10.x struts-1 java-6 ejb-2.x

One of our old applications uses Struts-1.2 and EJB-2, generated with xdoclet 1.2.3. Maven 1 is used to build the application using java 1.4. The application has been running in weblogic 8.1 withou...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.