/// <summary>
 /// Initializes a new instance of the <see cref="StateMachineInfoSurrogated"/> class.
 /// </summary>
 /// <param name="stateMachineInfo">
 /// The state machine info.
 /// </param>
 public StateMachineInfoSurrogated(StateMachineInfo stateMachineInfo)
 {
     this.CurrentState = stateMachineInfo.CurrentState;
     this.InstanceId = stateMachineInfo.InstanceId;
     this.InstanceState = stateMachineInfo.InstanceState;
     this.Name = stateMachineInfo.Name;
     this.PossibleTransitions = new TransitionList(stateMachineInfo.PossibleTransitions);
     this.PreviousState = stateMachineInfo.PreviousState;
     this.StateHistory = new HistoryList(stateMachineInfo.StateHistory);
     this.MaxHistory = stateMachineInfo.MaxHistory;
 }
 /// <summary>
 /// The get key.
 /// </summary>
 /// <param name="stateMachine">
 /// The state machine. 
 /// </param>
 /// <returns>
 /// The System.String. 
 /// </returns>
 private string GetKey(StateMachineInfo stateMachine)
 {
     return stateMachine.InstanceId + stateMachine.Name;
 }
 /// <summary>
 /// Adds or Updates a state machine
 /// </summary>
 /// <param name="record">
 /// The tracking record 
 /// </param>
 /// <remarks>
 /// In cases where the workflow is loaded, the StateMachineStateRecord may be the first tracking record
 /// </remarks>
 private void AddOrUpdateStateMachine(StateMachineStateRecord record)
 {
     var history = this.maxHistory;
     this.currentStateMachine = this.stateMachines.AddOrUpdate(
         GetKey(record),
         s =>
             {
                 var info = new StateMachineInfo(history)
                     {
                         Name = record.Activity.Name,
                         InstanceState = ActivityInstanceState.Executing,
                         InstanceId = record.InstanceId
                     };
                 info.UpdateState(record);
                 return info;
             },
         (s, info) =>
             {
                 info.InstanceState = ActivityInstanceState.Executing;
                 info.UpdateState(record);
                 return info;
             });
 }
 /// <summary>
 /// The add state machine.
 /// </summary>
 /// <param name="record">
 /// The record. 
 /// </param>
 private void AddOrUpdateStateMachine(ActivityStateRecord record)
 {
     var history = this.maxHistory;
     this.currentStateMachine = this.stateMachines.AddOrUpdate(
         GetKey(record),
         s =>
         new StateMachineInfo(history)
             {
                 Name = record.Activity.Name,
                 InstanceState = record.GetInstanceState(),
                 InstanceId = record.InstanceId
             },
         (s, info) =>
             {
                 info.InstanceState = record.GetInstanceState();
                 return info;
             });
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="StateTracker"/> class.
 /// </summary>
 /// <param name="stateTrackerSurrogated">
 /// The state tracker surrogated. 
 /// </param>
 public StateTracker(StateTrackerSurrogated stateTrackerSurrogated)
 {
     foreach (var stateMachine in stateTrackerSurrogated.StateMachines)
     {
         var machine = stateMachine;
         this.currentStateMachine = this.stateMachines.AddOrUpdate(
             GetKey(stateMachine), s => machine, (s, info) => machine);
     }
 }