~ubuntu-branches/ubuntu/oneiric/monodevelop/oneiric

« back to all changes in this revision

Viewing changes to src/core/Mono.Debugging/Mono.Debugging.Client/BreakpointStore.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2011-06-27 17:03:13 UTC
  • mto: (1.8.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 54.
  • Revision ID: james.westby@ubuntu.com-20110627170313-6cvz3s19x6e9hqe9
ImportĀ upstreamĀ versionĀ 2.5.92+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
//
27
27
 
28
28
using System;
 
29
using System.Linq;
29
30
using System.Xml;
30
31
using System.Collections;
31
32
using System.Collections.Generic;
46
47
                public bool IsReadOnly {
47
48
                        get {
48
49
                                ReadOnlyCheckEventArgs args = new ReadOnlyCheckEventArgs ();
49
 
                                if (CheckingReadOnly != null)
50
 
                                        CheckingReadOnly (this, args);
 
50
                                EventHandler<ReadOnlyCheckEventArgs> checkingReadOnly = CheckingReadOnly;
 
51
                                if (checkingReadOnly != null)
 
52
                                        checkingReadOnly (this, args);
51
53
                                return args.IsReadOnly;
52
54
                        }
53
55
                }
116
118
                                return false;
117
119
                }
118
120
                
119
 
                public bool Toggle (string filename, int line)
 
121
                public Breakpoint Toggle (string filename, int line)
120
122
                {
121
123
                        if (IsReadOnly)
122
 
                                return false;
 
124
                                return null;
123
125
                        
124
126
                        ReadOnlyCollection<Breakpoint> col = GetBreakpointsAtFileLine (filename, line);
125
127
                        if (col.Count > 0) {
126
128
                                foreach (Breakpoint bp in col)
127
129
                                        Remove (bp);
 
130
                                return null;
128
131
                        }
129
132
                        else {
130
 
                                Add (filename, line);
 
133
                                return Add (filename, line);
131
134
                        }
132
 
                        return true;
133
135
                }
134
136
                
135
137
                public ReadOnlyCollection<Breakpoint> GetBreakpoints ()
217
219
                        breakpoints.CopyTo (array, arrayIndex);
218
220
                }
219
221
                
 
222
                internal void AdjustBreakpointLine (Breakpoint bp, int newLine)
 
223
                {
 
224
                        Remove (bp);
 
225
                        bp.SetAdjustedLine (newLine);
 
226
                        Add (bp);
 
227
                }
 
228
                
 
229
                internal void ResetAdjustedBreakpoints ()
 
230
                {
 
231
                        foreach (Breakpoint bp in breakpoints.Where (b => b is Breakpoint).ToArray ()) {
 
232
                                if (bp.HasAdjustedLine) {
 
233
                                        Remove (bp);
 
234
                                        bp.ResetAdjustedLine ();
 
235
                                        Add (bp);
 
236
                                }
 
237
                        }
 
238
                }
 
239
                
220
240
                public XmlElement Save ()
221
241
                {
222
242
                        XmlDocument doc = new XmlDocument ();
239
259
                                if (ev != null)
240
260
                                        Add (ev);
241
261
                        }
242
 
                }
243
 
 
244
 
                public static bool FileNameEquals (string file1, string file2)
245
 
                {
246
 
                        if (System.IO.Path.DirectorySeparatorChar == '\\')
247
 
                                return string.Compare (file1, file2, true) == 0;
248
 
                        else
249
 
                                return file1 == file2;
 
262
                }
 
263
 
 
264
                public static bool FileNameEquals (string file1, string file2)
 
265
                {
 
266
                        if (System.IO.Path.DirectorySeparatorChar == '\\')
 
267
                                return string.Compare (file1, file2, true) == 0;
 
268
                        else
 
269
                                return file1 == file2;
250
270
                }
251
271
                
252
272
                internal bool EnableBreakEvent (BreakEvent be, bool enabled)
254
274
                        if (IsReadOnly)
255
275
                                return false;
256
276
                        OnChanged ();
257
 
                        if (BreakEventEnableStatusChanged != null)
258
 
                                BreakEventEnableStatusChanged (this, new BreakEventArgs (be));
 
277
                        EventHandler<BreakEventArgs> evnt = BreakEventEnableStatusChanged;
 
