Source/NFX.Wave/Handlers/MVCHandler.cs
/// <summary>
/// Finds matching method that has the specified action name and best matches the supplied input
/// </summary>
Finds matching method that has the specified action name and best matches the supplied input
Finds matching method that has the specified action name and best matches the supplied input
protected virtual MethodInfo FindMatchingAction(Controller controller, WorkContext work, string action, out object[] args)
      {
        var tp = controller.GetType();
        var cInfo = m_Controllers[ControllerInfo.TypeToKeyName(tp)]; 
        if (cInfo==null)
        {
          cInfo = new ControllerInfo(tp);
          m_Controllers.Register(cInfo);
        }
        var gInfo = cInfo.Groups[action];
        if (gInfo==null) 
        {
          throw new HTTPStatusException(WebConsts.STATUS_404,
                                        WebConsts.STATUS_404_DESCRIPTION,
                                        StringConsts.MVC_CONTROLLER_ACTION_UNKNOWN_ERROR.Args(tp.DisplayNameWithExpandedGenericArgs(), action));
        }
        foreach(var ai in gInfo.Actions)
          foreach(var match in ai.Attribute.Matches)
          {
            var matched = match.Make(work);
            if (matched!=null)
            {
              var attr = ai.Attribute;
              var result = ai.Method;
              BindParameters(controller, action, attr, result, work, out args);
              return result;
            }
          }
        args = null;
        return null;
      }
protected virtual MethodInfo FindMatchingAction ( Controller controller , WorkContext work , string action , out object [ ] args ) { var tp = controller . GetType ( ) ; var cInfo = m_Controllers [ ControllerInfo . TypeToKeyName ( tp ) ] ; if ( cInfo == null ) { cInfo = new ControllerInfo ( tp ) ; m_Controllers . Register ( cInfo ) ; } var gInfo = cInfo . Groups [ action ] ; if ( gInfo == null ) { throw new HTTPStatusException ( WebConsts . STATUS_404 , WebConsts . STATUS_404_DESCRIPTION , StringConsts . MVC_CONTROLLER_ACTION_UNKNOWN_ERROR . Args ( tp . DisplayNameWithExpandedGenericArgs ( ) , action ) ) ; } foreach ( var ai in gInfo . Actions ) foreach ( var match in ai . Attribute . Matches ) { var matched = match . Make ( work ) ; if ( matched != null ) { var attr = ai . Attribute ; var result = ai . Method ; BindParameters ( controller , action , attr , result , work , out args ) ; return result ; } } args = null ; return null ; }
Finds matching method that has the specified action name and best matches the supplied input
Finds matching method that has the specified action name and best matches the supplied input
//Lock free lookup //action unknown
controller
Controller
work
WorkContext
action
string
object[]
out