Beispiel #1
0
        public AppContext()
        {
            string storePath = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), "store.db");

            Type tEvent     = typeof(IEvent);
            Type tTO        = typeof(ITransferObject);
            var  allTypes   = System.Reflection.Assembly.GetExecutingAssembly().GetTypes();
            var  knownTypes = allTypes
                              .Where(t => !t.IsAbstract)
                              .Where(t => t.IsClass || t.IsValueType)
                              .Where(t => tEvent.IsAssignableFrom(t) || tTO.IsAssignableFrom(t)).ToArray();

            JSONFileEventStore store = new JSONFileEventStore(storePath, knownTypes);

            Repository = new Repository(store);
            var bus = MessageBus.Instance;

            AccountProjection = new AccountProjection(store, bus);
            AccountProjection.Init();
            AccountHandler = new Account.Handler(Repository, bus);

            GameProjection = new GameProjection(store, bus);
            GameProjection.Init();
            GameHandler = new BC.Game.Game.Handler(Repository, bus);

            FriendshipProjection = new FriendshipProjection(store, bus);
            FriendshipProjection.Init();
            FriendshipHandler = new Friendship.Handler(Repository, bus);
            //autologout ohne events
            AccountProjection.LogoutAllAccounts();

            GameProjection.CloseGamesAfterChallengeExpires();
        }
        public ChessContext()
        {
            string storePath = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), "chess.db");

            Type tEvent     = typeof(IEvent);
            Type tTO        = typeof(ITransferObject);
            var  allTypes   = System.Reflection.Assembly.GetExecutingAssembly().GetTypes();
            var  knownTypes = allTypes
                              .Where(t => !t.IsAbstract)
                              .Where(t => t.IsClass || t.IsValueType)
                              .Where(t => tEvent.IsAssignableFrom(t) || tTO.IsAssignableFrom(t))
                              .Where(t => t.Namespace.StartsWith($"{nameof(VnodeTest)}.{nameof(BC)}.{nameof(Chess)}")).ToArray();

            JSONFileEventStore store = new JSONFileEventStore(storePath, knownTypes);

            Repository = new Repository(store);
            var bus = MessageBus.Instance;

            ChessProjection = new ChessgameProjection(store, bus);
            ChessProjection.Init();
            ChessHandler = new Chessgame.Handler(Repository, bus);
        }