I created Silverlight application and I want to realise it via WCF RIA Services. There are 3 projects in my solution:
Data access layer library which contains all db logic and entities. I will use IUnitOfWork interface to communicate with it:
public interface IUnitOfWork : IDisposable { IRepository<Customer> Customers { get; } IRepository<Product> Products { get; } IRepository<Order> Orders { get; } void Save(); }WCF RIA Services project where I created custom DomainService class. Its constructor takes IUnitOfWork interface parameter:
[EnableClientAccess()] public void StoreService : DomainService { private IUnitOfWork _repository; public StoreService(IUnitOfWork repository) { _repository = repository; } // ... some methods to query _repository }Client project (its written in WPF).
So, I want to use Unity IoC container to path interface implementation into service. I can't understand where need to create custom service factory or something like that and where to register it to be used by system. For example, I know that in ASP.NET MVC there is DefaultControllerFactory class which I need to derive. Then put my IoC bindings in it and then register it in Global.asax.cs file. Can you help me, please. Thanks.
The
DomainServiceexposes a static property calledDomainService.DomainServiceFactory.You'll need a custom class that implements
IDomainServiceFactoryI've copied and pasted a blog post from Fredrik Normen how to wire up Unity to DomainService.
In your
Global.asax