278
                        if (evnt != null)
 
279
                                evnt (this, new BreakEventArgs (be));
259
280
                        NotifyStatusChanged (be);
260
281
                        return true;
261
282
                }
263
284
                void OnBreakEventAdded (BreakEvent be)
264
285
                {
265
286
                        OnChanged ();
266
 
                        if (BreakEventAdded != null)
267
 
                                BreakEventAdded (this, new BreakEventArgs ((BreakEvent)be));
 
287
                        EventHandler<BreakEventArgs> breakEventAdded = BreakEventAdded;
 
288
                        if (breakEventAdded != null)
 
289
                                breakEventAdded (this, new BreakEventArgs ((BreakEvent)be));
268
290
                        if (be is Breakpoint) {
269
 
                                if (BreakpointAdded != null)
270
 
                                        BreakpointAdded (this, new BreakpointEventArgs ((Breakpoint)be));
 
291
                                EventHandler<BreakpointEventArgs> breakpointAdded = BreakpointAdded;
 
292
                                if (breakpointAdded != null)
 
293
                                        breakpointAdded (this, new BreakpointEventArgs ((Breakpoint)be));
271
294
                        } else if (be is Catchpoint) {
272
 
                                if (CatchpointAdded != null)
273
 
                                        CatchpointAdded (this, new CatchpointEventArgs ((Catchpoint)be));
 
295
                                EventHandler<CatchpointEventArgs> catchpointAdded = CatchpointAdded;
 
296
                                if (catchpointAdded != null)
 
297
                                        catchpointAdded (this, new CatchpointEventArgs ((Catchpoint)be));
274
298
                        }
275
299
                }
276
300
                
277
301
                void OnBreakEventRemoved (BreakEvent be)
278
302
                {
279
303
                        OnChanged ();
280
 
                        if (BreakEventRemoved != null)
281
 
                                BreakEventRemoved (this, new BreakEventArgs ((BreakEvent)be));
 
304
                        EventHandler<BreakEventArgs> breakEventRemoved = BreakEventRemoved;
 
305
                        if (breakEventRemoved != null)
 
306
                                breakEventRemoved (this, new BreakEventArgs ((BreakEvent)be));
282
307
                        if (be is Breakpoint) {
283
 
                                if (BreakpointRemoved != null)
284
 
                                        BreakpointRemoved (this, new BreakpointEventArgs ((Breakpoint)be));
 
308
                                EventHandler<BreakpointEventArgs> breakpointRemoved = BreakpointRemoved;
 
309
                                if (breakpointRemoved != null)
 
310
                                        breakpointRemoved (this, new BreakpointEventArgs ((Breakpoint)be));
285
311
                        } else if (be is Catchpoint) {
286
 
                                if (CatchpointRemoved != null)
287
 
                                        CatchpointRemoved (this, new CatchpointEventArgs ((Catchpoint)be));
 
312
                                EventHandler<CatchpointEventArgs> catchpointRemoved = CatchpointRemoved;
 
313
                                if (catchpointRemoved != null)
 
314
                                        catchpointRemoved (this, new CatchpointEventArgs ((Catchpoint)be));
288
315
                        }
289
316
                }
290
317
                
291
318
                void OnChanged ()
292
319
                {
293
 
                        if (Changed != null)
294
 
                                Changed (this, EventArgs.Empty);
 
320
                        EventHandler changed = Changed;
 
321
                        if (changed != null)
 
322
                                changed (this, EventArgs.Empty);
295
323
                }
296
324
                
297
325
                internal void NotifyStatusChanged (BreakEvent be)
