Business services, dependency injection

 Recurrent dependency injection with Castle project (www.castleproject.org) & ServiceProvider class. Use [ServiceAttribute] to register interface implementation:

[Service(typeof(ICustomPermissionsService))]
public class CustomPermissionsService : ICustomPermissionsService
{
    private readonly IRepository<Employee> personRepository;
    private readonly IDivisionRepository divisionRepository;
 
    public CustomPermissionsService(IRepository<Employee> personRepository, IDivisionRepository divisionRepository)
    {
        this.personRepository = personRepository;
        this.divisionRepository = divisionRepository;
    }

    public ChangePermission(Employee person, int divisionType)
    {
        (...)
    }

    (...)
}

Last edited Apr 28, 2011 at 10:57 AM by Extreme, version 5

Comments

No comments yet.