/// <summary> /// Deserialize method. /// </summary> public T Deserialize <T>(string path) { ISerialiser deserialize = (ISerialiser)Serialiser; var deserializeObj = deserialize.Deserialize <T>(path); if (CheckVersion) { Version version = (Version)deserializeObj.GetType().GetProperty("Version").GetValue(deserializeObj, null); if (!Version.Equals(version)) { throw new System.ArgumentException("Version do not equal"); } return(deserializeObj); } else { return(deserializeObj); } }
private void buttonDesirialized_Click(object sender, EventArgs e) { List <Utensil> deserilizeList = new List <Utensil>(); this.openFileDialogSr.Title = "Выберите файл"; if (openFileDialogSr.ShowDialog() != DialogResult.OK) { return; } if (openFileDialogSr.FileName != string.Empty) { deserilizeList = serialiser.Deserialize(openFileDialogSr.FileName, types); } foreach (Utensil ut in deserilizeList) { listBoxItems.Items.Add(ut.Name); mainList.Add(ut); } }