public System.Web.Http.Controllers.IHttpController Create( System.Net.Http.HttpRequestMessage request, System.Web.Http.Controllers.HttpControllerDescriptor controllerDescriptor, Type controllerType) { using (_container.BeginScope()) { var controller = (System.Web.Http.Controllers.IHttpController)_container.GetInstance(controllerType); return(controller); } }
public void Initialize(System.Web.Http.Controllers.HttpControllerSettings settings, System.Web.Http.Controllers.HttpControllerDescriptor descriptor) { // Remove the JSON formatter. var jsonFormatter = settings.Formatters.JsonFormatter; settings.Formatters.Remove(jsonFormatter); // Add a custom json media-type formatter. var formatter = new JsonNetFormatter(); settings.Formatters.Insert(0, formatter); }
private static bool MatchesNamespace(this TRoute route, string controllerNamespace) { if (string.IsNullOrEmpty(controllerNamespace)) { return(true); } TActionDescriptor[] actionDescriptors = (TActionDescriptor[])route.DataTokens[RouteDataTokenKeys.Actions]; TControllerDescriptor controllerDescriptor = actionDescriptors.First().ControllerDescriptor; return(controllerDescriptor.ControllerType.Namespace == controllerNamespace); }
public static bool GetApiShow(System.Web.Http.Controllers.HttpControllerDescriptor actionContext, string project) { string prefix = ""; var obj = actionContext.GetCustomAttributes <System.Web.Http.RoutePrefixAttribute>(); if (obj != null) { foreach (System.Web.Http.RoutePrefixAttribute md in obj) { prefix = md.Prefix; } } return(prefix.ToLower().Contains(project.ToLower())); }
public IReadOnlyList<RouteEntry> GetDirectRoutes(TControllerDescriptor controllerDescriptor, IReadOnlyList<TActionDescriptor> actionDescriptors, IInlineConstraintResolver constraintResolver) { IReadOnlyCollection<RouteEntry> controllerDirectRoutes = DirectRouteProvider.GetDirectRoutes(controllerDescriptor, actionDescriptors, constraintResolver); // Wrap routes with LocalizationCollectionRoute List<RouteEntry> routeEntries = controllerDirectRoutes.Select(x => new RouteEntry(x.Name, new LocalizationCollectionRoute(x.Route))).ToList(); // Store routes for later processing LocalizationCollectionRoutes.AddRange(routeEntries); return routeEntries; }
public IReadOnlyList <RouteEntry> GetDirectRoutes(TControllerDescriptor controllerDescriptor, IReadOnlyList <TActionDescriptor> actionDescriptors, IInlineConstraintResolver constraintResolver) { IReadOnlyCollection <RouteEntry> controllerDirectRoutes = DirectRouteProvider.GetDirectRoutes(controllerDescriptor, actionDescriptors, constraintResolver); // Wrap routes with LocalizationCollectionRoute List <RouteEntry> routeEntries = controllerDirectRoutes.Select(x => new RouteEntry(x.Name, new LocalizationCollectionRoute(x.Route))).ToList(); // Store routes for later processing LocalizationCollectionRoutes.AddRange(routeEntries); return(routeEntries); }
public System.Web.Http.Controllers.IHttpController Create(System.Net.Http.HttpRequestMessage request, System.Web.Http.Controllers.HttpControllerDescriptor controllerDescriptor, Type controllerType) { try { return(_default.Create(request, controllerDescriptor, controllerType)); } catch (InvalidOperationException e) { if (e.InnerException is ArgumentNullException) { var x = 1; //DO SOMETHING WITH THE ORIGIONAL ERROR! } //DO SOMETHING WITH THE ORIGIONAL ERROR! return(null); } }