Esempio n. 1
0
        public static void TrySetPageModel(HttpContext context)
        {
            if (context == null || context.Handler == null)
            {
                return;
            }

            IHttpHandler handler = context.Handler;

            // 判断当前处理器是否从MyPageView<TModel>继承过来
            Type handlerType = handler.GetType().BaseType;

            if (handlerType.IsGenericType &&
                handlerType.GetGenericTypeDefinition() == MyPageViewOpenType)
            {
                // 查找能响应这个请求的Action,并获取视图数据。
                InvokeInfo vkInfo = ReflectionHelper.GetActionInvokeInfo(context.Request.FilePath);
                if (vkInfo == null)
                {
                    return;
                }


                object model = ActionExecutor.ExecuteActionInternal(context, vkInfo);

                // 设置页面Model
                SetPageModel(context.Handler, model);
            }
        }