コード例 #1
0
        public IJSResponse AddGameInfo(IJSRequest request)
        {
            string gameinfo_pre = request.GetParameter("gameinfo");
            IGameInfo game = GameInfo.FromJson(JsonConvert.DeserializeObject(gameinfo_pre));
            var gamePreAddEvent = new GamePreAddEventArgs(this.CoreInstance, game, this.CoreInstance.Get<IGameDatabase>());
            SnowflakeEventManager.EventSource.RaiseEvent(gamePreAddEvent);
            if (!gamePreAddEvent.Cancel)
            {
                game = gamePreAddEvent.GameInfo;
                this.CoreInstance.Get<IGameDatabase>().AddGame(game);
                var gameAddEvent = new GameAddEventArgs(this.CoreInstance, game, this.CoreInstance.Get<IGameDatabase>());
                SnowflakeEventManager.EventSource.RaiseEvent(gameAddEvent);

            }
            return new JSResponse(request, game, true);
        }
コード例 #2
0
 public void GameAddEvent_Test()
 {
     SnowflakeEventManager.InitEventSource();
     new StandardEvents().RegisterSnowflakeEvents(SnowflakeEventManager.EventSource);
     var fakeCoreService = new Mock<ICoreService>();
     var fakeGameInfo = new Mock<IGameInfo>();
     var fakeGameDatabase = new Mock<IGameDatabase>();
     var args = new GameAddEventArgs(fakeCoreService.Object, fakeGameInfo.Object, fakeGameDatabase.Object);
     SnowflakeEventManager.EventSource.Subscribe<GameAddEventArgs>((s, e) =>
     {
         Assert.Equal(args, e);
     });
     SnowflakeEventManager.EventSource.RaiseEvent(args);
 }