Reputation: 63870
Suppose I have a new interface:
public interface IClientRepository
{
void Add(Customer customer);
void Remove(Customer customer);
Customer Get(long id);
}
Now I'd like to do the following:
ClientRepository
");I think I've seen instructors of Pluralsight videos do this on numerous occasions, but I can't seem to find out what keyboard shortcuts to use for this.
What have I tried? Well:
What am I missing here? How do you generate a class from an interface?
Upvotes: 6
Views: 2116
Reputation: 23767
Put the cursor on the interface type name, for instance here:
public interface |IClientRepository
Hit Alt+Enter, and select Create Derived Type. This creates a class called ClientRepository
in the same file as IClientRepository
.
Now put your cursor on the class type name of ClientRepository
, and hit Ctrl+R, Ctrl+O and select Move to another file. It will default to a file name that matches the type name and puts it in the same directory as the file it was moved from.
Upvotes: 10
Reputation: 1668
I think Resharper does not have this possibility. However you can do it semi-manually. Type the following in the same file where
public class ClientRepository : IClientRepository {}
Then use implement members
command.
Then use refactor -> move to another file
command on the class
Upvotes: 0
Reputation: 3466
I don't use ReSharper, but I think you have to declare your class as derived from the interface, and then use ReSharper to implement the interface members, as explained here.
You can probably create the new class in the same file as the interface, and then use some "move" refactoring to create the corresponding files.
Upvotes: 0