Пример #1
0
 private void btnSerialize_Click(object sender, EventArgs e)
 {
     lblSerializeInfo.Text = "Serializing...";
     try {
         String[] quality = { "organic", "free range", "pesticide-free" };
         Fruit    fruit   = new Fruit(txtName.Text,
                                      Convert.ToInt32(txtWeight.Text),
                                      Convert.ToDateTime(txtDateTimePicked.Text),
                                      Fruit.enumCondition.ripe,
                                      quality);
         JSONSerializeTools.Serialize(fruit, txtFileName.Text);
         lblSerializeInfo.Text = "Done";
     } catch (Exception ex) {
         lblSerializeInfo.Text = ex.Message;
     }
 }
Пример #2
0
        private void btnDeserialize_Click(object sender, EventArgs e)
        {
            Fruit fruit = (Fruit)JSONSerializeTools.Deserialize <Fruit>(txtDeserializeFileName.Text);

            lblDeserializeInfo.Text = fruit.ToString();
        }