Exemplo n.º 1
0
        /// <summary>
        ///     Class .ctor
        /// </summary>
        /// <param name="locale">Locale for this repository</param>
        internal DestinyDefinitionsRepository(
            BungieLocales locale,
            IDefinitionAssemblyData assemblyData,
            IConfigurationService configuration,
            ILogger logger)
        {
            _assemblyData = assemblyData;
            _config       = configuration;
            _logger       = logger;
            Locale        = locale;

            var definitionsLoaded = _config.Settings.DefinitionLoadingSettings.AllowedDefinitions.Length;
            var concurrencyLevel  = _config.Settings.DefinitionLoadingSettings.AppConcurrencyLevel;

            _logger.Log(
                $"Initializing definitions repository with settings: Locale: {Locale}, Concurrency level: {concurrencyLevel}, Capacity: {definitionsLoaded}",
                LogType.Debug);

            _definitionRepositories = new ConcurrentDictionary <DefinitionsEnum, DestinyDefinitionTypeRepository>(
                concurrencyLevel,
                definitionsLoaded);
            foreach (var definition in configuration.Settings.DefinitionLoadingSettings.AllowedDefinitions)
            {
                _definitionRepositories.TryAdd(definition,
                                               new DestinyDefinitionTypeRepository(
                                                   _assemblyData.DefinitionsToTypeMapping[definition].DefinitionType,
                                                   concurrencyLevel));
            }

            _historicalStatsDefinitions =
                new ConcurrentDictionary <string, DestinyHistoricalStatsDefinition>(concurrencyLevel, 31);
        }
    internal DestinyDefinitionsRepository(
        BungieLocales locale,
        IDefinitionAssemblyData assemblyData,
        ILogger logger,
        DefaultDestiny2DefinitionRepositoryConfiguration configuration)
    {
        _assemblyData = assemblyData;
        _logger       = logger;
        Locale        = locale;

        var definitionsLoaded = configuration.AllowedDefinitions.Count;
        var concurrencyLevel  = configuration.AppConcurrencyLevel;

        _logger.LogDebug(
            "Initializing definitions repository with settings: Locale: {Locale}, Concurrency level: {ConcurrencyLevel}, Capacity: {DefinitionsLoaded}",
            Locale, concurrencyLevel, definitionsLoaded);

        _definitionRepositories = new ConcurrentDictionary <DefinitionsEnum, DestinyDefinitionTypeRepository>(
            concurrencyLevel,
            definitionsLoaded);
        foreach (var definition in configuration.AllowedDefinitions)
        {
            _definitionRepositories.TryAdd(definition,
                                           new DestinyDefinitionTypeRepository(
                                               _assemblyData.DefinitionsToTypeMapping[definition].DefinitionType,
                                               concurrencyLevel));
        }

        _historicalStatsDefinitions =
            new ConcurrentDictionary <string, DestinyHistoricalStatsDefinition>(concurrencyLevel, 31);
    }
Exemplo n.º 3
0
 public LocalisedDestinyDefinitionRepositories(ILogger logger, IConfigurationService config,
                                               IDefinitionAssemblyData assemblyData)
 {
     _logger       = logger;
     _configs      = config;
     _assemblyData = assemblyData;
 }
Exemplo n.º 4
0
    public DefaultDestiny2DefinitionRepository(
        IDefinitionAssemblyData assemblyData,
        ILogger logger,
        DefaultDestiny2DefinitionRepositoryConfiguration configuration)
    {
        _logger                = logger;
        _configuration         = configuration;
        _localisedRepositories =
            new ConcurrentDictionary <BungieLocales, DestinyDefinitionsRepository>(
                configuration.AppConcurrencyLevel, configuration.UsedLocales.Count);

        foreach (var locale in configuration.UsedLocales)
        {
            _localisedRepositories.TryAdd(
                locale,
                new DestinyDefinitionsRepository(
                    locale,
                    assemblyData,
                    logger,
                    configuration));
        }
    }
Exemplo n.º 5
0
        /// <summary>
        /// Class .ctor
        /// </summary>
        /// <param name="locale">Locale for this repository</param>
        internal DestinyDefinitionsRepository(DestinyLocales locale, IDefinitionAssemblyData assemblyData, IConfigurationService configuration, ILogger logger)
        {
            _assemblyData = assemblyData;
            _config       = configuration;
            _logger       = logger;
            Locale        = locale;

            _loadRules =
                _assemblyData.DefinitionsToTypeMapping
                .Where(x => !_config.Settings.ExcludedDefinitions.Contains(x.Key))
                .Where(x => x.Value.AttributeData.Sources.HasFlag(_config.Settings.PreferredLoadSource))
                .ToDictionary(x => x.Key, x => _config.Settings.PreferredLoadSource);

            if (_config.Settings.SpecifiedLoadSources.Count > 0)
            {
                foreach (var source in _config.Settings.SpecifiedLoadSources)
                {
                    var definitionAssemblyRules = _assemblyData.DefinitionsToTypeMapping[source.Key];
                    if (definitionAssemblyRules.AttributeData.Sources.HasFlag(source.Value))
                    {
                        if (!_loadRules.TryAdd(source.Key, source.Value))
                        {
                            _loadRules[source.Key] = source.Value;
                        }
                    }
                }
            }

            int definitionsLoaded = _loadRules.Count;
            int concurrencyLevel  = _config.Settings.AppConcurrencyLevel;

            _logger.Log($"Initializing definitions repository with settings: Locale: {Locale}, Concurrency level: {concurrencyLevel}, Capacity: {definitionsLoaded}", LogType.Debug);

            _definitionRepositories = new ConcurrentDictionary <DefinitionsEnum, DestinyDefinitionTypeRepository>(
                concurrencyLevel: concurrencyLevel,
                capacity: definitionsLoaded);
        }