示例#1
0
        /// <summary> Creates a new manager and loads settings stored in the settings file. </summary>
        /// <param name="generateDatabase"> Whether to read data from JSON instead of the database. </param>
        /// <param name="readOnlyJson"> Whether to generate the database. </param>
        public Manager
        (
            IWarThunderFileManager fileManager,
            IWarThunderFileReader fileReader,
            IWarThunderSettingsManager settingsManager,
            IParser parser,
            IUnpacker unpacker,
            IConverter converter,
            IWarThunderJsonHelper jsonHelper,
            ICsvDeserializer csvDeserializer,
            IDataRepositoryFactory dataRepositoryFactory,
            IRandomiser randomizer,
            IVehicleSelector vehicleSelector,
            IPresetGenerator presetGenerator,
            IThunderSkillParser thunderSkillParser,
            bool generateDatabase,
            bool readOnlyJson,
            bool readPreviouslyUnpackedJson,
            params IConfiguredLogger[] loggers
        ) : base(EOrganizationLogCategory.Manager, loggers)
        {
            _generateDatabase           = generateDatabase;
            _readOnlyJson               = readOnlyJson;
            _readPreviouslyUnpackedJson = readPreviouslyUnpackedJson;
            _startupConfiguration       = GetStartupConfiguration(_generateDatabase, _readOnlyJson, _readPreviouslyUnpackedJson);
            _excludedGaijinIdParts      = new List <string>()
            {
                "_football",
                "germ_panzerkampflaufer_565_r",
                "germ_panzerkampflaufer_565_r_2",
                "po-2_nw",
                "_race",
                "sdi_",
                "_space_suit",
                "toon_",
                "_tutorial",
                "ucav_assault",
                "ucav_scout",
                "uk_centaur_aa_mk_",
                "us_m35",
                "us_m35_2",
                "ussr_sht_1",
                "ussr_sht_1_2",
            };
            _fileManager           = fileManager;
            _fileReader            = fileReader;
            _parser                = parser;
            _unpacker              = unpacker;
            _converter             = converter;
            _jsonHelper            = jsonHelper;
            _csvDeserializer       = csvDeserializer;
            _dataRepositoryFactory = dataRepositoryFactory;
            _randomizer            = randomizer;
            _vehicleSelector       = vehicleSelector;
            _presetGenerator       = presetGenerator;
            _thunderSkillParser    = thunderSkillParser;

            _cache = new List <IPersistentObject>();

            PlayableVehicles = new Dictionary <string, IVehicle>();
        /// <summary> Creates a new manager and loads settings stored in the <see cref="EWpfClientFile.Settings"/> file. </summary>
        /// <param name="generateDatabase"> Whether to read data from JSON instead of the database. </param>
        /// <param name="readOnlyJson"> Whether to generate the database. </param>
        /// <param name="readPreviouslyUnpackedJson"> Whether to extract game files. </param>
        public WpfClientManager
        (
            IWarThunderFileManager fileManager,
            IWarThunderFileReader fileReader,
            IWarThunderSettingsManager settingsManager,
            IParser parser,
            IUnpacker unpacker,
            IConverter converter,
            IWarThunderJsonHelper jsonHelper,
            ICsvDeserializer csvDeserializer,
            IDataRepositoryFactory dataRepositoryFactory,
            IRandomiser randomizer,
            IVehicleSelector vehicleSelector,
            IPresetGenerator presetGenerator,
            bool generateDatabase,
            bool readOnlyJson,
            bool readPreviouslyUnpackedJson,
            params IConfiguredLogger[] loggers
        ) : base(fileManager, fileReader, settingsManager, parser, unpacker, converter, jsonHelper, csvDeserializer, dataRepositoryFactory, randomizer, vehicleSelector, presetGenerator, generateDatabase, readOnlyJson, readPreviouslyUnpackedJson, loggers)
        {
            _flagImageSources             = new Dictionary <ECountry, ImageSource>();
            _vehicleIconBitmapSources     = new ConcurrentDictionary <string, BitmapSource>();
            _vehiclePortraitBitmapSources = new ConcurrentDictionary <string, BitmapSource>();

            ProcessVehicleImages = (vehicle) => { GetIconBitmapSource(vehicle); GetPortraitBitmapSource(vehicle); };
        }
        public void Initialise()
        {
            _fileManager     = new WarThunderFileManager(Presets.Logger);
            _fileReader      = new WarThunderFileReader(Presets.Logger);
            _unpacker        = new Unpacker(_fileManager, Presets.Logger);
            _converter       = new Converter(Presets.Logger);
            _jsonHelper      = new WarThunderJsonHelper(Presets.Logger);
            _csvDeserializer = new CsvDeserializer(Presets.Logger);

            var mockSettingsManager = new Mock <IWarThunderSettingsManager>();

            mockSettingsManager
            .Setup(manager => manager.GetSetting(nameof(Settings.WarThunderLocation)))
            .Returns(Settings.WarThunderLocation);
            mockSettingsManager
            .Setup(manager => manager.GetSetting(nameof(Settings.KlensysWarThunderToolsLocation)))
            .Returns(Settings.KlensysWarThunderToolsLocation);
            mockSettingsManager
            .Setup(manager => manager.GetSetting(nameof(Settings.TempLocation)))
            .Returns(Settings.TempLocation);

            _manager = new Manager
                       (
                _fileManager,
                _fileReader,
                mockSettingsManager.Object,
                new Mock <IParser>().Object,
                _unpacker,
                _converter,
                _jsonHelper,
                _csvDeserializer,
                new Mock <IDataRepositoryFactory>().Object,
                new Mock <IRandomiser>().Object,
                new Mock <IVehicleSelector>().Object,
                new Mock <IPresetGenerator>().Object,
                new Mock <IThunderSkillParser>().Object,
                true,
                false,
                false,
                Presets.Logger
                       );
            _rootDirectory        = $"{Directory.GetCurrentDirectory()}\\TestFiles";
            _defaultTempDirectory = Settings.TempLocation;

            if (!Directory.Exists(_rootDirectory))
            {
                Directory.CreateDirectory(_rootDirectory);
            }
            else
            {
                _fileManager.EmptyDirectory(_rootDirectory);
            }

            Settings.TempLocation = _rootDirectory;
        }
        /// <summary> Initialises helpers. </summary>
        /// <param name="generateDatabase"> Whether to read data from JSON instead of the database. </param>
        /// <param name="readOnlyJson"> Whether to generate the database. </param>
        /// <param name="readPreviouslyUnpackedJson"> Whether to extract game files. </param>
        private static void InitialiseHelpers(bool generateDatabase, bool readOnlyJson, bool readPreviouslyUnpackedJson)
        {
            var settingsTypes = new List <Type>
            {
                typeof(Settings),
                typeof(WpfSettings),
            };

            var requiredSettingNames = settingsTypes
                                       .SelectMany(settingsType => settingsType.GetProperties(BindingFlags.Public | BindingFlags.Static))
                                       .Where(settingProperty => settingProperty.GetCustomAttribute <RequiredSettingAttribute>() is RequiredSettingAttribute)
                                       .Select(settingProperty => settingProperty.Name);

            WindowFactory = new WindowFactory(Loggers);

            FileManager            = new WarThunderFileManager(Loggers);
            FileReader             = new WarThunderFileReader(Loggers);
            SettingsManager        = new WpfClientSettingsManager(FileManager, EWpfClientFile.Settings, requiredSettingNames, Loggers);
            _parser                = new Parser(Loggers);
            _unpacker              = new Unpacker(FileManager, Loggers);
            _dataRepositoryFactory = new DataRepositoryFactoryWarThunder(Loggers);
            _converter             = new Converter(Loggers);
            _jsonHelper            = new WarThunderJsonHelper(Loggers);
            _csvDeserializer       = new CsvDeserializer(Loggers);
            _randomizer            = new CustomRandomiserWithNormalisation(Loggers);
            _vehicleSelector       = new VehicleSelector(_randomizer, Loggers);
            _presetGenerator       = new PresetGenerator(_randomizer, _vehicleSelector, Loggers);
            _thunderSkillParser    = new ThunderSkillParser(Loggers);

            Manager = new WpfClientManager
                      (
                FileManager,
                FileReader,
                SettingsManager,
                _parser,
                _unpacker,
                _converter,
                _jsonHelper,
                _csvDeserializer,
                _dataRepositoryFactory,
                _randomizer,
                _vehicleSelector,
                _presetGenerator,
                _thunderSkillParser,
                generateDatabase,
                readOnlyJson,
                readPreviouslyUnpackedJson,
                Loggers
                      );
            InitialiseLocalisationManager();
        }
示例#5
0
 public RestaurantsController(IRestaurantRepository repository, ICsvDeserializer csvDeserializer)
 {
     _restaurantRepository = repository;
     _csvDeserializer      = csvDeserializer;
 }
示例#6
0
 public DataProcessingApplicationService(ICsvDeserializer fileDeserialzer, ISave save, IGet get)
 {
     _fileDeserialzer = fileDeserialzer;
     _save            = save;
     _get             = get;
 }
        /// <summary> Creates a new manager and loads settings stored in the settings file. </summary>
        /// <param name="generateDatabase"> Whether to read data from JSON instead of the database. </param>
        /// <param name="readOnlyJson"> Whether to generate the database. </param>
        public Manager
        (
            IWarThunderFileManager fileManager,
            IWarThunderFileReader fileReader,
            IWarThunderSettingsManager settingsManager,
            IParser parser,
            IUnpacker unpacker,
            IConverter converter,
            IWarThunderJsonHelper jsonHelper,
            ICsvDeserializer csvDeserializer,
            IDataRepositoryFactory dataRepositoryFactory,
            IRandomiser randomizer,
            IVehicleSelector vehicleSelector,
            IPresetGenerator presetGenerator,
            bool generateDatabase,
            bool readOnlyJson,
            bool readPreviouslyUnpackedJson,
            params IConfiguredLogger[] loggers
        ) : base(EOrganizationLogCategory.Manager, loggers)
        {
            _generateDatabase           = generateDatabase;
            _readOnlyJson               = readOnlyJson;
            _readPreviouslyUnpackedJson = readPreviouslyUnpackedJson;
            _startupConfiguration       = GetStartupConfiguration(_generateDatabase, _readOnlyJson, _readPreviouslyUnpackedJson);
            _excludedGaijinIdParts      = new List <string>()
            {
                "_football",
                "germ_panzerkampflaufer_565_r",
                "germ_panzerkampflaufer_565_r_2",
                "po-2_nw",
                "_race",
                "_space_suit",
                "_tutorial",
                "uk_centaur_aa_mk_",
                "us_m35",
                "us_m35_2",
                "ussr_sht_1",
                "ussr_sht_1_2",
            };
            _fileManager           = fileManager;
            _fileReader            = fileReader;
            _parser                = parser;
            _unpacker              = unpacker;
            _converter             = converter;
            _jsonHelper            = jsonHelper;
            _csvDeserializer       = csvDeserializer;
            _dataRepositoryFactory = dataRepositoryFactory;
            _randomizer            = randomizer;
            _vehicleSelector       = vehicleSelector;
            _presetGenerator       = presetGenerator;

            _cache           = new List <IPersistentObject>();
            PlayableVehicles = new Dictionary <string, IVehicle>();

            _settingsManager = settingsManager;
            _settingsManager.Initialise(_startupConfiguration.IsIn(new List <EStartup> {
                EStartup.ReadDatabase, EStartup.ReadUnpackedJson
            }));
            LoadSettings();

            ResearchTrees = new Dictionary <ENation, ResearchTree>();

            LogDebug(ECoreLogMessage.Created.FormatFluently(EOrganizationLogCategory.Manager));
        }