You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
690 B
35 lines
690 B
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace State.States
|
|
{
|
|
internal class Context
|
|
{
|
|
private State _state = null;
|
|
|
|
public Context(State state)
|
|
{
|
|
TransitionTo(state);
|
|
}
|
|
|
|
public void TransitionTo(State state)
|
|
{
|
|
Console.WriteLine($"Context: Transition to {state.GetType().Name}");
|
|
_state = state;
|
|
_state.SetContext(this);
|
|
}
|
|
|
|
public void Request1()
|
|
{
|
|
_state.Handle1();
|
|
}
|
|
|
|
public void Request2()
|
|
{
|
|
_state.Handle2();
|
|
}
|
|
}
|
|
}
|
|
|