Пример #1
0
        public MockController3(MockState state, INavigator navigator, UipTask task, IViewDeck viewManager) {
            Assert.IsNotNull(state);
            Assert.IsNotNull(navigator);
            Assert.IsNotNull(task);
            this.state = state;
            this.navigator = navigator;

            // the view manager does not get used, just checking that it is passed if it is needed
            Assert.IsNotNull(viewManager);
            this.viewManager = viewManager;

            if (task.CurrentNode.Name == "NoViewNode") {
                state.SetByController3 = true;
            	navigator.Next();
            }
        }
Пример #2
0
		/// <summary>
		/// Start the UI task.
		/// </summary>
		/// <param name="viewManager">View manager for the task.</param>
		/// <exception cref="UipException">
		/// Task has already started.
		/// </exception>
		public void Start(IViewDeck viewManager)
		{
			Verify.ArgumentNotNull(viewManager, "viewManager");
			if (IsRunning)
			{
				const string message = "Task is already running";
				Log.Error(message);
				throw new UipException(message);
			}
			if (IsComplete)
			{
				// This is a bit of a restriction, sorry. When a task has completed, there is
				// quite a bit of cleaning up to do to re-use it. At the moment it is easier to
				// just have the restriction that UI tasks cannot be reused.
				const string message = "A task can only be run once.";
				Log.Error(message);
				throw new UipException(message);
			}

			// If you have a UI task that is run more than once you
			// are going to have a problem, because each time you might be using a different IViewManager.
			// One way to deal with this is to have (yet another) child container that is created each
			// time the UI task is started.
			//
			// The way this is solved at the moment is to prevent re-use of UI tasks. See test before this
			// for avoiding re-use of tasks.
			_viewManager = viewManager;
			_serviceContainer.RegisterInstance(_viewManager);

			// For backwards compatible UipQuestion calls.
			_serviceContainer.RegisterType<IUipViewManager, UipViewManager>(ServiceLifecycle.Singleton);

			// Register the nested interfaces one time only. Wait until the first run
			// to do this, as the controller and view types are not available in the constructor.
			if (!_taskInitialized)
			{
				InitializeTask();
				_taskInitialized = true;
			}


			Navigate(null);
		}