Exemplo n.º 1
0
        public static void Initialize(IServiceCollection serviceCollection)
        {
            AppConfig = new ConfigurationBuilder()
                        .SetBasePath(Directory.GetCurrentDirectory())
                        .AddJsonFile("AppSettings.json", optional: true, reloadOnChange: true).Build();

            var animalSection  = AppConfig.GetSection(ANIMALCONFIG);
            var animalSettings = new AnimalSettingsDto();

            animalSection.Bind(animalSettings);

            var coopSection  = AppConfig.GetSection(COOPCONFIG);
            var coopSettings = new CoopSettingsDto();

            coopSection.Bind(coopSettings);

            serviceCollection.AddSingleton <AnimalSettingsDto>(animalSettings);
            serviceCollection.AddSingleton <CoopSettingsDto>(coopSettings);
            serviceCollection.AddSingleton <CoopManager>();
            serviceCollection.AddSingleton <AnimalHelper>();
            Provider = serviceCollection.BuildServiceProvider();
        }
Exemplo n.º 2
0
 public AnimalHelper(AnimalSettingsDto animalSettings)
 {
     AnimalSettings = animalSettings;
     BornActions    = new List <KeyValuePair <Animal, int> >();
 }