コード例 #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
        static IEnumerable <IPresenter> BuildPresenters(
            HttpContextBase httpContext,
            ITraceContext traceContext,
            IMessageBus messageBus,
            Action <IPresenter> presenterCreatedCallback,
            IPresenterFactory presenterFactory,
            PresenterBinding binding)
        {
            IEnumerable <IView> viewsToCreateFor;

            switch (binding.BindingMode)
            {
            case BindingMode.Default:
                viewsToCreateFor = binding.ViewInstances;
                break;

            case BindingMode.SharedPresenter:
                viewsToCreateFor = new[]
                {
                    CreateCompositeView(binding.ViewType, binding.ViewInstances, traceContext)
                };
                break;

            default:
                throw new NotSupportedException(string.Format(
                                                    CultureInfo.InvariantCulture,
                                                    "Binding mode {0} is not supported by this method.",
                                                    binding.BindingMode));
            }

            return(viewsToCreateFor.Select(viewInstance =>
                                           BuildPresenter(
                                               httpContext,
                                               traceContext,
                                               messageBus,
                                               presenterCreatedCallback,
                                               presenterFactory,
                                               binding,
                                               viewInstance)));
        }
コード例 #3
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;
        }
コード例 #4
0
        static IEnumerable<IPresenter> BuildPresenters(
            HttpContextBase httpContext,
            ITraceContext traceContext,
            IMessageBus messageBus,
            Action<IPresenter> presenterCreatedCallback,
            IPresenterFactory presenterFactory,
            PresenterBinding binding)
        {
            IEnumerable<IView> viewsToCreateFor;

            switch (binding.BindingMode)
            {
                case BindingMode.Default:
                    viewsToCreateFor = binding.ViewInstances;
                    break;
                case BindingMode.SharedPresenter:
                    viewsToCreateFor = new[]
                    {
                        CreateCompositeView(binding.ViewType, binding.ViewInstances, traceContext)
                    };
                    break;
                default:
                    throw new NotSupportedException(string.Format(
                        CultureInfo.InvariantCulture,
                        "Binding mode {0} is not supported by this method.",
                        binding.BindingMode));
            }

            return viewsToCreateFor.Select(viewInstance =>
                BuildPresenter(
                    httpContext,
                    traceContext,
                    messageBus,
                    presenterCreatedCallback,
                    presenterFactory,
                    binding,
                    viewInstance));
        }