TimeoutState.cs 1007 B

1234567891011121314151617181920212223242526272829303132333435
  1. namespace Wayne.Lib.StateEngine.Generic
  2. {
  3. /// <summary>
  4. /// Generic timeout state class that has a main object of a generic type.
  5. /// </summary>
  6. /// <typeparam name="TMain">Specifies the type of the main object.</typeparam>
  7. /// <typeparam name="TData">Specifies the type of state data the state uses.</typeparam>
  8. public abstract class TimeoutState<TMain, TData> : TimeoutState<TMain> where TData : StateData
  9. {
  10. #region Fields
  11. private IStateWithData stateWithData;
  12. #endregion
  13. #region Properties
  14. /// <summary>
  15. /// Gets the state data for this state.
  16. /// </summary>
  17. protected TData Data
  18. {
  19. get
  20. {
  21. if (stateWithData == null)
  22. {
  23. stateWithData = StateData.GetParentCompositeStateWithStateData<TData>(this);
  24. }
  25. return stateWithData.StateData as TData;
  26. }
  27. }
  28. #endregion
  29. }
  30. }