0
votes

I use Prism Unity in a WPF application and I have some problems to understand the correct implementation of a shared service.

I created a DLL Project and added an interface.

Interface (DLL):

public interface IMyservice
{
        string Version { get; }
        int DoSomething(int x, int y);
}

The interface implementation (class) is done inside of a module and the module is loaded on host application start, of course, I added my Interface DLL as a reference in my Host application.

ModuleA:

public class Myservice : IMyservice
{
   public string Version => "V1.00";
   public int DoSomething(int x, int y)
        {
            return x + y;
        }
}

I registered the IMyservice in the Bootstrapper of my Host application. I added to ModuleB Project the interface DLL as a reference, then I'm able to use the instance of Myservice by resolving from unity container.

container.Resolve<MyService>.DoSomething(1,1);

Questions:

  1. Is this architecture valid or I have to put the implementation of the interface into my interface.dll? I made the implementation of the interface in the module because I would like to share only with others my interface.dll and not the implementation. I put the implementation in the moduleA because I would like to have it modular.

  2. If this architecture is valid design, then I would like to know, how I'm able to handle the version description of my interface.dll and not the moduleA version description during runtime.

1
Do you want to version the implementation or the interface? Currently, you version the implementation, AdvancedServciemight return V2.00 for Version, but they both implement the same interface. Have a look at my answer to this related question: stackoverflow.com/questions/40827080/… - Haukinger
I would like version both interface and implementation, but independent from each other. - Shazter

1 Answers

0
votes

I would like version both interface and implementation, but independent from each other

Then you're on the right track, just add new versions of the interface. Because, you know, another interface is another interface, no matter whether or not one evolved out of the other... you'll end up with something like IMyService, IMyService2, IMyAdvancedService and so on and the consumers of the service will have to look which one of them has implementations and then select one of the implementations to interact with.

Anyway, there's no magic neither in Unity nor in Prism that divests you of that.