How do I make a class inherit from an interface: public class Dog : INotifyPropertyChanged

I want to add the INotifyPropertyChanged interface to a


Example:
Change this:

public class Dog
        {
        }



to:

public class Dog : INotifyPropertyChanged
        {
        }
5 comments
Comment actions Permalink

EDIT: After reading Matt's answer, I think I finally understood your question. As a result, my answer is probably not helpfull at all. Sorry for that! xD

I'm not exactly sure what you question is, but you can find an example of how to use the INotifyPropertyChanged interface here. Look for the implementation of the class DemoCustomer.

Hope this helps... if not, please try to specify your problem more precisely!

0
Comment actions Permalink

Given a classDeclaration of type IClassDeclaration, you should be able to call IClassLikeDeclaration.AddSuperInterface(), passing in the declared type of the interface to add.

0
Comment actions Permalink

I found IClassLikeDeclaration.AddSuperInterface(), but have been unsuccessful in finding something to pass into AddSuperInterface() that would work. Can you provide a little more code on how/what I would pass into AddSuperInterface()? Thank you for your help.

0
Comment actions Permalink

Hi John. AddSuperInterface requires an IDeclaredType instance, which you can get in several ways. One of which is via the TypeFactory static class. You can call TypeFactory.CreateTypeByCLRName and pass in the fully qualified name of the type you're after. You also need to pass in an IPsiModule and a resolve context. The simplest way to do this is to use your classLikeDeclaration to do classLikeDeclaration.GetPsiModule() and classLikeDeclaration.GetResolveContext(). If you're after a predefined type that ReSharper will be using elsewhere (you mention INotifyPropertyChanged), you can use classLikeDeclaration.GetPsiModule().GetPredefinedType(classLikeDeclaration.GetResolveContext()).INotifyPropertyChanged. You can pass this value to AddSuperInterface.

Hope this helps
Matt

0
Comment actions Permalink

Thank you. That worked great.

0

Please sign in to leave a comment.