in src/Microsoft.Azure.WebJobs.Host/Bindings/BindingDataProvider.cs [76:114]
public static BindingDataProvider FromType(Type type)
{
if (type == null)
{
throw new ArgumentNullException("type");
}
if ((type == typeof(object)) ||
(type == typeof(string)) ||
(type == typeof(byte[])))
{
// No binding data is available for primitive types.
return null;
}
// The properties on user-defined types are valid binding data.
IReadOnlyList<PropertyHelper> bindingDataProperties = PropertyHelper.GetVisibleProperties(type);
if (bindingDataProperties.Count == 0)
{
return null;
}
Dictionary<string, Type> contract = new Dictionary<string, Type>(StringComparer.OrdinalIgnoreCase);
foreach (PropertyHelper property in bindingDataProperties)
{
// Because only visible properties are being returned from the type hierarchy, there should
// be no duplication due to shadowing and this condition should never be met. This check
// exists only as guard to ensure a meaningful error message should something unexpected occur.
if (contract.ContainsKey(property.Name))
{
throw new InvalidOperationException(
string.Format(CultureInfo.InvariantCulture,
"Multiple visible properties named '{0}' found for type '{1}'.", property.Name, type.Name));
}
contract.Add(property.Name, property.Property.PropertyType);
}
return new BindingDataProvider(type, contract, bindingDataProperties);
}