Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 static bool Compare(DbgExceptionSettings settings, DbgExceptionDefinition def)
 {
     if (settings.Conditions.Count != 0)
     {
         return(false);
     }
     return(settings.Flags == def.Flags);
 }
Ejemplo n.º 4
0
 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);
     }
 }
Ejemplo n.º 5
0
 /// <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;
 }
Ejemplo n.º 6
0
 /// <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;
 }
Ejemplo n.º 7
0
 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);
 }
Ejemplo n.º 8
0
            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);
                }
            }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
        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);
        }
Ejemplo n.º 11
0
 public ExceptionInfo(DbgExceptionDefinition definition, DbgExceptionSettings settings)
 {
     Definition = definition;
     Settings   = settings;
 }