Ejemplo n.º 1
0
        public static void CreateContext(HttpContext httpContext)
        {
            WebAppConfig.Init();

            HttpContextBase context = new OnlineHttpContext(httpContext);

            Current = context;

            if (httpContext.Session != null)
            {
                context.SessionObject = WebAppHelper.CreateSessionObject();
            }
        }
Ejemplo n.º 2
0
        internal string RenderView(ControllerAction controllerAction)
        {
            string method = _innerView ?? controllerAction.Method;
            Skin   layout = IsAjax() ? null : WebAppHelper.GetLayout(_layoutName);
            Skin   skin   = WebAppHelper.GetSkin(_viewName, method);

            string outerHTML;

            ViewData["SESSION"]  = WebAppContext.Session;
            ViewData["VIEWNAME"] = ViewName;
            ViewData["METHOD"]   = method;
            ViewData["URL"]      = Url;
            ViewData["CUR"]      = Url.Substring(0, Url.LastIndexOf('/'));
            ViewData["SELF"]     = string.Concat(Url, "/", method);

            ViewData["CHECK"] = new Function("Check", WebAppConfig.SecurityProvider);

            ViewData["R"] = ResourceManager.GetResources();

            if (WebAppContext.Request.ApplicationPath != "/")
            {
                ViewData["ROOT"] = WebAppContext.Request.ApplicationPath;
            }
            else
            {
                ViewData["ROOT"] = "";
            }

            ViewData["THEME"]     = WebAppConfig.ThemePath;
            ViewData["EXTENSION"] = WebAppConfig.Extension;

            if (layout == null)
            {
                outerHTML = skin.RenderView(ViewData);
            }
            else
            {
                outerHTML        = skin.RenderView(ViewData);
                ViewData["VIEW"] = outerHTML.TrimStart();
                outerHTML        = layout.RenderView(ViewData);
            }

            return(outerHTML);
        }
Ejemplo n.º 3
0
        public bool Run(Controller controller, string methodName)
        {
            try
            {
                MethodSchema data;

                if (_publicMethods.TryGetValue(methodName, out data))
                {
                    foreach (MethodSchema beforeData in _beforeMethods)
                    {
                        beforeData.InvokeHandler.Invoke(controller, WebAppHelper.CreateParameters(beforeData.Parameters, controller.ViewData));
                    }

                    data.InvokeHandler.Invoke(controller, WebAppHelper.CreateParameters(data.Parameters, controller.ViewData));

                    foreach (MethodSchema afterData in _afterMethods)
                    {
                        afterData.InvokeHandler.Invoke(controller, WebAppHelper.CreateParameters(afterData.Parameters, controller.ViewData));
                    }
                }
                else
                {
                    throw new InvokeException(methodName, controller.GetType());
                }

                return(true);
            }
            catch (TargetInvocationException ex)
            {
#if MEDIUMLEVEL
                throw ex.InnerException;
#else
                FieldInfo remoteStackTrace = typeof(Exception).GetField("_remoteStackTraceString", BindingFlags.Instance | BindingFlags.NonPublic);

                remoteStackTrace.SetValue(ex.InnerException, ex.InnerException.StackTrace + "\r\n");

                throw ex.InnerException;
#endif
            }
        }