I am using Autofac and I am not a IoC master.
Consider this scenario:
public interface IBeforeRequestTask
{
void Execute();
}
public interface IAfterRequestTask
{
void Execute();
}
public class TaskExecutor : IBeforeRequestTask, IAfterRequestTask
{
void IBeforeRequestTask.Execute()
{
// code
}
void IAfterRequestTask.Execute()
{
// code
}
}
So, we have explicit implementations. How would you register these interfaces?
I think we can't do this:
builder.RegisterType<IBeforeRequestTask> ...
builder.RegisterType<IAfterRequestTask> ...
I read in the Autofac Registration Docs that we must register concrete types.
A similar question but not treating Autofac is this one: TinyIoC: Register multiple interfaces on a single instance
Well, I know that this can be easy by doing 1-1 (one interface per class, then you register the concrete type). But now I am curious about it.
Don't remeber where I saw something like the below code using StructureMap (can be wrong):
action.AddTypesOf<IBeforeRequestTask>();
action.AddTypesOf<IAfterRequestTask>();
Hope I made myself clear. Thank you all.
EDIT
I created this sample to help. ;-)