public override void EditConditions() { if (SelectedItems.Count == 0) { return; } var dlg = new EditExceptionConditionsDlg(); var vm = new EditExceptionConditionsVM(SortedSelectedItems.First().Settings.Conditions); dlg.DataContext = vm; dlg.Owner = appWindow.MainWindow; var res = dlg.ShowDialog(); if (res != true) { return; } var newConditions = vm.GetConditions(); var newSettings = new DbgExceptionIdAndSettings[SelectedItems.Count]; for (int i = 0; i < newSettings.Length; i++) { var item = SelectedItems[i]; var flags = item.Settings.Flags | DbgExceptionDefinitionFlags.StopFirstChance; var settings = new DbgExceptionSettings(flags, newConditions); newSettings[i] = new DbgExceptionIdAndSettings(item.Definition.Id, settings); } dbgExceptionSettingsService.Value.Modify(newSettings); }
bool ReadSettings(ISettingsSection section, out DbgExceptionSettings settings) { settings = default; var flags = section.Attribute <DbgExceptionDefinitionFlags?>("Flags"); if (flags == null) { return(false); } ReadOnlyCollection <DbgExceptionConditionSettings> condSettings; var condSects = section.SectionsWithName("Conditions"); if (condSects.Length == 0) { condSettings = null; } else { var conds = new DbgExceptionConditionSettings[condSects.Length]; for (int i = 0; i < condSects.Length; i++) { var condSect = condSects[i]; var condType = condSect.Attribute <DbgExceptionConditionType?>("Type"); var cond = condSect.Attribute <string>("Condition"); if (condType == null || string.IsNullOrWhiteSpace(cond) || !IsValid(condType.Value)) { return(false); } conds[i] = new DbgExceptionConditionSettings(condType.Value, cond); } condSettings = new ReadOnlyCollection <DbgExceptionConditionSettings>(conds); } settings = new DbgExceptionSettings(flags.Value, condSettings); return(true); }
static bool Compare(DbgExceptionSettings settings, DbgExceptionDefinition def) { if (settings.Conditions.Count != 0) { return(false); } return(settings.Flags == def.Flags); }
static void AddSettings(ISettingsSection section, DbgExceptionSettings settings) { section.Attribute("Flags", settings.Flags); foreach (var cond in settings.Conditions) { var condSect = section.CreateSection("Conditions"); condSect.Attribute("Type", cond.ConditionType); condSect.Attribute("Condition", cond.Condition); } }
/// <summary> /// Constructor /// </summary> /// <param name="id">Exception id</param> /// <param name="settings">Settings</param> public DbgExceptionIdAndSettings(DbgExceptionId id, DbgExceptionSettings settings) { if (id.Category is null) { throw new ArgumentException(); } if (settings.Conditions is null) { throw new ArgumentException(); } Id = id; Settings = settings; }
/// <summary> /// Constructor /// </summary> /// <param name="definition">Exception definition</param> /// <param name="settings">Exception settings</param> public DbgExceptionSettingsInfo(DbgExceptionDefinition definition, DbgExceptionSettings settings) { if (definition.Id.Category is null) { throw new ArgumentException(); } if (settings.Conditions is null) { throw new ArgumentException(); } Definition = definition; Settings = settings; }
public override bool TryGetSettings(DbgExceptionId id, out DbgExceptionSettings settings) { if (id.Category is null) { throw new ArgumentException(); } lock (lockObj) { if (toExceptionInfo.TryGetValue(id, out var info)) { settings = info.Settings; return(true); } } settings = default; return(false); }
public override void Execute(string context) { if (context == null) { return; } var id = new DbgExceptionId(PredefinedExceptionCategories.DotNet, context); if (dbgExceptionSettingsService.Value.TryGetSettings(id, out var settings)) { settings = new DbgExceptionSettings(settings.Flags | DbgExceptionDefinitionFlags.StopFirstChance, settings.Conditions); dbgExceptionSettingsService.Value.Modify(id, settings); } else { var def = new DbgExceptionDefinition(id, DbgExceptionDefinitionFlags.StopFirstChance | DbgExceptionDefinitionFlags.StopSecondChance); settings = new DbgExceptionSettings(def.Flags); var info = new DbgExceptionSettingsInfo(def, settings); dbgExceptionSettingsService.Value.Add(info); } }
void ToggleBreakWhenThrown(IList <ExceptionVM> exceptions) { bool allSet = exceptions.All(a => a.BreakWhenThrown); var newSettings = new DbgExceptionIdAndSettings[exceptions.Count]; for (int i = 0; i < newSettings.Length; i++) { var vm = exceptions[i]; var flags = vm.Settings.Flags; if (allSet) { flags &= ~DbgExceptionDefinitionFlags.StopFirstChance; } else { flags |= DbgExceptionDefinitionFlags.StopFirstChance; } var settings = new DbgExceptionSettings(flags, vm.Settings.Conditions); newSettings[i] = new DbgExceptionIdAndSettings(vm.Definition.Id, settings); } dbgExceptionSettingsService.Value.Modify(newSettings); }
public override void ToggleBreakWhenThrown() { // Toggling everything seems to be less useful, it's more likely that you'd want // to enable all selected exceptions or disable all of them. bool allSet = SelectedItems.All(a => a.BreakWhenThrown); var newSettings = new DbgExceptionIdAndSettings[SelectedItems.Count]; for (int i = 0; i < newSettings.Length; i++) { var vm = SelectedItems[i]; var flags = vm.Settings.Flags; if (allSet) { flags &= ~DbgExceptionDefinitionFlags.StopFirstChance; } else { flags |= DbgExceptionDefinitionFlags.StopFirstChance; } var settings = new DbgExceptionSettings(flags, vm.Settings.Conditions); newSettings[i] = new DbgExceptionIdAndSettings(vm.Definition.Id, settings); } dbgExceptionSettingsService.Value.Modify(newSettings); }
public ExceptionInfo(DbgExceptionDefinition definition, DbgExceptionSettings settings) { Definition = definition; Settings = settings; }