public PropertyMapperArgsTests() { _key = Guid.NewGuid().ToString(); _value = Guid.NewGuid().ToString(); _sources = new List <IConfigurationSource> { new DictionarySource(new Dictionary <string, string> { { _key, _value } }) }; _args = new PropertyMapperArgs( (template, values) => { }, _sources, new TestDescriptor("RabbitMqTestUsername", typeof(string))); }
public string Select(PropertyDescriptor property) { var selectionArgs = new PropertyMapperArgs(_options.WriteLog, _sources, property); var valueToUse = _options.Mappers.Select(x => x.ValueFor(selectionArgs)).FirstOrDefault(v => v != null); if (valueToUse != null) { return(valueToUse); } if (property.IsOptional) { return(string.Empty); } _options.WriteLog("Unable to find a value for {propertyName}", property.Name); throw new SourceValueNotFoundException(new SourceValueNotFoundArgs { ValueSelectors = _options.Mappers, Property = property, Sources = _options.ConfigSources }); }
public string ValueFor(PropertyMapperArgs args) => args.GetValue(args.Property.Name);