Example #1
0
        protected override async Task <UiFlowScreenModel> OnCreateModelAsync(IUiFlowContextData contextData)
        {
            ThrowIfMustFail(contextData, ScreenLifecycleStage.CreatingStepData);
            var result = new InitialScreenScreenModel();

            return(result);
        }
Example #2
0
        protected override async Task <UiFlowScreenModel> OnCreateModelAsync(IUiFlowContextData contextData)
        {
            var initData       = contextData.GetStepData <FlowInitializer.StartScreenModel>(ScreenName.PreStart);
            var screenStepData = contextData.GetStepData <InitialScreen.InitialScreenScreenModel>();

            return(new ExitReturnToCaller(initData, screenStepData.StringValue));
        }
Example #3
0
 protected override async Task <UiFlowScreenModel> OnCreateModelAsync(IUiFlowContextData contextData)
 {
     return(new StepBScreenScreenModel
     {
         //TODO: rest
     });
 }
Example #4
0
        protected override async Task <UiFlowScreenModel> OnCreateModelAsync(IUiFlowContextData contextData)
        {
            var result = await base.OnCreateModelAsync(contextData);

            result.SetContainedFlow("GreenFlow");
            return(result);
        }
Example #5
0
 protected override IScreenFlowConfigurator OnRegisterUserActions(
     IScreenFlowConfigurator screenConfiguration, IUiFlowContextData contextData)
 {
     return(screenConfiguration
            .OnEventReentriesCurrent(ScreenEvent.ErrorOccurred)
            .OnEventNavigatesTo(ScreenInputEvent.Submit, ModelTesterFlowStep.FlowCompletedScreen));
 }
Example #6
0
        public async Task <UiFlowScreenModel> RefreshStepDataAsync(IUiFlowContextData contextData,
                                                                   UiFlowScreenModel originalScreenModel, IDictionary <string, object> stepViewCustomizations = null)
        {
            TraceBegin(nameof(RefreshStepDataAsync), contextData);

            var result = originalScreenModel;

            if (!_stepDataLoaded)
            {
                await _syncLock.AsyncCriticalSection(async() =>
                {
                    if (!_stepDataLoaded)
                    {
                        LifecycleStage  = ScreenLifecycleStage.RefreshingStepData;
                        _stepDataLoaded = true;

                        var onRefreshStepDataAsync =
                            await OnRefreshModelAsync(contextData, originalScreenModel, stepViewCustomizations);
                        await OnScreenLoadCompletedAsync(contextData);
                        result         = onRefreshStepDataAsync;
                        LifecycleStage = ScreenLifecycleStage.RefreshStepDataCompleted;
                    }
                }
                                                     );
            }
            TraceEnd(nameof(RefreshStepDataAsync), contextData);

            return(result);
        }
Example #7
0
 protected override async Task <UiFlowScreenModel> OnCreateModelAsync(IUiFlowContextData contextData)
 {
     return(new StepAScreenScreenModel()
     {
         ScreenTitle = "Green Flow -Step A"
     });
 }
        protected override IScreenFlowConfigurator OnRegisterUserActions(
            IScreenFlowConfigurator screenConfiguration, IUiFlowContextData contextData)
        {
            var prestart = contextData.GetStepData <FlowInitializer.StartScreenModel>(ScreenName.PreStart);


            return(screenConfiguration.OnEventReentriesCurrent(ScreenEvent.ErrorOccurred)
                   .OnEventNavigatesTo(ScreenInputEvent.Reset, BlueFlowScreenName.Step0Screen)
                   .OnEventNavigatesTo(ScreenInputEvent.FlowTransitionCompleted, BlueFlowScreenName.FlowCompletedScreen, () => !prestart.MustReturnToCaller, "Not Called from another flow expecting result")
                   .OnEventNavigatesTo(ScreenInputEvent.FlowTransitionCompleted, BlueFlowScreenName.EndAndReturnToCaller, () => prestart.MustReturnToCaller, "Called from another flow expecting result")
                   .OnEventNavigatesTo(ScreenInputEvent.Previous, BlueFlowScreenName.FillDataStep_StepBScreen,
                                       () => !ByPassedStepAandB(), "Comes from B")
                   .OnEventNavigatesTo(ScreenInputEvent.Previous, BlueFlowScreenName.Step0Screen, ByPassedStepAandB,
                                       "Comes from step0")

                   .OnEventExecutes(ScreenInputEvent.Reset, (e, ctx) => ctx.Reset()));

            bool ByPassedStepAandB()
            {
                var stepValue1 = contextData
                                 .GetStepData <InitialScreen.InitialScreenScreenModel>(BlueFlowScreenName.Step0Screen).StepValue1;

                return(stepValue1 != null && stepValue1.StartsWith('a'));
            }
        }
