The following conditions should be met for extracting interfaces:
- Only non-static methods can be extracted.
- All methods in the extracted interface are public.
- If the name specified for the new interface coincides with the name of an existing interface in the same namespace, all the methods will be extracted into an existing interface.
To extract an interface:
- Select one or more code elements (class, interface, field, method, event, property, or indexer) in the Diagram View or Model View.
- On the main menu, choose RefactoringExtract Interface
Tip: Alternatively, you can choose Refactoring->Extract Interface on the context menu of the selection.
- In the Extract interface dialog box, enter the name for the interface and designate its namespace, if applicable.
- Specify the members to be used in the resulting interface by setting or clearing the respective check-boxes.
- Click OK. The Refactoring window opens allowing you to review the refactoring before committing to it.
- Click the Perform refactoring button to complete the extraction.