protected void SetLifecycleStateTo(LifecycleState state)
            {
                var operations = new ScreenLifecycleOperations(Aggregator, Screen);

                if (state == LifecycleState.Created)
                {
                    return;
                }

                operations.Initialize();

                if (state == LifecycleState.Initialized)
                {
                    return;
                }

                operations.Activate();

                if (state == LifecycleState.Activated)
                {
                    return;
                }

                operations.Deactivate();

                if (state == LifecycleState.Deactivated)
                {
                    return;
                }

                operations.Close();

                if (state == LifecycleState.Closed)
                {
                    return;
                }

                if (state == LifecycleState.ExceptionOccured)
                {
                    Aggregator.Publish(
                        ScreenEvents.LifecycleExceptionOccured,
                        new ScreenEventArgs(Screen)
                        );
                }
                else
                {
                    throw new NotSupportedException();
                }
            }
예제 #2
0
        private void CloseScreen(bool checkState)
        {
            var screenLifecycle = ScreenHelper.GetChild <ScreenLifecycle>(_screen);
            var ops             = new ScreenLifecycleOperations(_aggregator, _screen);

            if (!checkState || screenLifecycle.CanDeactivate)
            {
                ops.Deactivate();
            }

            if (!checkState || screenLifecycle.CanClose)
            {
                ops.Close();
            }
        }