示例#1
0
        /// <summary>The server entry point.</summary>
        public static void Main()
        {
            ConfigureLogging();
            using (var persistenceContextProvider = new PersistenceContextProvider(PersistenceConfiguration.InMemory())) {
                var initializer = new PersistenceInitializer(persistenceContextProvider);
                Logger.Info("Creating configuration & test data");
                initializer.CreateConfiguration();
                initializer.CreateTestData();

                using (var connectServer = CreateConnectServer())
                    using (var loginServer = CreateLoginServer(persistenceContextProvider))
                        using (var gameServer = CreateGameServer(persistenceContextProvider, connectServer, loginServer))
                            using (BeginServerStart(connectServer))
                                using (BeginServerStart(loginServer))
                                    using (BeginServerStart(gameServer)) {
                                        Task.WaitAny(gameServer.ShutdownTask, connectServer.ShutdownTask, InterruptSignal());
                                    }
            }
        }
示例#2
0
        private void ValidatePersistenceCache(PersistenceContextProvider persistenceContextProvider)
        {
            using (persistenceContextProvider) {
                var dataInitializer = new PersistenceInitializer(persistenceContextProvider);
                dataInitializer.CreateConfiguration();
                dataInitializer.CreateTestData();

                GameConfiguration config1 = null;
                using (var context = persistenceContextProvider.CreateContext()) {
                    config1 = context.GetAll <GameConfiguration>().First();
                }

                GameConfiguration config2 = null;
                using (var context = persistenceContextProvider.CreateContext()) {
                    config2 = context.GetAll <GameConfiguration>().First();
                }

                // These references should be the same (fetched from the configuration cache)
                Assert.AreSame(config1.MapDefinitions[0].Name, config2.MapDefinitions[0].Name);
            }
        }