samedi 2 mai 2015

Convert a class to a possible interface

I have two Interfaces in different projects (these projects are not referenced to each other) which have the same methods like this:

In first project we have:

public interface IInterfaceA
{
     IAViewModel Do();
}
public interface IAViewModel
{
     int Id { get; set; }
}
public class ServiceA : IInterfaceB
{
     public IBViewModel Do()
     {
         return null;
     }
}

In second project we have:

public interface IInterfaceB
{
    IBViewModel Do();
}
public interface IBViewModel
{
    int Id { get; set; }
}

I can create an instance of ServiceA at runtime, using some Reflection, from second project.

The question is that how can I convert that service to IInterfaceB. I mean I want to access it's methods when someone is developing by referring as IInterfaceB .





Aucun commentaire:

Enregistrer un commentaire