private GameCommand ParseCommand(Player origin, string value)
{
dynamic jsonValue = JsonValue.Parse(value);
string commandType = (string)jsonValue.Type;
switch (commandType)
{
case "PlayerMoveCommand":
return new PlayerMoveCommand
{
Direction = (Direction)Enum.Parse(typeof(Direction), (string)jsonValue.Direction),
Player = origin
};
default:
throw new ArgumentException("Unknown command '{0}'", commandType);
}
}