public GameServerInstance()
        {
            JsonDataLoader.LoadJsonData();

            m_PlayersListener = new PlayersListener(connectedPlayers => OnPlayersConnected(connectedPlayers));
            m_RoomsHandler    = new GameRoomsHandler();
        }
Exemple #2
0
        /// <summary>
        /// This method gets called by the runtime. Use this method to add
        /// services to the container.
        /// </summary>
        /// <param name="services">
        /// A concrete instance of any object that implements the
        /// <see cref="IServiceCollection"/> interface.
        /// </param>
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            // load up the data from the provided .json data file.
            var dataFilePath = _hostingEnvironment.ContentRootPath + @"\database.json";
            var theData      = JsonDataLoader.LoadDataFromFile(dataFilePath);

            // and store it into the DI container
            services.AddSingleton(sp => theData);

            // normal service(s) registration
            services.AddScoped <IDatabaseFactory, DatabaseFactory>();
            services.AddScoped <ICustomersRepository, CustomersRepository>();
            services.AddScoped <ICustomersServices, CustomersServices>();

            services.AddScoped <IOrdersRepository, OrdersRepository>();
            services.AddScoped <IOrdersServices, OrdersServices>();
        }