Basically, I have the following class within my Client.exe project:
Client.exe Project: Foo.cs
public class Foo
{
[Import(typeof(IBarService))
private IBarService MyBarService { get; set; }
...
}
CoolBarService.dll Project: CoolBarService.cs
[Export(typeof(IBarService))]
public class CoolBarService : IBarService
{
public int GetBar() { ... }
}
Where does IBarService go? Currently, I'm throwing it into a project class library of its own, which is then referenced by both projects, but I'm not sure if this is the best-practice or not. If I simply leave the IBarService in the Client app, the CoolBarService project can not compile because it has no idea what a IBarService is (unless of course, I copy the same code into it).
ServiceContracts.dll Project: IBarService.cs
publ开发者_JAVA技巧ic interface IBarService
{
int GetBar();
}
In this case it sounds like you do want to put your contracts in a separate contract assembly.
精彩评论