private void DataSettingsList_ListChanged(object sender, ListChangedEventArgs e) { if (e.ListChangedType == ListChangedType.ItemAdded || e.ListChangedType == ListChangedType.ItemDeleted || e.ListChangedType == ListChangedType.ItemChanged) { try { _dataIOService.SaveData(sender); } catch (Exception ex) { Logger.Error($"Cannot save settings. Message:{ex.Message}"); Close(); } } }
public void DataIOTest() { DataIOService dataIOService = new DataIOService(PATH); BindingList <ViewSettings> bindingListSave = new BindingList <ViewSettings>() { new ViewSettings() { EnableSSL = true, Host = "host", Port = 1, UserEmail = "email", Name = "name", UserPassword = "******", TimeStartSettings = "* * * * * *", MessageBody = "body", MessageSubject = "subject", RecieverEmail = "email", SenderEmail = "email", SenderName = "name", SiteUrl = "https://www.eurosport.ru/football/bundesliga/standing.shtml", TableClassID = "standing-table", ColumnToCompare = "\u0412", CompareValue = "10", NotNullColumn = "\u0418" } }; dataIOService.SaveData(bindingListSave); BindingList <ViewSettings> bindingListLoad = dataIOService.LoadData(); Comparer comparer = new Comparer(CultureInfo.CurrentCulture); var viewSettingsLoad = bindingListLoad.FirstOrDefault(); var viewSettingsSave = bindingListSave.FirstOrDefault(); Assert.AreEqual(comparer.Compare(viewSettingsLoad, viewSettingsSave), 0); }