コード例 #1
0
        /// <inheritdoc/>
        public IPresenterBuilder UseViewControllerFactory(IViewControllerFactory viewControllerFactory)
        {
            if (_viewControllerFactory != null)
            {
                throw new InvalidOperationException();
            }

            _viewControllerFactory = viewControllerFactory ?? throw new ArgumentNullException(nameof(viewControllerFactory));
            return(this);
        }
コード例 #2
0
ファイル: Presenter.cs プロジェクト: Arvtesh/UnityFx.Mvc
		internal Presenter(IServiceProvider serviceProvider, IViewFactory viewFactory, IViewControllerFactory controllerFactory, IPresenterEventSource eventSource)
		{
			Debug.Assert(serviceProvider != null);
			Debug.Assert(viewFactory != null);
			Debug.Assert(controllerFactory != null);

			_serviceProvider = serviceProvider;
			_viewFactory = viewFactory;
			_controllerFactory = controllerFactory;
			_eventSource = eventSource;
			_controllers = new ViewControllerCollection(_presentables);

			_eventSource?.AddPresenter(this);
		}
コード例 #3
0
        public MenuWindow(IViewControllerFactory factory)
        {
            InitializeComponent();

            this.categoryViewController   = factory.CreateCategoryViewController();
            this.dishViewController       = factory.CreateDishViewController();
            this.ingredientViewController = factory.CreateIngredientViewController();
            this.menuViewController       = factory.CreateMenuViewController();
            this.recipeViewController     = factory.CreateRecipeViewController();
            this.stockViewController      = factory.CreateStockViewController();

            categoryViewController.Subscribe(this);
            dishViewController.Subscribe(this);

            DisplayMenu();
        }
コード例 #4
0
        public PresentResult(IPresenterInternal presenter, PresentResultArgs context)
        {
            Debug.Assert(presenter != null);
            Debug.Assert(context != null);

            _presenter         = presenter;
            _id                = context.Id;
            _tag               = context.Tag;
            _layer             = context.Layer;
            _parent            = context.Parent;
            _serviceProvider   = context.ServiceProvider;
            _controllerFactory = context.ControllerFactory;
            _controllerType    = context.ControllerType;
            _presentArgs       = context.PresentArgs;
            _presentOptions    = context.PresentOptions;
            _deeplinkId        = GetDeeplinkId(_controllerType);
            _prefabPath        = string.IsNullOrEmpty(context.PrefabPath) ? GetDefaultPrefabName(_controllerType) : context.PrefabPath;
        }
コード例 #5
0
        /// <inheritdoc/>
        public IPresentService Build()
        {
            if (_presenter is null)
            {
                if (_eventSource is null && _gameObject is null)
                {
                    throw new InvalidOperationException("No event source is set. Presenter requires update notifications in order to function properly.");
                }

                if (_viewFactory is null)
                {
                    _viewFactory = _serviceProvider.GetService(typeof(IViewFactory)) as IViewFactory;

                    if (_viewFactory is null)
                    {
                        _viewFactory = _gameObject?.GetComponentInChildren <IViewFactory>();

                        if (_viewFactory is null)
                        {
                            throw new InvalidOperationException($"No {typeof(IViewFactory).Name} instance registered. It should be accessible either via IServiceProvider or with GameObject.GetComponentInChildren().");
                        }
                    }
                }

                if (_viewControllerFactory is null)
                {
                    _viewControllerFactory = _serviceProvider.GetService(typeof(IViewControllerFactory)) as IViewControllerFactory;

                    if (_viewControllerFactory is null)
                    {
                        _viewControllerFactory = new ViewControllerFactory(_serviceProvider);
                    }
                }

                _presenter = new Presenter(_serviceProvider, _viewFactory, _viewControllerFactory, _eventSource);
                _presenter.SetMiddleware(_presentDelegates);
                _presenter.SetErrorHandler(_errorDelegate);

                _gameObject?.AddComponent <PresenterBehaviour>().Initialize(_presenter);
            }

            return(_presenter);
        }
コード例 #6
0
 public MainMenuViewController(MainMenuView view, SceneWireframe wireframe, IViewControllerFactory factory) : base(view)
 {
     _wireframe = wireframe;
     _factory   = factory;
 }
コード例 #7
0
 public GameInitializer(SceneWireframe wireframe, IViewControllerFactory factory)
 {
     _wireframe = wireframe;
     _factory   = factory;
 }
コード例 #8
0
 public GamePlayViewController(GamePlayView view, SceneWireframe wireframe, IViewControllerFactory factory) : base(view)
 {
     _wireframe = wireframe;
     _factory   = factory;
 }
コード例 #9
0
 public GameInitializer(SceneWireframe wireframe, AssetLoader assetLoader)
 {
     _wireframe = wireframe;
     _factory   = new AssetBundleViewControllerFactory(_wireframe, assetLoader);
 }