public async Task<MapResult> MapAsync(HttpContextBase context, Type type, MethodInfo method, ParameterInfo parameter)
{
context.ThrowIfNull("context");
type.ThrowIfNull("type");
method.ThrowIfNull("method");
parameter.ThrowIfNull("parameter");
Type parameterType = parameter.ParameterType;
object model = _container != null ? _container.GetInstance(parameterType) : Activator.CreateInstance(parameterType);
Type modelType = model.GetType();
foreach (PropertyInfo property in modelType.GetProperties(BindingFlags.Public | BindingFlags.Instance))
{
object mappedValue = await GetMappedValueAsync(context, modelType, property);
if (mappedValue == null)
{
throw new ApplicationException(String.Format("Unable to map property '{0} {1}' of type '{2}'.", property.PropertyType.FullName, property.Name, modelType.FullName));
}
property.SetValue(model, mappedValue, null);
}
return MapResult.ValueMapped(model);
}