Ejemplo n.º 1
0
            void WebformsView_Init(object sender, EventArgs e)
            {
                IView view = sender as IView;

                (view as Page).Init -= new EventHandler(WebformsView_Init);
                HttpContext httpContext = HttpContext.Current;
                ITask       currTask    = httpContext.Session[currTaskKey] as ITask;

                if (currTask == null)
                {
                    return;
                }
                WebformsViewInfo requestedViewInf = (currTask.Navigator.ViewsManager.ViewInfos
                                                     as WebformsViewInfoCollection).GetByUrl(httpContext.Request.AppRelativeCurrentExecutionFilePath);

                currTask.Navigator.TryNavigateToView(requestedViewInf.ViewName);
                IController requestedController = currTask.Navigator.GetController(requestedViewInf.ViewName);

                view.ViewName   = requestedViewInf.ViewName;
                view.Controller = requestedController;
                if (view.Controller != null)
                {
                    view.Controller.View = view;
                }
            }
Ejemplo n.º 2
0
        /// <summary>
        /// IViewsManager.ActivateView implementation.
        /// </summary>
        #endregion
        public override void ActivateView(string viewName)
        {
            HttpContext      httpContext = HttpContext.Current;
            WebformsViewInfo currViewInf = ViewInfos.GetByUrl(httpContext.Request.
                                                              AppRelativeCurrentExecutionFilePath);

            if ((currViewInf != null) && (currViewInf.ViewName == viewName))
            {
                return;
            }
            httpContext.Session[currTaskKey] = Navigator.Task;
            httpContext.Response.Redirect(ViewInfos[viewName].ViewUrl, true);
        }
Ejemplo n.º 3
0
        public void TestGetFromAssembly()
        {
            ViewInfosByTaskCollection viewInfsByTask = new WebformsViewInfosProvider()
                                                       .GetFromAssembly(Assembly.GetExecutingAssembly());
            WebformsViewInfoCollection viewInfs1 = viewInfsByTask[typeof(int)] as WebformsViewInfoCollection;
            WebformsViewInfoCollection viewInfs2 = viewInfsByTask[typeof(string)] as WebformsViewInfoCollection;
            WebformsViewInfoCollection viewInfs3 = viewInfsByTask[typeof(Array)] as WebformsViewInfoCollection;

            Assert.IsNotNull(viewInfs1);
            Assert.IsNotNull(viewInfs2);
            Assert.IsNotNull(viewInfs3);

            WebformsViewInfo viewInf1 = viewInfs1["MainView"];

            Assert.AreEqual("MainView", viewInf1.ViewName);
            Assert.AreEqual("default.aspx", viewInf1.ViewUrl);

            Assert.AreSame(viewInfs2["MainView"], viewInfs2.GetByUrl("Other/Default.aspx"));
            Assert.AreSame(viewInfs2["Other View"], viewInfs2.GetByUrl("Other/Other.aspx"));
            Assert.AreSame(viewInfs2["Other View 2"], viewInfs2.GetByUrl("~/Other/Other2.aspx"));
        }