I am in the process of converting some of my code to MEF from a proprietary system that sort of does the same thing as MEF, and I have a question about how I would accomplish the following problem that I recently ran into.
I have a typical entity object that looks something like this:
public class Account {
[Import]
public IAccountServerService { get; set; }
}
And a service object that needs to be imported in to the above entity object:
public class AccountServerService : IAccountServerService {
[ImportingConstructor]
public AccountServerService (Account account) { ... }
}
To put this into words I need the account
parameter passed into the AccountServerService
constructor instance to be the object of the calling Account
object. So that it act like this:
public class Account {
public IAccountServerService { get { return new AccountServerService (this); } }
}
Please let me know if this scenario is possible or if I have to refactor my service interface in this instance.