Exemple #1
0
        /// <summary>
        /// Validate.
        /// </summary>
        void ConfirmButton_Clicked(object sender, EventArgs e)
        {
            // Type
            ContentType type = (ContentType)ContentTypeSelect.SelectedItem;

            // Data
            String error = null;

            // Parse
            if (type == ContentType.JSON)
            {
                List <ParserError> errors = new List <ParserError>();
                Parser.deserialize(TextInput.Text, errors, "json");
                if (errors.Count > 0)
                {
                    error = ParserResult.CreateMarkdownReport(errors);
                }
            }
            else if (type == ContentType.XML)
            {
                try {
                    using (XmlReader reader = XmlReader.Create(new StringReader(TextInput.Text)))
                    {
                        // OK
                    }
                } catch (Exception er) {
                    error = er.Message;
                }
            }

            if (error != null)
            {
                ErrorReport.Markdown = error;
                return;
            }

            if (ReqWidget != null)
            {
                ReqWidget.SetRequest(TextInput.Text, type);
            }
            else
            {
                ResWidget.SetResponse(TextInput.Text, type);
            }

            Close();
        }