We have recently developed a library of classes that are used within an MVC3 app internally. The MVC3 app uses Autofac to inject the controllers with the required service classes at runtime. The library uses its own set of tables for data storage that may or may not be in the same database as the host application.
The classes follow the dependency injection pattern, and as an example look something like this (yes, you've seen it a million times before)...
public class PackageService : ServiceBase, IPackageService
{
private readonly IRepository _db;
private readonly IClientService _clientSvc;
public PackageService(IRepository db, IClientService clientService)
{
_db = db;
_clientSvc = clientService;
}
public ServiceResult<IEnumerable<Package>> FindPackagesBy(string searchTerm, out int totalRecords, int pageSize, int pageIndex)
{
//...
}
public ServiceResult<Package> GetPackage(string packageRef)
{
//...
}
}
We would like to consume these classes within modules that run in Orchard CMS. From what i have read on how orchard works it would seem that i need to decorate each class that i intend to use within Orchard with the IDependency interface - which doesnt really seem like a great idea considering this will create a dependency on orchard itself. Our classes manage their own transactions / unit of work, so do not need to be governed by orchards own transaction mechanism. Is this possible? or are we faced with making Orchard specific implementations of our existing library?
Would be good to hear from anyone who has been through this already.