2

I create an item template and this template have to implement an interface.

Current template code:

namespace $rootnamespace$ {
public class $safeitemname$ : ITestA {
    public long? Id { get; set; }
    public string Years { get; set; }
}

I guess, I want to like this;

namespace $rootnamespace$ {
public class $safeitemname$ : $userselectedinterface$ {
    foreach(var prop in $userselectedinterface$.props)
        public prop.Type prop.Name {get; set;}
}

I have multiple interface like ITestA, so I need to create a wizard but how? I do not find any example like that.

How I create a wizard and choose an interface from solution?

is_oz
  • 813
  • 1
  • 8
  • 27
  • Are the interfaces included in the vsix? – Lars Kristensen Aug 06 '20 at 09:32
  • You need to clarify what interface(s) you wish to list in your wizard. Where are they defined? – Ed Dore Aug 08 '20 at 00:12
  • The interfaces are not included Visx. Like view page generator you need to get from project. Yes, that interfaces, user defined. Think MVC view page generator. It get all classes from project. – is_oz Aug 08 '20 at 03:02
  • Your custom IWizard implementation will need to leverage the CodeModel (https://learn.microsoft.com/en-us/dotnet/api/envdte.codemodel), or Roslyn (https://github.com/dotnet/roslyn/wiki/Roslyn%20Overview) API's to find the interfaces defined/declared in the current project. – Ed Dore Aug 17 '20 at 17:38

1 Answers1

0

you can use multiple inheritance like this:

public class Myclass : ITestA, ITestB {
    public long? Id { get; set; }
    public string Years { get; set; }
}

Then you can implement methods of both parent interfaces.

snus74
  • 421
  • 3
  • 9
  • But anyone want to choose another interface ITestC ? I need to get interfaces into a dropdown list. Then add each property to class. – is_oz Aug 05 '20 at 05:29
  • I don't know why you want to do that. you can create a dropdown list and create a new object of the class corresponding to the selected entry, why do you need the class interfaces to be different? – snus74 Aug 05 '20 at 07:06
  • I want to create a vsix, and add my project. I have similarities at code, so I want to select interface and implement it from template. For example, do you create a view at visual studio? You could select model, database etc. I want to similiar wizard like that. – is_oz Aug 05 '20 at 07:13
  • I am sorry but I don't understand what you want. Try adding vsix in your question Tags – snus74 Aug 05 '20 at 08:14