コード例 #1
0
 public static FrameworkElement Render(SubmitAction action, RenderContext context)
 {
     if (context.Config.SupportsInteractivity)
     {
         Button uiButton = XamlUtilities.CreateActionButton(action, context); // content
         uiButton.Click += (sender, e) =>
         {
             try
             {
                 dynamic data = (action.Data != null) ? ((JToken)action.Data).DeepClone() : new JObject();
                 data = context.MergeInputData(data);
                 context.Action(uiButton, new ActionEventArgs()
                 {
                     Action = action, Data = data
                 });
             }
             catch (MissingInputException err)
             {
                 context.MissingInput(action, new MissingInputEventArgs(err.Input, err.FrameworkElement));
             }
         };
         return(uiButton);
     }
     return(null);
 }
コード例 #2
0
        public static FrameworkElement Render(TypedElement element, RenderContext context)
        {
            HttpAction action = (HttpAction)element;

            if (context.Config.SupportsInteractivity)
            {
                Button uiButton = XamlUtilities.CreateActionButton(action, context);
                uiButton.Click += (sender, e) =>
                {
                    dynamic data = new JObject();
                    try
                    {
                        data = context.MergeInputData(data);

                        string body = (string)action.Body?.ToString() ?? String.Empty;

                        context.Action(uiButton, new ActionEventArgs()
                        {
                            Action = new HttpAction()
                            {
                                Title   = action.Title,
                                Method  = action.Method,
                                Url     = RendererUtilities.BindData(data, action.Url, url: true),
                                Headers = action.Headers,
                                Body    = RendererUtilities.BindData(data, body),
                            },
                            Data = data
                        });
                    }
                    catch (MissingInputException err)
                    {
                        context.MissingInput(action, new MissingInputEventArgs(err.Input, err.FrameworkElement));
                    }
                };
                return(uiButton);
            }
            return(null);
        }