private object UpdateObject(ConfigCollectionInstance target, JArray source, ConfigurationOptionModel optionModel, ConfigurationIdentity configIdentity, IEnumerable <ConfigurationSet> requiredConfigurationSets)
        {
            var collectionBuilder = target.CreateCollectionBuilder();

            foreach (var item in source)
            {
                var obj       = optionModel.NewItemInstance();
                var itemToAdd = UpdateObject(obj, (JObject)item, optionModel.ConfigurationProperties, configIdentity, requiredConfigurationSets);
                collectionBuilder.Add(itemToAdd);
            }
            return(collectionBuilder.Collection);
        }
        private ConfigurationOptionModel BuildOptionModel <TOption>(Expression <Func <TConfigurationSet, OptionSet <TOption> > > optionSelector, Func <TOption, string> keySelector, Func <TOption, object> descriptionSelector) where TOption : class, new()
        {
            var propertyInfo = ExpressionHelper.GetPropertyInfo(optionSelector);
            var name         = propertyInfo.Name;
            var type         = typeof(TOption);
            var setter       = (Action <TConfigurationSet, OptionSet <TOption> >)propertyInfo.SetMethod.CreateDelegate(typeof(Action <TConfigurationSet, OptionSet <TOption> >));
            var definition   = new ConfigurationOptionModel <TOption, TConfigurationSet>(name, keySelector, descriptionSelector, optionSelector.Compile(), setter);

            ApplyDefaultPropertyDefinitions(definition);

            return(definition);
        }
        private async Task <IOptionSet> BuildOptionSetCollection(ConfigurationOptionModel option, IEnumerable <ConfigurationSet> configurationDependencies, ConfigurationIdentity identity)
        {
            var options = await configProvider.GetCollectionAsync(option.Type, identity);

            var optionSet = option.BuildOptionSet(options);

            foreach (var item in optionSet.Values)
            {
                UpdateOptions(item, option.ConfigurationProperties, configurationDependencies, identity);
            }

            return(optionSet);
        }
Exemple #4
0
        private object BuildObject(object source, ConfigurationOptionModel model)
        {
            var collection = source as IEnumerable ?? new List <object>();

            var result = new List <object>();

            foreach (var item in collection)
            {
                var itemValue = BuildObject(item, model.ConfigurationProperties);
                result.Add(itemValue);
            }

            return(result);
        }