示例#1
0
        public void AutoDiscovery()
        {
            var manager = new PlugInManager();

            manager.DiscoverAndRegisterPlugIns();
            var examplePlugInPoint = manager.GetPlugInPoint <IExamplePlugIn>();

            Assert.That(examplePlugInPoint, Is.InstanceOf <IExamplePlugIn>());
        }
示例#2
0
        public void AutoDiscovery()
        {
            var manager = new PlugInManager(null, new NullLoggerFactory(), this.CreateServiceProvider());

            manager.DiscoverAndRegisterPlugIns();
            var examplePlugInPoint = manager.GetPlugInPoint <IExamplePlugIn>();

            Assert.That(examplePlugInPoint, Is.InstanceOf <IExamplePlugIn>());
        }
示例#3
0
        /// <summary>
        /// Creates the initial data for a server.
        /// </summary>
        public void CreateInitialData()
        {
            BaseMapInitializer.ClearDefaultDropItemGroups();
            using (var temporaryContext = this.persistenceContextProvider.CreateNewContext())
            {
                this.gameConfiguration = temporaryContext.CreateNew <GameConfiguration>();
                temporaryContext.SaveChanges();
            }

            using var contextWithConfiguration = this.persistenceContextProvider.CreateNewContext(this.gameConfiguration);
            this.context = contextWithConfiguration;
            this.CreateGameClientDefinitions();
            this.CreateChatServerDefinition();
            new GameConfigurationInitializer(this.context, this.gameConfiguration).Initialize();

            var gameServerConfiguration = this.CreateGameServerConfiguration(this.gameConfiguration.Maps);

            this.CreateGameServerDefinitions(gameServerConfiguration, 3);
            this.CreateConnectServerDefinitions();
            this.context.SaveChanges();

            new MapsInitializer(this.context, this.gameConfiguration).SetSafezoneMaps();

            new TestAccountsInitialization(this.context, this.gameConfiguration).Initialize();

            if (!AppDomain.CurrentDomain.GetAssemblies().Contains(typeof(GameServer).Assembly))
            {
                // should never happen, but the access to the GameServer type is a trick to load the assembly into the current domain.
            }

            var plugInManager = new PlugInManager(null, this.loggerFactory, null);

            plugInManager.DiscoverAndRegisterPlugIns();
            plugInManager.KnownPlugInTypes.ForEach(plugInType =>
            {
                var plugInConfiguration      = this.context.CreateNew <PlugInConfiguration>();
                plugInConfiguration.TypeId   = plugInType.GUID;
                plugInConfiguration.IsActive = true;
                this.gameConfiguration.PlugInConfigurations.Add(plugInConfiguration);

                // Resets are disabled by default.
                if (plugInType == typeof(ResetFeaturePlugIn))
                {
                    plugInConfiguration.IsActive = false;
                    plugInConfiguration.SetConfiguration(new ResetConfiguration());
                }
            });

            this.context.SaveChanges();
        }