Lets say i have a traditional statemachine/Factory implemented like
public class StateMachine
{
public void ProcessState(StateEnum CurrentState)
{
switch (CurrentState)
{
case StateEnum.New:
ProcessNewState();
break;
case StateEnum.Waiting:
ProcessWaitingState();
break;
++++ More states.....
}
}
void ProcessWaitingState()
{
//Do State work
}
void ProcessNewState()
{
//Do State work
}
}
But now i want to implement this using best practices (TDD, SOLID...) and structuremap.
To follow the Single responsibility principle I want to put the processing code for each state in separate classes. Also each class has their own set of unique dependencies and they can be pretty complex them self. So putting them in separate classes a good idea I think.
So, how I can i properly do this in Structuremap?
I know this is basically a Factory class that i want to convert to a Objectfactory.
I am using latest Structuremap version 2.54 and in this version a lot of things seems to be deprecated (or not recommended anymore), like the use of ForRequestedType. So I am looking for the correct way of thing this using the new notation.