Exemple #1
0
        private void btnToClass_Click(object sender, EventArgs e)
        {
            string jsonStr = txtJson.Text.Trim();

            if (string.IsNullOrWhiteSpace(jsonStr))
            {
                MessageBox.Show("Json String文本框内容不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            string className = FrmInputBox.Show("请输入要生成的Class Name", "请输入要生成的Class Name(Class Name应符合Csharp的编码命名规范)", false, this);

            if (string.IsNullOrWhiteSpace(className))
            {
                className = "Root";
            }

            try
            {
                var JObj = JObject.Parse(jsonStr);
                txtCode.Text = ToClassCode(JObj, className);
            }
            catch (Exception ex)
            {
                MessageBox.Show("转换出错,原因:" + ex.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #2
0
 public static string Show(string title, string tip, bool passwordMask = false, Form ownerForm = null)
 {
     using (var inputBox = new FrmInputBox(title, tip, passwordMask))
     {
         if (inputBox.ShowDialog(ownerForm) == DialogResult.OK)
         {
             return(inputBox.InputValue);
         }
         else
         {
             return(string.Empty);
         }
     }
 }