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

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2009-02-18 08:40:51 UTC
  • mfrom: (1.2.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090218084051-gh8m6ukvokbwj7cf
Tags: 1.9.2+dfsg-1ubuntu1
* Merge from Debian Experimental (LP: #330519), remaining Ubuntu changes:
  + debian/control:
    - Update for Gnome# 2.24
    - Add libmono-cairo1.0-cil to build-deps to fool pkg-config check

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// BreakEvent.cs
 
2
//
 
3
// Author:
 
4
//   Lluis Sanchez Gual <lluis@novell.com>
 
5
//
 
6
// Copyright (c) 2008 Novell, Inc (http://www.novell.com)
 
7
//
 
8
// Permission is hereby granted, free of charge, to any person obtaining a copy
 
9
// of this software and associated documentation files (the "Software"), to deal
 
10
// in the Software without restriction, including without limitation the rights
 
11
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 
12
// copies of the Software, and to permit persons to whom the Software is
 
13
// furnished to do so, subject to the following conditions:
 
14
//
 
15
// The above copyright notice and this permission notice shall be included in
 
16
// all copies or substantial portions of the Software.
 
17
//
 
18
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
19
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
20
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 
21
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
22
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 
23
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 
24
// THE SOFTWARE.
 
25
//
 
26
//
 
27
 
 
28
using System;
 
29
using System.Xml;
 
30
 
 
31
namespace Mono.Debugging.Client
 
32
{
 
33
        [Serializable]
 
34
        public class BreakEvent
 
35
        {
 
36
                [NonSerialized] BreakpointStore store;
 
37
                [NonSerialized] bool enabled = true;
 
38
                
 
39
                HitAction hitAction = HitAction.Break;
 
40
                string customActionId;
 
41
                string traceExpression;
 
42
                int hitCount;
 
43
                string lastTraceValue;
 
44
                
 
45
                public BreakEvent()
 
46
                {
 
47
                }
 
48
                
 
49
                internal BreakEvent (XmlElement elem)
 
50
                {
 
51
                        string s = elem.GetAttribute ("enabled");
 
52
                        if (s.Length > 0)
 
53
                                enabled = bool.Parse (s);
 
54
                        s = elem.GetAttribute ("hitAction");
 
55
                        if (s.Length > 0)
 
56
                                hitAction = (HitAction) Enum.Parse (typeof(HitAction), s);
 
57
                        s = elem.GetAttribute ("customActionId");
 
58
                        if (s.Length > 0)
 
59
                                customActionId = s;
 
60
                        s = elem.GetAttribute ("traceExpression");
 
61
                        if (s.Length > 0)
 
62
                                traceExpression = s;
 
63
                        s = elem.GetAttribute ("hitCount");
 
64
                        if (s.Length > 0)
 
65
                                hitCount = int.Parse (s);
 
66
                }
 
67
                
 
68
                internal virtual XmlElement ToXml (XmlDocument doc)
 
69
                {
 
70
                        XmlElement elem = doc.CreateElement (GetType().Name);
 
71
                        if (!enabled)
 
72
                                elem.SetAttribute ("enabled", "false");
 
73
                        if (hitAction != HitAction.Break)
 
74
                                elem.SetAttribute ("hitAction", hitAction.ToString ());
 
75
                        if (!string.IsNullOrEmpty (customActionId))
 
76
                                elem.SetAttribute ("customActionId", customActionId);
 
77
                        if (!string.IsNullOrEmpty (traceExpression))
 
78
                                elem.SetAttribute ("traceExpression", traceExpression);
 
79
                        if (hitCount > 0)
 
80
                                elem.SetAttribute ("hitCount", hitCount.ToString ());
 
81
                        return elem;
 
82
                }
 
83
                
 
84
                internal static BreakEvent FromXml (XmlElement elem)
 
85
                {
 
86
                        if (elem.Name == "Breakpoint")
 
87
                                return new Breakpoint (elem);
 
88
                        else if (elem.Name == "Catchpoint")
 
89
                                return new Catchpoint (elem);
 
90
                        else
 
91
                                return null;
 
92
                }
 
93
                
 
94
                public bool Enabled {
 
95
                        get {
 
96
                                if (store == null)
 
97
                                        throw new InvalidOperationException ();
 
98
                                return enabled;
 
99
                        }
 
100
                        set {
 
101
                                if (store == null)
 
102
                                        throw new InvalidOperationException ();
 
103
                                enabled = value;
 
104
                                store.EnableBreakEvent (this, value);
 
105
                        }
 
106
                }
 
107
                
 
108
                public bool IsValid (DebuggerSession session)
 
109
                {
 
110
                        if (store == null)
 
111
                                throw new InvalidOperationException ();
 
112
                        if (session == null)
 
113
                                return true;
 
114
                        return session.IsBreakEventValid (this);
 
115
                }
 
116
 
 
117
                public string TraceExpression {
 
118
                        get {
 
119
                                return traceExpression;
 
120
                        }
 
121
                        set {
 
122
                                traceExpression = value;
 
123
                        }
 
124
                }
 
125
 
 
126
                public HitAction HitAction {
 
127
                        get {
 
128
                                return hitAction;
 
129
                        }
 
130
                        set {
 
131
                                hitAction = value;
 
132
                        }
 
133
                }
 
134
 
 
135
                public string CustomActionId {
 
136
                        get {
 
137
                                return customActionId;
 
138
                        }
 
139
                        set {
 
140
                                customActionId = value;
 
141
                        }
 
142
                }
 
143
 
 
144
                internal BreakpointStore Store {
 
145
                        get {
 
146
                                return store;
 
147
                        }
 
148
                        set {
 
149
                                store = value;
 
150
                        }
 
151
                }
 
152
 
 
153
                public int HitCount {
 
154
                        get {
 
155
                                return hitCount;
 
156
                        }
 
157
                        set {
 
158
                                hitCount = value;
 
159
                        }
 
160
                }
 
161
 
 
162
                public string LastTraceValue {
 
163
                        get {
 
164
                                return lastTraceValue;
 
165
                        }
 
166
                        internal set {
 
167
                                lastTraceValue = value;
 
168
                        }
 
169
                }
 
170
                
 
171
                public void CommitChanges ()
 
172
                {
 
173
                        if (store != null)
 
174
                                store.NotifyBreakEventChanged (this);
 
175
                }
 
176
                
 
177
                internal void NotifyUpdate ()
 
178
                {
 
179
                        if (store != null)
 
180
                                store.NotifyBreakEventUpdated (this);
 
181
                }
 
182
                
 
183
                public BreakEvent Clone ()
 
184
                {
 
185
                        return (BreakEvent) MemberwiseClone ();
 
186
                }
 
187
                
 
188
                public virtual void CopyFrom (BreakEvent ev)
 
189
                {
 
190
                        hitAction = ev.hitAction;
 
191
                        customActionId = ev.customActionId;
 
192
                        traceExpression = ev.traceExpression;
 
193
                        hitCount = ev.hitCount;
 
194
                }
 
195
        }
 
196
}