298
326
                {
299
327
                        try {
300
 
                                if (BreakEventStatusChanged != null)
301
 
                                        BreakEventStatusChanged (this, new BreakEventArgs ((BreakEvent)be));
 
328
                                EventHandler<BreakEventArgs> breakEventStatusChanged = BreakEventStatusChanged;
 
329
                                if (breakEventStatusChanged != null)
 
330
                                        breakEventStatusChanged (this, new BreakEventArgs ((BreakEvent)be));
302
331
                                if (be is Breakpoint) {
303
 
                                        if (BreakpointStatusChanged != null)
304
 
                                                BreakpointStatusChanged (this, new BreakpointEventArgs ((Breakpoint)be));
 
332
                                        EventHandler<BreakpointEventArgs> breakpointStatusChanged = BreakpointStatusChanged;
 
333
                                        if (breakpointStatusChanged != null)
 
334
                                                breakpointStatusChanged (this, new BreakpointEventArgs ((Breakpoint)be));
305
335
                                } else if (be is Catchpoint) {
306
 
                                        if (CatchpointStatusChanged != null)
307
 
                                                CatchpointStatusChanged (this, new CatchpointEventArgs ((Catchpoint)be));
 
336
                                        EventHandler<CatchpointEventArgs > catchpointStatusChanged = CatchpointStatusChanged;
 
337
                                        if (catchpointStatusChanged != null)
 
338
                                                catchpointStatusChanged (this, new CatchpointEventArgs ((Catchpoint)be));
308
339
                                }
309
340
                        } catch {
310
 
                                // Ignone
 
341
                                // Ignore
311
342
                        }
312
343
                }
313
344
                
314
345
                internal void NotifyBreakEventChanged (BreakEvent be)
315
346
                {
316
347
                        try {
317
 
                                if (BreakEventModified != null)
318
 
                                        BreakEventModified (this, new BreakEventArgs ((BreakEvent)be));
 
348
                                EventHandler<BreakEventArgs > breakEventModified = BreakEventModified;
 
349
                                if (breakEventModified != null)
 
350
                                        breakEventModified (this, new BreakEventArgs ((BreakEvent)be));
319
351
                                if (be is Breakpoint) {
320
 
                                        if (BreakpointModified != null)
321
 
                                                BreakpointModified (this, new BreakpointEventArgs ((Breakpoint)be));
 
352
                                        EventHandler<BreakpointEventArgs > breakpointModified = BreakpointModified;
 
353
                                        if (breakpointModified != null)
 
354
                                                breakpointModified (this, new BreakpointEventArgs ((Breakpoint)be));
322
355
                                } else if (be is Catchpoint) {
323
 
                                        if (CatchpointModified != null)
324
 
                                                CatchpointModified (this, new CatchpointEventArgs ((Catchpoint)be));
 
356
                                        EventHandler<CatchpointEventArgs >  catchpointModified = CatchpointModified;
 
357
                                        if (catchpointModified != null)
 
358
                                                catchpointModified (this, new CatchpointEventArgs ((Catchpoint)be));
325
359
                                }
326
360
                                OnChanged ();
327
361
                        } catch {
328
 
                                // Ignone
 
362
                                // Ignore
329
363
                        }
330
364
                }
331
365
                
332
366
                internal void NotifyBreakEventUpdated (BreakEvent be)
333
367
                {
334
368
                        try {
335
 
                                if (BreakEventUpdated != null)
336
 
                                        BreakEventUpdated (this, new BreakEventArgs ((BreakEvent)be));
 
369
                                EventHandler<BreakEventArgs> breakEventUpdated = BreakEventUpdated;
 
370
                                if (breakEventUpdated != null)
 
371
                                        breakEventUpdated (this, new BreakEventArgs ((BreakEvent)be));
337
372
                                if (be is Breakpoint) {
338
 
                                        if (BreakpointUpdated != null)
339
 
                                                BreakpointUpdated (this, new BreakpointEventArgs ((Breakpoint)be));
 
373
                                        EventHandler<BreakpointEventArgs> breakpointUpdated = BreakpointUpdated;
 
374
                                        if (breakpointUpdated != null)
 
375
                                                breakpointUpdated (this, new BreakpointEventArgs ((Breakpoint)be));
340
376
                                } else if (be is Catchpoint) {
341
 
                                        if (CatchpointUpdated != null)
342
 
                                                CatchpointUpdated (this, new CatchpointEventArgs ((Catchpoint)be));
 
377
                                        EventHandler<CatchpointEventArgs>  catchpointUpdated = CatchpointUpdated;
 
378
                                        if (catchpointUpdated != null)
 
379
                                                catchpointUpdated (this, new CatchpointEventArgs ((Catchpoint)be));
343
380
                                }
344
381
                        } catch {
345
 
                                // Ignone
 
382
                                // Ignore
346
383
                        }
347
384
                }
348
385