I want to implement IOC in my application, but I'm confused, in my application I have several specific classes that implement the interface. Consider this scenario: -
I have an ICommand Inteface and the following specific types that implement this interface: -
- Addaddress
- Addcontact
- RemoveAddress
- Removecontact
Basically, the user performs all this action in the user interface, and then the List is passed to the service level where each command is executed.
So in the GUI layer I will write
ICommand command1 = new AddAddress();
ICommand command2 = new RemoveContact();
In the command box
List<ICommand> listOfCommands = List<ICommand>();
listOfCommands.Add(command1);
listOfCommands.Add(command2);
Then, finally, we pass listOfCommands to the service level.
, IOC, . , StructureMap.
ICommand command = ObjectFactory.GetInstance<ICommand>();
IOC ?