Example #9
0
 protected override Task <UiFlowScreenModel> OnRefreshModelAsync(IUiFlowContextData contextData,
                                                                 UiFlowScreenModel originalScreenModel,
                                                                 IDictionary <string, object> stepViewCustomizations = null)
 {
     ThrowIfMustFail(contextData, ScreenLifecycleStage.RefreshingStepData);
     return(base.OnRefreshModelAsync(contextData, originalScreenModel, stepViewCustomizations));
 }
Example #10
0
        protected override async Task <UiFlowScreenModel> OnRefreshModelAsync(IUiFlowContextData contextData, UiFlowScreenModel originalScreenModel,
                                                                              IDictionary <string, object> stepViewCustomizations = null)
        {
            await SetTitle(contextData, (Number2ContainerScreenModel)originalScreenModel);

            return(originalScreenModel);
        }
Example #11
0
 private async Task OnHandlingStepEvent(ScreenEvent triggeredEvent, IUiFlowContextData contextData)
 {
     if (_eventHandlers.ContainsKey(triggeredEvent))
     {
         var eventHandler = _eventHandlers[triggeredEvent];
         await eventHandler(triggeredEvent, contextData);
     }
 }
Example #12
0
        protected override async Task <UiFlowScreenModel> OnCreateModelAsync(IUiFlowContextData contextData)
        {
            var model = new Number2ContainerScreenModel();

            await SetTitle(contextData, model);

            return(model);
        }
Example #13
0
        protected override async Task <UiFlowScreenModel> OnRefreshModelAsync(IUiFlowContextData contextData,
                                                                              UiFlowScreenModel originalScreenModel, IDictionary <string, object> stepViewCustomizations = null)
        {
            var result = Map(contextData.GetStepData <InputScreen.ScreenModel>(ModelTesterFlowStep.InputScreen),
                             contextData.GetCurrentStepData <ScreenModel>());

            return(result);
        }
Example #14
0
        protected override bool OnValidate(ScreenEvent transitionTrigger,
                                           IUiFlowContextData contextData, out string errorMessage)
        {
            var result = true;

            errorMessage = null;

            return(result);
        }
Example #15
0
 protected override async Task <UiFlowScreenModel> OnCreateModelAsync(IUiFlowContextData contextData)
 {
     return(new StepData("BlueFlow",
                         new BlueFlow.Steps.FlowInitializer.StartScreenModel
     {
         CallbackFlowHandler = contextData.FlowHandler,
         CallbackFlowEvent = ScreenInputEvent.ToStep2,
     }, asContained: true));
 }
Example #16
0
        private void ThrowIfMustFail(IUiFlowContextData contextData, ScreenLifecycleStage stage)
        {
            var root = contextData.GetStepData <FlowInitializer.StartScreenModel>();

            if (root != null && (ScreenName)root.FailOnStep == ScreenNameId && root.FailOnEvent == stage)
            {
                throw new Exception($"Failing on {ScreenNameId}.{stage}");
            }
        }
Example #17
0
 protected override async Task <UiFlowScreenModel> OnCreateModelAsync(IUiFlowContextData contextData)
 {
     return(new StepData("BlueFlow",
                         new BlueFlow.Steps.FlowInitializer.StartScreenModel
     {
         GreenFlowData = contextData.GetStepData <InitialScreen.InitialScreenScreenModel>().StepValue1,
         CallbackFlowHandler = contextData.FlowHandler,
         CallbackFlowEvent = ScreenInputEvent.BlueFlowCompleted
     }));
 }
Example #18
0
        protected override IScreenFlowConfigurator OnRegisterUserActions(
            IScreenFlowConfigurator screenConfiguration,
            IUiFlowContextData contextData)
        {
            return(screenConfiguration
                   .OnEventNavigatesTo(ScreenInputEvent.BlueFlowCompleted, GreenFlowScreenName.FlowCompletedScreen)

                   .OnEventExecutes(ScreenInputEvent.BlueFlowCompleted,
                                    (e, ctx) => ctx.GetCurrentStepData <StepData>().BlueFlowCompletedEventHandled = true));
        }
