private async Task <AppMetadata.FlowMetadata.ScreenDataModelMetadata> ResolveScreenDataMetadata(
            IUiFlowScreen uiFlowScreen)
        {
            var  type     = uiFlowScreen.GetType();
            Type dataType = null;

            while (type != null && (dataType = type.GetNestedTypes().SingleOrDefault(x => x.Implements <IUiFlowScreenModel>())) == null && type.BaseType != null)
            {
                type = type.BaseType;
            }

            AppMetadata.FlowMetadata.ScreenDataModelMetadata resolveScreenDataMetadata = null;
            if (dataType != null)
            {
                resolveScreenDataMetadata = new AppMetadata.FlowMetadata.ScreenDataModelMetadata
                {
                    TypeName   = dataType.FullName,
                    Properties = dataType.GetProperties(BindingFlags.Instance | BindingFlags.Public |
                                                        BindingFlags.GetProperty | BindingFlags.SetProperty | BindingFlags.DeclaredOnly)
                                 .Select(x => new AppMetadata.FlowMetadata.ScreenDataModelMetadata.ScreenProperty
                    {
                        TypeName     = x.PropertyType.FullName,
                        Name         = x.Name,
                        IsSerialized = x.GetCustomAttribute <JsonIgnoreAttribute>() == null
                    }).ToArray()
                };
            }
            return(resolveScreenDataMetadata);
        }
        public async Task <AppMetadata.FlowMetadata.FlowStepMetadata> GetMetadata(IUiFlowScreen uiFlowScreen)
        {
            var result = new AppMetadata.FlowMetadata.FlowStepMetadata
            {
                Data        = await ResolveScreenDataMetadata(uiFlowScreen),
                Navigations = await ResolveUserNavigationsMetadata((UiFlowScreen)uiFlowScreen)
            };

            //TODO: resolve navigations



            return(result);
        }
Example #3
0
        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 TestFlowScreenConfigurator(IUiFlowScreen step) : base(step.ScreenNameId)
 {
     _step = step;
 }