public FlowContextTrace(string scopeId, IEnumerable <Difference> diff, UiFlowContextData initial, UiFlowContextData final) { ScopeId = scopeId; Diff = diff; Initial = initial; Final = final; }
public UiFlowContextData CreateNew() { var result = new UiFlowContextData(); result.CurrentScreenStep = ScreenName.PreStart; Attach(result); return(result); }
public ScreenName RunNavigation(ScreenEvent eventToTrigger, UiFlowContextData contextData = null) { var navigations = new TestFlowCreateStepDataConfigurator(_target); _target.OnDefiningAdditionalInitialStateTransitions(navigations, contextData ?? _uiFlowContextData ?? new UiFlowContextData()); return(navigations.Execute(eventToTrigger)); }
public async Task <UiFlowContextData> Save(UiFlowContextData contextData) { var jsonData = contextData.ToJson(true); await _store.SetAsync(contextData.FlowHandler, jsonData); Logger.Debug(() => $"Added {contextData.FlowHandler}"); return(contextData); }
public async Task <UiFlowContextData> CreateSnapshotOfContext(UiFlowContextData source) { if (!Store.ContainsKey(source.FlowHandler)) { throw new ArgumentException("the context must be attached before creating an snapshot"); } var ctx = source.CloneAsNew(this); Attach(ctx); UpdateClonedSteps(); await UpdateContainer(); UpdateFollowingSnapshot(); return(ctx); void UpdateClonedSteps() { foreach (var stepData in ctx.ViewModels.Values) { stepData.FlowHandler = ctx.FlowHandler; } } async Task UpdateContainer() { if (ctx.IsInContainer()) { var container = await Get(ctx.ContainerFlowHandler); container = await CreateSnapshotOfContext(container); var currentStepData = container.GetCurrentStepData <UiFlowScreenModel>().Metadata; if (currentStepData != null) { currentStepData.ContainedFlowHandler = ctx.FlowHandler; } ctx.ContainerFlowHandler = container.FlowHandler; } } void UpdateFollowingSnapshot() { if (!string.IsNullOrWhiteSpace(source.NextFlowHandler)) { Store.TryRemove(source.NextFlowHandler, out var deleted); _removed.Add(source.NextFlowHandler); } source.NextFlowHandler = ctx.FlowHandler; } }
protected override Task <StartScreenModel> OnBuildStartData(UiFlowContextData newContext, StartScreenModel preloadedInputData) { if (nameof(FlowInitializer).Equals(preloadedInputData.FailOnStep, StringComparison.InvariantCultureIgnoreCase) && preloadedInputData.FailOnEvent == ScreenLifecycleStage.FlowInitialization) { throw new Exception($"Triggering failure on {GetType().Name}"); } return(base.OnBuildStartData(newContext, preloadedInputData)); }
private async Task <TFlowInputData> BuildStartData(UiFlowContextData newContext, IDictionary <string, object> flowInputData) { var expandoObject = flowInputData.ToExpandoObject(); var result = await OnBuildStartData(newContext, expandoObject.ToObjectOfType <TFlowInputData>(false)); return(result); }
public async Task <UiFlowContextData> GetRootContainerContext(UiFlowContextData ctx) { if (ctx.IsInContainer()) { var containerContext = await Get(ctx.ContainerFlowHandler); return(await GetRootContainerContext(containerContext)); } return(ctx); }
public static UiFlowScreenModel AddStepData(this UiFlowContextData ctx, string flowScreenName, bool setCurrentStepData = false) { var userData = new UiFlowScreenModel(); userData.Metadata.FlowHandler = ctx.FlowHandler; userData.Metadata.FlowScreenName = flowScreenName; ctx.SetStepData(flowScreenName, userData); if (setCurrentStepData) { ctx.CurrentScreenStep = flowScreenName; } return(userData); }
public async Task <ScreenEvent> InitializeContext(UiFlowContextData newContext, IDictionary <string, object> flowInputData, ScreenEvent defaultEventToTrigger) { var data = await BuildStartData(newContext, flowInputData); data.Metadata.FlowHandler = newContext.FlowHandler; data.Metadata.FlowType = newContext.FlowType; data.Metadata.FlowScreenName = typeof(EmptyScreenModel).FullName; newContext.SetCurrentStepData(data); return(await ResolveInitializationEventToTrigger(defaultEventToTrigger, data)); }
public void CanDeserialize() { var ctx = new UiFlowContextData(); ctx.CurrentScreenStep = ScreenName.PreStart; var flowScreenName = "stepDataA"; var expected = ctx.AddStepData(flowScreenName); var actual = ctx.ToJson(true).JsonToObject <UiFlowContextData>(true); var userMetadata = actual.ViewModels[flowScreenName]; Assert.AreEqual(ctx.FlowHandler, userMetadata.FlowHandler); Assert.IsNotNull(userMetadata.UserData); Assert.AreEqual(expected, userMetadata.UserData); }
internal FlowInitializerWithLifecycleAdapter(IUiFlowInitializationStep target) { _target = target; SetRegistry(); _uiFlowContextData = new UiFlowContextData { CurrentScreenStep = ScreenName.PreStart }; void SetRegistry() { var items = typeof(TInitializer).Namespace.Split('.').SkipLast(2); var flowsRootNamespace = string.Join('.', items); _target.SetPropertyValueFast(nameof(UiFlowScreen.Registry), new FlowsRegistry(typeof(TInitializer).Assembly, flowsRootNamespace, string.Empty)); } }
internal FlowScreenWithLifecycleAdapter(TFlowScreen target, IFixture fixture) { Fixture = fixture; _target = target; SetRegistry(); _uiFlowContextData = new UiFlowContextData { CurrentScreenStep = GetStep() }; void SetRegistry() { var items = typeof(TFlowScreen).Namespace.Split('.').SkipLast(2); var flowsRootNamespace = string.Join('.', items); _target.SetPropertyValueFast(nameof(UiFlowScreen.Registry), new FlowsRegistry(typeof(TFlowScreen).Assembly, flowsRootNamespace, string.Empty)); } }
public override IScreenFlowConfigurator OnDefiningAdditionalInitialStateTransitions(IScreenFlowConfigurator preStartCfg, UiFlowContextData contextData) { return(preStartCfg.OnEventNavigatesTo(ScreenEvent.Start, ContainersFlowScreenName.Number1ContainerScreen)); }
public override IScreenFlowConfigurator OnDefiningAdditionalInitialStateTransitions(IScreenFlowConfigurator preStartCfg, UiFlowContextData contextData) { return(preStartCfg.OnEventNavigatesTo(ScreenEvent.ErrorOccurred, StartFailureFlowScreenName.FailureScreen)); }
protected virtual async Task <TFlowInputData> OnBuildStartData(UiFlowContextData newContext, TFlowInputData preloadedInputData) { return(preloadedInputData); }
public override IScreenFlowConfigurator OnDefiningAdditionalInitialStateTransitions(IScreenFlowConfigurator preStartCfg, UiFlowContextData contextData) { return(preStartCfg.OnEventNavigatesTo(ScreenEvent.Start, GreenFlowScreenName.Step0Screen , () => contextData.GetCurrentStepData <StartScreenModel>().SampleParameter != "Finish" , "normal start" ) .OnEventNavigatesTo(ScreenEvent.Start, GreenFlowScreenName.FlowCompletedScreen , () => contextData.GetCurrentStepData <StartScreenModel>().SampleParameter == "Finish" , "straight to the end" )); }
private void Attach(UiFlowContextData contextData) { contextData.SetRepository(this); Store.AddOrUpdate(contextData.FlowHandler, a => Task.FromResult(contextData), (a, b) => Task.FromResult(contextData)); }
public override IScreenFlowConfigurator OnDefiningAdditionalInitialStateTransitions(IScreenFlowConfigurator preStartCfg, UiFlowContextData contextData) { return(preStartCfg.OnEventNavigatesTo(ScreenEvent.Start, MetadataTestFlowScreenScreenName.Step0Screen)); }
public override IScreenFlowConfigurator OnDefiningAdditionalInitialStateTransitions(IScreenFlowConfigurator preStartCfg, UiFlowContextData contextData) { return(preStartCfg.OnEventNavigatesTo(ScreenEvent.Start, ModelTesterFlowStep.InputScreen)); }
OnDefiningAdditionalInitialStateTransitions(IScreenFlowConfigurator preStartCfg, UiFlowContextData contextData) { return(preStartCfg); }
private async Task <TResult> InputOnRedirectToRoot(FlowResultResolverRequest <TResult> input, UiFlowContextData uiFlowContextData) { var root = await _contextRepository.GetRootContainerContext(uiFlowContextData); return(await input.OnRedirectToRoot(root.FlowType, root.FlowHandler)); }