I am using structure map IOC container I am not using the scan with default name convention here.
public interface ICompanyRepository
{
IEnumerable<Company> GetAll();
Company Get(int id);
Company Add(Company item);
bool Update(Company item);
bool Delete(int id);
}
public class Company1: ICompanyRepository
{
// Proivide implementation for all interface methods
}
public class Company2: ICompanyRepository
{
// Provide implementation for all interface methods
//Class Company2 will also have new method called DisplayLog
public void DisplayLog()
{
//To do
}
}
I am trying to implement DI using structuremap in my Customer controller class how can I tell the that i need methods ofcompany1 to be called or methods Company2 to be called?
_.Scan(x =>
{
x.TheCallingAssembly();
x.AddAllTypesOf<ICompanyRepository>();
// or
});
my code: private readonly ICustomerRepository customerRepository;
public CustomerController(ICustomerRepository CustomerRepository)
{
customerRepository = CustomerRepository;
}
// GET: Customer
public ActionResult Index()
{
var customers = customerRepository.GetAll
//Here i need to be specfic telling i need to call company1 or company2 class methods ?
return View(customers);
}