private async Task BuildConfigurations(ConfigurationSet result, ConfigurationSetModel setDefinition, Type setType, IEnumerable <ConfigurationSet> configurationSets, ConfigurationIdentity identity)
        {
            var configurationDependencies = configurationSets.Concat(new[] { result }).ToArray();

            foreach (var configDefinition in setDefinition.Configs.Where(w => !(w is ConfigurationOptionModel)))
            {
                var configInstance = await configProvider.GetAsync(configDefinition.Type, identity);

                var configuration = configInstance.GetConfiguration();
                UpdateOptions(configuration, configDefinition.ConfigurationProperties, configurationDependencies, identity);
                configDefinition.SetConfigurationOnConfigurationSet(result, configuration);
            }
        }
        private async Task <IEnumerable <ConfigurationSet> > GetRequiredConfiguration(ConfigurationSetModel model, ConfigurationIdentity identity)
        {
            var requiredConfigurationSetTypes = model.GetDependencies()
                                                .Select(s => s.ConfigurationSet)
                                                .Distinct()
                                                .ToArray();
            var configurationSet = new ConfigurationSet[requiredConfigurationSetTypes.Length];
            var i = 0;

            foreach (var type in requiredConfigurationSetTypes)
            {
                configurationSet[i] = await configurationSetService.GetConfigurationSet(type, identity);

                i++;
            }
            return(configurationSet);
        }
Exemple #3
0
        private async Task <ConfigurationSet> GetConfigurationSetFromSource(Type type, ConfigurationIdentity identity)
        {
            if (!registry.TryGetConfigSetDefinition(type, out ConfigurationSetModel model))
            {
                throw new InvalidOperationException($"Could not find ConfigurationSet of type: {type} in regiistry");
            }
            var requiredConfigurationSetTypes = model.GetDependencies().Select(s => s.ConfigurationSet)
                                                .Distinct()
                                                .Where(w => type != w)
                                                .ToArray();
            var requiredConfigurationSet = new ConfigurationSet[requiredConfigurationSetTypes.Length];

            for (var i = 0; i < requiredConfigurationSetTypes.Length; i++)
            {
                requiredConfigurationSet[i] = await GetConfigurationSetFromSource(requiredConfigurationSetTypes[i], identity);
            }
            return(await factory.BuildConfigSet(type, identity, requiredConfigurationSet));
        }
        private async Task BuildOptions(ConfigurationSet result, ConfigurationSetModel setDefinition, Type setType, IEnumerable <ConfigurationSet> configurationSets, ConfigurationIdentity identity)
        {
            var configurationDependencies = configurationSets.Concat(new[] { result }).ToArray();

            foreach (var option in GetOptionsInOrder(setDefinition))
            {
                IOptionSet optionSet;
                if (option is ReadOnlyConfigurationOptionModel readonlyModel)
                {
                    optionSet = optionSetFactory.Build(readonlyModel, identity);
                }
                else
                {
                    optionSet = await BuildOptionSetCollection(option, configurationDependencies, identity);
                }

                option.SetConfigurationOnConfigurationSet(result, optionSet);
            }
        }
Exemple #5
0
 private IOptionSet Build(IOptionPropertyDefinition definition, ConfigurationSet configurationSet) => definition.GetOptionSet(configurationSet);