Пример #1
0
        protected override void ConfigureApplicationContainer(Nancy.TinyIoc.TinyIoCContainer container)
        {
            base.ConfigureApplicationContainer(container);

            var config = AppConfigReader.RetrieveClientConfig();
            var client = new Domain.Client(config.Id, config.Name);

            container.Register(config);
            container.Register(client);
        }
        public ClientIncomingHttpInterface(Domain.Client client)
        {
            _client = client;

            Get["/hello"] = _ => string.Format("Hi there, my name is '{0}' and my ID is '{1}'.", _client.Name, _client.Id);

            Post["/start"] =
                o =>
            {
                ProcessStart(o.opponentId, o.opponentName, o.pointsToWin, o.numberOfTurns, o.dynamiteLimit);
                return(HttpStatusCode.OK);
            };

            Get["/move"] = _ => GetNextMove();

            Post["/move"] =
                o =>
            {
                ProcessLastOpponentMove(o.move);
                return(HttpStatusCode.OK);
            };
        }