private void BtnSave_Click(object sender, EventArgs e) { var output = new ClClassData(TBInstanceName.Text, InputClass.ClassName, new List <ClFieldData>(), new List <ClEnumerableFieldData>()); bool error = false; foreach (Control c in FLPMain.Controls) { if (c is FieldUIs.UCPrimitiveUI) { if ((c as FieldUIs.UCPrimitiveUI).Error == true) { error = true; } } else if (c is FieldUIs.UCEnumerableUI) { if ((c as FieldUIs.UCEnumerableUI).Error == true) { error = true; } } } if (!error) // if there are no errors { foreach (Control c in FLPMain.Controls) { if (c is FieldUIs.UCPrimitiveUI) { output.FieldDatas.Add((c as FieldUIs.UCPrimitiveUI).OutputData()); } else if (c is FieldUIs.UCEnumerableUI) { output.EnumerableFieldDatas.Add((c as FieldUIs.UCEnumerableUI).OutputData()); } } //Now output is ready to be serialized var sfd = new SaveFileDialog(); sfd.Filter = "XML file as txt (*.txt)|*.txt|XML file as xml (*.xml)|*.xml"; if (sfd.ShowDialog() == DialogResult.OK) { MdCore.Serialize <ClClassData>(output, sfd.FileName); } } else { MessageBox.Show("Error: there are syntax errors in the instance editor."); } }
public ClClassData OutputInstance() { var output = new ClClassData(TBName.Text, InputClass.ClassName, new List <ClFieldData>(), new List <ClEnumerableFieldData>()); bool error = false; foreach (Control c in FLPMain.Controls) { if (c is FieldUIs.UCPrimitiveUI) { if ((c as FieldUIs.UCPrimitiveUI).Error == true) { error = true; } } else if (c is FieldUIs.UCEnumerableUI) { if ((c as FieldUIs.UCEnumerableUI).Error == true) { error = true; } } } if (!error) // if there are no errors { foreach (Control c in FLPMain.Controls) { if (c is FieldUIs.UCPrimitiveUI) { output.FieldDatas.Add((c as FieldUIs.UCPrimitiveUI).OutputData()); } else if (c is FieldUIs.UCEnumerableUI) { output.EnumerableFieldDatas.Add((c as FieldUIs.UCEnumerableUI).OutputData()); } } return(output); } else { MessageBox.Show("Error: there are syntax errors in the instance editor for " + TBName.Text); return(null); } }