hi all,
I'm new to the all DI pattern idea and i have some basic design doubts. im using Unity application blocks 2.0 as my DI framwork.
To the questions :
- Say I have an interface for HW devices named IDevice. And some HW listener that receives such IDevice. Now say you have several HW Devices that implement IDevice and Several Listeners. You need to specify for each listener which actual device to inject. You can’t just map a single device to the interface you need something like multiple mapping.
well one solution possible is to create another level of abstraction for each actual device like
public interface IActualDevice : IDevice
{}
public ActualDevice : IActualDevice
{}
public SimulatedActualDevice : IActualDevice
{}
public OtherAcualDevice: IOtherAcualDevice
{}
then it would be possible to create such kind of mapping :
container.RegisterType<IActualDevice, ActualDevice>()
or if the HW is missing :
container.RegisterType<IActualDevice, SimulatedActualDevice>()
so what do you say is this good design ?
- DI pattern gives us the good creation of objects mechanism.
What about glue, what about the event subscription between objects ?
don't you think it is missing or better am i missing some Unity feature that supports it.
Adiel.