private void OnClosed(object sender, EventArgs e) { if (this.DataContext is AddInViewModel) { if (!Directory.Exists(GlobalHelper.AddInManagerPath)) { Directory.CreateDirectory(GlobalHelper.AddInManagerPath); } var vmodel = this.DataContext as AddInViewModel; if (vmodel.Models.Count == 0) { File.WriteAllText(Helper.GlobalHelper.AddInManagerAssemblyFile, ""); return; } try { var models = AddInAssemblyModel.Converter(vmodel.Models); AddInAssemblyModel.WriteModels(models); } catch (Exception ex) { } } }
private void OnLoaded(object sender, RoutedEventArgs e) { GlobalHelper.DeleteTemp(); if (this.DataContext is AddInViewModel vmodel) { if (!File.Exists(GlobalHelper.AddInManagerAssemblyFile)) { return; } var models = AddInAssemblyModel.ReadModels(); if (models == null || models.Count == 0) { return; } vmodel.Models = AddInAssemblyModel.Converter(models); } }