Example #19
0
        protected override async Task <UiFlowScreenModel> OnCreateModelAsync(IUiFlowContextData contextData)
        {
            var a = contextData.GetStepData <Number1ContainerScreen.StepData>(ContainersFlow3ScreenName.Number1ContainerScreen);

            return(new ScreenModel()
            {
                BlueFlowSelectedInput = a.CalledFlowResult,
                Step1Loaded = a.InitialLoad
            });
        }
Example #20
0
 protected override async Task <UiFlowScreenModel> OnCreateModelAsync(IUiFlowContextData contextData)
 {
     return(new StepCScreenScreenModel
     {
         FlowInputData = contextData.GetStepData <FlowInitializer.StartScreenModel>(ScreenName.PreStart).SampleParameter,
         InitialValue = contextData.GetStepData <InitialScreen.InitialScreenScreenModel>(GreenFlowScreenName.Step0Screen).StepValue1,
         StepAValue = contextData.GetStepData <StepAScreen.StepAScreenScreenModel>(GreenFlowScreenName.StepAScreen)?.StepAValue1,
         StepBValue = contextData.GetStepData <StepBScreen.StepBScreenScreenModel>(GreenFlowScreenName.StepBScreen)?.StepBValue1,
     });
 }
Example #21
0
        protected override IScreenFlowConfigurator OnRegisterUserActions(
            IScreenFlowConfigurator screenConfiguration, IUiFlowContextData contextData)
        {
            return(screenConfiguration.OnEventReentriesCurrent(ScreenEvent.ErrorOccurred)
                   .OnEventNavigatesTo(ScreenInputEvent.Reset, GreenFlowScreenName.Step0Screen)
                   .OnEventNavigatesTo(ScreenInputEvent.Next, GreenFlowScreenName.StepCScreen)
                   .OnEventNavigatesTo(ScreenInputEvent.Previous, GreenFlowScreenName.StepAScreen)

                   .OnEventExecutes(ScreenInputEvent.Reset, (e, ctx) => ctx.Reset())
                   .OnEventExecutes(ScreenInputEvent.Previous, (e, ctx) => ctx.GetCurrentStepData <StepBScreenScreenModel>().StepBValue1 = null));
        }
Example #22
0
        protected override async Task <UiFlowScreenModel> OnCreateModelAsync(IUiFlowContextData contextData)
        {
            var result = new ErrorScreenModel();

            result.Error            = contextData.LastError.ExceptionMessage;
            result.OnStep           = contextData.LastError.OccurredOnStep;
            result.OnLifecycleEvent = contextData.LastError.LifecycleStage.ToString();

            //error handled
            contextData.LastError = null;

            return(result);
        }
Example #23
0
        public bool ValidateTransitionAttempt(ScreenEvent triggeredEvent,
                                              IUiFlowContextData contextData, out string errorMessage)
        {
            TraceBegin(nameof(HandleStepEvent), contextData, triggeredEvent);
            LifecycleStage = ScreenLifecycleStage.ValidatingTransition;
            var isValid = OnValidate(triggeredEvent, contextData, out errorMessage);

            LifecycleStage = isValid
                                ? ScreenLifecycleStage.ValidateTransitionCompleted
                                : ScreenLifecycleStage.ValidateTransitionCompletedWithErrors;
            TraceEnd(nameof(HandleStepEvent), contextData, triggeredEvent);
            return(isValid);
        }
Example #24
0
        public async Task <UiFlowScreenModel> CreateStepDataAsync(IUiFlowContextData contextData)
        {
            TraceBegin(nameof(CreateStepDataAsync), contextData);
            LifecycleStage = ScreenLifecycleStage.CreatingStepData;
            var result = await OnCreateModelAsync(contextData);

            _stepDataLoaded = true;
            await OnScreenLoadCompletedAsync(contextData);

            LifecycleStage = ScreenLifecycleStage.CreateStepDataCompleted;
            TraceEnd(nameof(CreateStepDataAsync), contextData);

            return(result);
        }
