internal ControllerActionInvokerCacheEntry( FilterItem[] cachedFilters, Func <ControllerContext, object> controllerFactory, Action <ControllerContext, object> controllerReleaser, ControllerBinderDelegate controllerBinderDelegate, ObjectMethodExecutor actionMethodExecutor) { ControllerFactory = controllerFactory; ControllerReleaser = controllerReleaser; ControllerBinderDelegate = controllerBinderDelegate; CachedFilters = cachedFilters; ActionMethodExecutor = actionMethodExecutor; }
// 合并参数绑定委托,检查Body类型如果是json则使用多参数绑定委托,如果不是,则使用mvc提供的默认委托 private ControllerBinderDelegate MergeControllerBinderDelegate(ControllerBinderDelegate clownFishWebDelegate, ControllerBinderDelegate mvcCoreDelegate) { return((controllerContext, controller, arguments) => { var contentType = controllerContext.HttpContext.Request.ContentType; if (string.IsNullOrEmpty(contentType) == false && contentType.IndexOf("application/json", StringComparison.OrdinalIgnoreCase) >= 0) { return clownFishWebDelegate(controllerContext, controller, arguments); } else { return mvcCoreDelegate(controllerContext, controller, arguments); } }); }
/// <summary> /// 替换cacheEntry; /// </summary> /// <param name="cacheEntry"></param> /// <param name="binderDelegate"></param> /// <returns></returns> private static ControllerActionInvokerCacheEntry ReplaceCacheEntry(ControllerActionInvokerCacheEntry cacheEntry, ControllerBinderDelegate binderDelegate) { return(s_getCacheEntryDelegate.Value(cacheEntry, binderDelegate)); }