public static AwaitableStateMachineConfiguration <TState, TTrigger> Reconfigure <TState, TTrigger>( AwaitableStateMachine <TState, TTrigger> existingAwaitableMachine) { Contract.Requires <ArgumentNullException>(existingAwaitableMachine != null); return(new AwaitableStateMachineConfiguration <TState, TTrigger>(existingAwaitableMachine)); }
internal AwaitableStateMachineConfiguration(AwaitableStateMachine <TState, TTrigger> existingMachine) { Contract.Requires(existingMachine != null); Contract.Ensures(config != null); config = new Dictionary <TState, AwaitableStateRepresentation <TState, TTrigger> >(); var currentStateRep = existingMachine.currentStateRepresentation; var currentTriggers = currentStateRep.Triggers.ToArray(); foreach (var triggerRepresentation in currentTriggers) { var nextStateRep = triggerRepresentation.NextStateRepresentation; if (nextStateRep != currentStateRep) { if (!config.ContainsKey(nextStateRep.State)) { config.Add(nextStateRep.State, nextStateRep); } } } }