Example #25
0
        public IScreenFlowConfigurator DefineActionHandlersOnCurrentScreen(IScreenFlowConfigurator screenConfiguration,
                                                                           IUiFlowContextData contextData)
        {
            TraceBegin(nameof(DefineActionHandlersOnCurrentScreen), contextData);
            LifecycleStage = ScreenLifecycleStage.DefiningTransitionsFromCurrentScreen;
            var cfg = OnRegisterUserActions(screenConfiguration, contextData);
            var internalScreenFlowConfigurator = ((IInternalScreenFlowConfigurator)cfg);

            internalScreenFlowConfigurator.AddErrorTransitionIfUndefined();
            this.Transitions    = internalScreenFlowConfigurator.Transitions;
            this._eventHandlers = internalScreenFlowConfigurator.Handlers;
            LifecycleStage      = ScreenLifecycleStage.DefineTransitionsFromCurrentScreenCompleted;
            TraceEnd(nameof(DefineActionHandlersOnCurrentScreen), contextData);
            return(cfg);
        }
Example #26
0
        protected override bool OnValidate(ScreenEvent transitionTrigger,
                                           IUiFlowContextData contextData, out string errorMessage)
        {
            var result = true;

            errorMessage = null;
            if (transitionTrigger == ScreenInputEvent.Next)
            {
                var viewModel = contextData.GetCurrentStepData <InitialScreenScreenModel>();
                var b         = int.TryParse(viewModel.StepValue1, out var value);
                errorMessage = b ? "Numeric only value  are not allowed" : string.Empty;
                result       = !b;
            }

            return(result);
        }
Example #27
0
        public async Task HandleStepEvent(ScreenEvent triggeredEvent, IUiFlowContextData contextData)
        {
            TraceBegin(nameof(HandleStepEvent), contextData, triggeredEvent);
            LifecycleStage = ScreenLifecycleStage.HandlingEvent;
            //TDO: inline next
            await OnHandlingStepEvent(triggeredEvent, contextData);

            var uiFlowStepData = contextData.GetCurrentStepData <UiFlowScreenModel>();

            if (uiFlowStepData != null)
            {
                uiFlowStepData.Errors = new List <UiFlowUserInputError>();
            }
            LifecycleStage = ScreenLifecycleStage.HandleEventCompleted;
            TraceEnd(nameof(HandleStepEvent), contextData, triggeredEvent);
        }
Example #28
0
        protected override async Task <UiFlowScreenModel> OnCreateModelAsync(IUiFlowContextData contextData)
        {
            var stepData = new FlowCompletedScreenScreenModel
            {
            };
            var runBlueFlowStep = contextData.GetStepData <RunBlueFlowScreen.StepData>(GreenFlowScreenName.RunBlueFlow);

            if (contextData.CurrentEvents.Any(x => x == RunBlueFlowScreen.ScreenInputEvent.BlueFlowCompleted) ||
                contextData.EventsLog.Any(x => x.Event == RunBlueFlowScreen.ScreenInputEvent.BlueFlowCompleted))
            {
                stepData.BlueFlowInitialScreenValue = runBlueFlowStep.CalledFlowResult;
            }

            stepData.BlueFlowEventHandled = runBlueFlowStep != null && runBlueFlowStep.BlueFlowCompletedEventHandled;

            return(stepData);
        }
Example #29
0
        protected override async Task <UiFlowScreenModel> OnRefreshModelAsync(IUiFlowContextData contextData,
                                                                              UiFlowScreenModel originalScreenModel, IDictionary <string, object> stepViewCustomizations = null)
        {
            var result = (StepCScreenScreenModel)originalScreenModel;


            result.FlowInputData = contextData.GetStepData <FlowInitializer.StartScreenModel>(ScreenName.PreStart).SampleParameter;
            result.InitialValue  = contextData
                                   .GetStepData <InitialScreen.InitialScreenScreenModel>(GreenFlowScreenName.Step0Screen).StepValue1;
            result.StepAValue = contextData
                                .GetStepData <StepAScreen.StepAScreenScreenModel>(GreenFlowScreenName.StepAScreen)
                                ?.StepAValue1;
            result.StepBValue = contextData
                                .GetStepData <StepBScreen.StepBScreenScreenModel>(GreenFlowScreenName.StepBScreen)
                                ?.StepBValue1;
            return(result);
        }
Example #30
0
        protected override bool OnValidate(ScreenEvent transitionTrigger,
                                           IUiFlowContextData contextData, out string errorMessage)
        {
            var result = true;

            errorMessage = null;
            if (transitionTrigger == ScreenInputEvent.Next)
            {
                var viewModel = contextData.GetCurrentStepData <StepBScreenScreenModel>();
                result = !string.IsNullOrEmpty(viewModel.StepBValue1);
                if (!result)
                {
                    errorMessage = "Value cannot be empty";
                }
            }


            return(result);
        }