예제 #1
0
        static IPresenter BuildPresenter(
            HttpContextBase httpContext,
            ITraceContext traceContext,
            IMessageBus messageBus,
            Action <IPresenter> presenterCreatedCallback,
            IPresenterFactory presenterFactory,
            PresenterBinding binding,
            IView viewInstance)
        {
            traceContext.Write(typeof(PresenterBinder), () => string.Format(
                                   CultureInfo.InvariantCulture,
                                   "Creating presenter of type {0} for view of type {1}. (The actual view instance is of type {2}.)",
                                   binding.PresenterType.FullName,
                                   binding.ViewType.FullName,
                                   viewInstance.GetType().FullName));

            var presenter = presenterFactory.Create(binding.PresenterType, binding.ViewType, viewInstance);

            presenter.HttpContext = httpContext;
            presenter.Messages    = messageBus;
            if (presenterCreatedCallback != null)
            {
                presenterCreatedCallback(presenter);
            }
            return(presenter);
        }
예제 #2
0
        private static IPresenter BuildPresenter(
            IPresenterFactory presenterFactory,
            PresenterBinding binding,
            IView viewInstance)
        {
            var presenter = presenterFactory.Create(
                binding.PresenterType, binding.ViewType, viewInstance);

            return(presenter);
        }
예제 #3
0
        private static IPresenter PerformBinding(IView viewInstance, IPresenterFactory presenterFactory)
        {
            IPresenter presenter = null;
            //获取该视图的类类型
            Type t = viewInstance.GetType();

            //获取该类上的附加特性集合
            object[] attrs = t.GetCustomAttributes(typeof(PresenterBindingAttribute), false);
            //遍历特性集合,找到Presenter类型附加的特性,通过该特性建立实例
            foreach (PresenterBindingAttribute pba in attrs)
            {
                //获取Presenter类类型
                Type newt = pba.PresenterType;
                presenter = presenterFactory.Create(newt, t, viewInstance);
            }
            return(presenter);
        }
예제 #4
0
        protected IPresenter CreatePresenter(PresenterBindingParameter binding, IView view)
        {
            Require.NotNull(binding, nameof(binding));

            var presenter = _presenterFactory.Create(binding.PresenterType, binding.ViewType, view);

            if (presenter == null)
            {
                return(null);
            }

            // TODO: Explain this.
            ((Internal.IPresenter)presenter).Messages = _messageCoordinator;

            OnPresenterCreated(new PresenterEventArgs(presenter));

            return(presenter);
        }
예제 #5
0
        private static IPresenter BuildPresenter(
            Action <IPresenter> presenterCreatedCallback,
            //IAppState appState,
            IPresenterFactory presenterFactory,
            PresenterBinding binding,
            IView viewInstance)
        {
            Tracing.Verbose(
                "Creating presenter of type {0} for view of type {1}. (The actual view instance is of type {2}.)",
                binding.PresenterType.FullName,
                binding.ViewType.FullName,
                viewInstance.GetType().FullName
                );

            var presenter = presenterFactory.Create(binding.PresenterType, binding.ViewType, viewInstance);

            //presenter.Items = appState;

            if (presenterCreatedCallback != null)
            {
                presenterCreatedCallback(presenter);
            }
            return(presenter);
        }
예제 #6
0
        static IPresenter BuildPresenter(
            HttpContextBase httpContext,
            ITraceContext traceContext,
            IMessageBus messageBus,
            Action<IPresenter> presenterCreatedCallback,
            IPresenterFactory presenterFactory,
            PresenterBinding binding,
            IView viewInstance)
        {
            traceContext.Write(typeof(PresenterBinder), () => string.Format(
                CultureInfo.InvariantCulture,
                "Creating presenter of type {0} for view of type {1}. (The actual view instance is of type {2}.)",
                binding.PresenterType.FullName,
                binding.ViewType.FullName,
                viewInstance.GetType().FullName));

            var presenter = presenterFactory.Create(binding.PresenterType, binding.ViewType, viewInstance);
            presenter.HttpContext = httpContext;
            presenter.Messages = messageBus;
            if (presenterCreatedCallback != null)
            {
                presenterCreatedCallback(presenter);
            }
            return presenter;
        }
예제 #7
0
        private static IPresenter BuildPresenter(
            Action<IPresenter> presenterCreatedCallback,
            //IAppState appState,
            IPresenterFactory presenterFactory,
            PresenterBinding binding,
            IView viewInstance)
        {
            Tracing.Verbose(
                "Creating presenter of type {0} for view of type {1}. (The actual view instance is of type {2}.)",
                binding.PresenterType.FullName,
                binding.ViewType.FullName,
                viewInstance.GetType().FullName
                );

            var presenter = presenterFactory.Create(binding.PresenterType, binding.ViewType, viewInstance);

            //presenter.Items = appState;

            if (presenterCreatedCallback != null)
            {
                presenterCreatedCallback(presenter);
            }
            return presenter;
        }
 public void ShowPresenterDocked(Type presenterType, DockState state)
 {
     ChangeVisibilty(_factory.Create(presenterType), view => view.Show(_panel, state));
 }