private object GetConfigPropertyValueFromInput(JObject source, ConfigurationPropertyWithMultipleOptionsModelDefinition propertyModel) { var collectionBuilder = propertyModel.GetCollectionBuilder(); var optionSet = optionSetFactory.Build(propertyModel); foreach (var key in source.GetValue(propertyModel.ConfigurationPropertyName.ToLowerCamelCase()).Select(s => s.ToObject <string>())) { object option = null; if (optionSet.TryGetValue(key, out option)) { collectionBuilder.Add(option); } } return(collectionBuilder.Collection); }
private void UpdateOptions(object source, ConfigurationPropertyWithMultipleOptionsModelDefinition model) { var optionSet = optionSetFactory.Build(model); var collectionBuilder = model.GetCollectionBuilder(); var items = model.GetPropertyValue(source) as IEnumerable; foreach (var item in items ?? Enumerable.Empty <object>()) { if (optionSet.TryGetValue(item, out var actualValue)) { collectionBuilder.Add(actualValue); } } model.SetPropertyValue(source, collectionBuilder.Collection); }