コード例 #1
0
ファイル: MyFormHandler.cs プロジェクト: UNOPS/uimf-android
        private void RenderOutput(ViewGroup layout, InvokeForm.Response result, FormMetadata formMetadata, List <FormInputManager> inputsManager)
        {
            if (result?.Data == null)
            {
                return;
            }
            var reloadResponse = result.Data.CastTObject <ReloadResponse>();

            if (reloadResponse?.Form != null)
            {
                this.FormWrapper.ReloadView(this, reloadResponse);

                return;
            }
            var orderedOutputs = formMetadata.OutputFields.OrderBy(a => a.OrderIndex).ToList();

            foreach (var output in orderedOutputs)
            {
                if (!output.Hidden)
                {
                    object value;
                    if (result.Data.GetType() == typeof(JObject))
                    {
                        var jsonObj = (JObject)result.Data;
                        value = jsonObj.GetValue(output.Id, StringComparison.OrdinalIgnoreCase);
                    }
                    else
                    {
                        var propertyInfo = result.Data.GetType().GetProperty(output.Id);
                        value = propertyInfo?.GetValue(result.Data, null);
                    }
                    if (value != null)
                    {
                        var manager = this.ManagersCollection.OutputManagerCollection.GetManager(output.Type);
                        var view    = manager.GetView(output, value, this, formMetadata, inputsManager);
                        view.SetPadding(0, 10, 0, 10);
                        if (view.LayoutParameters == null)
                        {
                            view.LayoutParameters = layout.MatchParentWrapContent();
                        }
                        layout.AddView(view);
                    }
                }
            }
            // run on response handled events
            EventsManager.OnResponseHandledEvent(this, formMetadata, inputsManager, result);
        }