private static IntegrationSettings[] GetIntegrationSettings(IConfigurationSource source)
        {
            var integrations = new IntegrationSettings[IntegrationRegistry.Names.Length];

            for (int i = 0; i < integrations.Length; i++)
            {
                var name = IntegrationRegistry.Names[i];

                if (name != null)
                {
                    integrations[i] = new IntegrationSettings(name, source);
                }
            }

            return(integrations);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="IntegrationSettingsCollection"/> class.
        /// </summary>
        /// <param name="source">The <see cref="IConfigurationSource"/> to use when retrieving configuration values.</param>
        public IntegrationSettingsCollection(IConfigurationSource source)
        {
            _source         = source;
            _settingsByName = new ConcurrentDictionary <string, IntegrationSettings>();
            _settingsById   = GetIntegrationSettings(source);
            _valueFactory   = name =>
            {
                if (IntegrationRegistry.Ids.TryGetValue(name, out var id))
                {
                    return(_settingsById[id]);
                }

                // We have no id for this integration, it will only be available in _settingsByName
                var settings = new IntegrationSettings(name, _source);

                if (_disabledIntegrations?.Contains(name) == true)
                {
                    settings.Enabled = false;
                }

                return(settings);
            };
        }