/// <summary> /// Creates and returns an action descriptor mapping for the specified controller descriptor. /// </summary> /// <param name="controllerDescriptor">The <see cref="HttpControllerDescriptor">controller descriptor</see> to create a mapping for.</param> /// <returns>A <see cref="ILookup{TKey,TValue}">lookup</see>, which represents the route-to-action mapping for the /// specified <paramref name="controllerDescriptor">controller descriptor</paramref>.</returns> public virtual ILookup <string, HttpActionDescriptor> GetActionMapping(HttpControllerDescriptor controllerDescriptor) { Arg.NotNull(controllerDescriptor, nameof(controllerDescriptor)); Contract.Ensures(Contract.Result <ILookup <string, HttpActionDescriptor> >() != null); var actionMappings = (from descriptor in controllerDescriptor.AsEnumerable() let selector = GetInternalSelector(descriptor) select selector.GetActionMapping()).ToArray(); return(actionMappings.Length == 1 ? actionMappings[0] : new AggregatedActionMapping(actionMappings)); }
/// <summary> /// Creates and returns an action descriptor mapping for the specified controller descriptor. /// </summary> /// <param name="controllerDescriptor">The <see cref="HttpControllerDescriptor">controller descriptor</see> to create a mapping for.</param> /// <returns>A <see cref="ILookup{TKey,TValue}">lookup</see>, which represents the route-to-action mapping for the /// specified <paramref name="controllerDescriptor">controller descriptor</paramref>.</returns> public virtual ILookup <string, HttpActionDescriptor> GetActionMapping(HttpControllerDescriptor controllerDescriptor) { if (controllerDescriptor == null) { throw new ArgumentNullException(nameof(controllerDescriptor)); } var actionMappings = (from descriptor in controllerDescriptor.AsEnumerable() let selector = GetInternalSelector(descriptor) select selector.GetActionMapping()).ToArray(); return(actionMappings.Length == 1 ? actionMappings[0] : new AggregatedActionMapping(actionMappings)); }