public bool InsertBreakpoint(string filePath, int column, int line) { solutionModified = true; // Changes should be persisted. showSaveSolutionDialog = true; // Attempt to remove a breakpoint if there's one. if (RemoveBreakpoint(filePath, column, line)) { return(true); } BreakpointItem breakpoint = new BreakpointItem(); breakpoint.AbsolutePath = filePath; breakpoint.Line = line; breakpoint.Column = column; breakpoint.RelativePath = string.Empty; solutionData.Breakpoints.Add(breakpoint); return(ToggleBreakpoint(breakpoint)); }
private bool ToggleBreakpoint(BreakpointItem breakpoint) { bool isInDebugMode = false; if (IsExecutionActive(ref isInDebugMode) == false) { return(true); } if (IsExecutionInProgress() != false) { return(false); // Can't set breakpoint now! } CodePoint codePoint = new CodePoint(); codePoint.CharNo = breakpoint.Column; codePoint.LineNo = breakpoint.Line; CodeFile script = new CodeFile(); script.FilePath = breakpoint.AbsolutePath; codePoint.SourceLocation = script; return(executionSession.SetBreakpointAt(codePoint)); }
internal bool RemoveBreakpoint(string filePath, int column, int line) { solutionModified = true; // Changes should be persisted. showSaveSolutionDialog = true; int currDifference = int.MaxValue; BreakpointItem toBeRemoved = null; List <BreakpointItem> breakpoints = solutionData.Breakpoints; foreach (BreakpointItem breakpoint in breakpoints) { // Integer comparison is faster (than string). if (line == breakpoint.Line) { // If line matches then only we check on the file path. if (string.Compare(breakpoint.AbsolutePath, filePath, true) == 0) { int difference = Math.Abs(breakpoint.Column - column); if (difference < currDifference) { currDifference = difference; toBeRemoved = breakpoint; } } } } if (null != toBeRemoved) { breakpoints.Remove(toBeRemoved); ToggleBreakpoint(toBeRemoved); return(true); // A breakpoint was removed. } return(false); }