Ejemplo n.º 1
0
 public BeeHtmlHelper(BeePageView view)
 {
     this.owner = view;
 }
Ejemplo n.º 2
0
        public override void Ouput(HttpContext context)
        {
            BeePageView pageBase = null;

            dataAdapter.Add(Constants.BeeAutoModelInfo, instance.AutoModelInfo());

            string areaName = dataAdapter.TryGetValue <string>(Constants.BeeAreaName, string.Empty);

            string virtualPath = string.Empty;

            if (actionName.StartsWith("BeeAuto"))
            {
                virtualPath = string.Format("/InnerViews/{0}.aspx", actionName);
            }
            else
            {
                if (string.IsNullOrEmpty(areaName))
                {
                    virtualPath = string.Format("/Views/{0}/{1}.aspx", controllerName, actionName);
                }
                else
                {
                    virtualPath = string.Format("/Views/{2}/{0}/{1}.aspx", controllerName, actionName, areaName);
                }
            }

            if (model != null)
            {
                dataAdapter[Constants.BeeModelName] = model;
            }

            if (context.Request.ApplicationPath != "/")
            {
                virtualPath = context.Request.ApplicationPath + virtualPath;
            }

            object o = BuildManager.CreateInstanceFromVirtualPath(virtualPath, typeof(object));

            if (o == null)
            {
                throw new MvcException(string.Format("Cannot find the page:{0}", virtualPath));
            }
            else
            {
                pageBase = o as BeePageView;
                Page page = o as Page;

                if (pageBase != null)
                {
                    pageBase.InitData(dataAdapter);

                    // 效率低于下面的方法
                    //context.Server.Execute(page, context.Response.Output, false);

                    pageBase.ProcessRequest(context);
                }
                else if (page != null)
                {
                    //context.Server.Execute(page, context.Response.Output, false);

                    page.ProcessRequest(context);
                }
                else
                {
                    throw new MvcException(string.Format("Cannot find the page:{0}", virtualPath));
                }
            }
        }