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:
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.
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.
AdvancedServciemight returnV2.00forVersion, but they both implement the same interface. Have a look at my answer to this related question: stackoverflow.com/questions/40827080/… - Haukinger