UseImplicitIdToken for complex types?

Mar 23, 2015 at 10:28 AM
My controller action signatures typically look like this:
public async Task<ActionResult> Create(CreateQuery query)

public async Task<ActionResult> Confirm(ConfirmQuery query)
...passing on handling of the query object to another component in my system. Sometimes these types contain "Id" parameter, and with regular MVC routing I could embed it in the route. The "UseImplicitIdToken" however doesn't recognize this as a parameter (makes sense).

I've tried to create a pull request to add this functionality but it's unclear to me how I should configure the ActionParameterInfo object. I've added a setting SearchComplexTypesForImplicitIdToken and am currently looking at \MvcCodeRouting\Controllers\ActionInfo.cs. I've added the following piece of code to locate the complex type that contains the Id property:
if (_RouteParameters.Count == 0
  && Controller.Register.Settings.UseImplicitIdToken) {

      ActionParameterInfo id = Parameters.FirstOrDefault(p => p.Name.Equals("id", StringComparison.OrdinalIgnoreCase));

      if (id == null && Controller.Register.Settings.SearchComplexTypesForImplicitIdToken)
          id = Parameters.FirstOrDefault(p => p.Type.GetProperties().Any(prop => prop.Name.Equals("id", StringComparison.OrdinalIgnoreCase)));
But I'm doubtful that just that will just work from there on out. Can you give me some idea on how to move forward? Or tell me if it's too much of a refactoring to support this... :)
Mar 23, 2015 at 2:42 PM
If you rename the query parameter to id it should work.