コード例 #1
0
        protected void SelfRegister(System.Web.UI.UserControl control)
        {
            if (control != null && control is IView)
            {
                object[] attributes = control.GetType().GetCustomAttributes(typeof(PresenterTypeAttribute), true);

                if (attributes != null && attributes.Length > 0)
                {
                    foreach (Attribute viewAttribute in attributes)
                    {
                        if (viewAttribute is PresenterTypeAttribute)
                        {
                            //Had to grab the application context that gets created in the global.asax and shoved into the httpcontext.current.items collection.  In order to use it I have to assign it to the ISessionProvider because presenters have no knowledge of httpcontext.
                            var sessionProvider = new WebSessionProvider();
                            SessionManager.Current = sessionProvider;
                            //if (HttpContext.Current.Items[ResourceStrings.Session_ApplicationContext] != null)
                            //{
                            //    SessionManager.Current[ResourceStrings.Session_ApplicationContext] = (ApplicationContext)HttpContext.Current.Items[ResourceStrings.Session_ApplicationContext];
                            //}
                            PresentationManager.RegisterView((viewAttribute as PresenterTypeAttribute).PresenterType, control as IView, sessionProvider);

                            if (SecurityContextManager.Current == null)
                            {
                                SecurityContextManager.Current = new WebSecurityContext();
                            }
                            break;
                        }
                    }
                }
            }
        }
コード例 #2
0
        protected void SelfRegister(System.Web.UI.UserControl control)
        {
            if (control != null && control is IView)
            {
                object[] attributes = control.GetType().GetCustomAttributes(typeof(PresenterTypeAttribute), true);

                if (attributes != null && attributes.Length > 0)
                {
                    foreach (Attribute viewAttribute in attributes)
                    {
                        if (viewAttribute is PresenterTypeAttribute)
                        {
                            PresentationManager.RegisterView((viewAttribute as PresenterTypeAttribute).PresenterType, control as IView, new WebSessionProvider(), new WebSecurityContext());
                            break;
                        }
                    }
                }
            }
        }
コード例 #3
0
        protected void SelfRegister(System.Web.UI.Page page)
        {
            if (page != null && page is IView)
            {
                object[] attributes = page.GetType().GetCustomAttributes(typeof(PresenterTypeAttribute), true);

                if (attributes != null && attributes.Length > 0)
                {
                    foreach (Attribute viewAttribute in attributes)
                    {
                        if (viewAttribute is PresenterTypeAttribute)
                        {
                            PresentationManager.RegisterView((viewAttribute as PresenterTypeAttribute).PresenterType, page as IView, new WebSessionProvider());
                            if (SecurityContextManager.Current == null)
                            {
                                SecurityContextManager.Current = new WebSecurityContext();
                            }
                            break;
                        }
                    }
                }
            }
        }
コード例 #4
0
 protected T RegisterView <T>() where T : Presenter
 {
     return(PresentationManager.RegisterView <T>(typeof(T), this, new WebSessionProvider()));
 }