private void addAdressButton(object sender, EventArgs e) { string country = textCountry.Text; string city = textCity.Text; string area = textArea.Text; string street = textStreet.Text; string house = textHouse.Text; string appartNumber = textAppartNumber.Text; Adress tmp = new Adress(country, city, area, street, house, appartNumber); if (!Adress.isAdress(tmp)) { if (textCity.Text == "" || textCountry.Text == "" || textHouse.Text == "" || textStreet.Text == "" || textAppartNumber.Text == "" || textArea.Text == "") { MessageBox.Show("Не все параметры указаны!"); } else { showNotReadyAdresses.Items.Add(tmp.ToString()); Adress.addAdress(tmp); } } else { MessageBox.Show("Такой адрес уже существует!"); } }
public static void DeserializedJsonFormat(string fileName) { DataContractJsonSerializer jsonFormatter = new DataContractJsonSerializer(typeof(List <Adress>)); List <Adress> adresses; using (FileStream fs = new FileStream(fileName, FileMode.Open)) { adresses = (List <Adress>)jsonFormatter.ReadObject(fs); } foreach (Adress adress in adresses) { Adress.addAdress(adress); } }