|
|
|
@ -19,8 +19,8 @@ namespace Debugger
@@ -19,8 +19,8 @@ namespace Debugger
|
|
|
|
|
|
|
|
|
|
bool readOnly = false; |
|
|
|
|
|
|
|
|
|
public event EventHandler<VariableEventArgs> VariableAdded; |
|
|
|
|
public event EventHandler<VariableEventArgs> VariableRemoved; |
|
|
|
|
public event EventHandler<ValueEventArgs> VariableAdded; |
|
|
|
|
public event EventHandler<ValueEventArgs> VariableRemoved; |
|
|
|
|
internal event EventHandler Updating; |
|
|
|
|
|
|
|
|
|
internal VariableCollection() |
|
|
|
@ -45,9 +45,9 @@ namespace Debugger
@@ -45,9 +45,9 @@ namespace Debugger
|
|
|
|
|
Empty.readOnly = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public bool Contains(Variable variable) |
|
|
|
|
public bool Contains(Value variable) |
|
|
|
|
{ |
|
|
|
|
foreach (Variable v in InnerList) { |
|
|
|
|
foreach (Value v in InnerList) { |
|
|
|
|
if (v == variable) { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
@ -57,7 +57,7 @@ namespace Debugger
@@ -57,7 +57,7 @@ namespace Debugger
|
|
|
|
|
|
|
|
|
|
public bool Contains(string variableName) |
|
|
|
|
{ |
|
|
|
|
foreach (Variable v in InnerList) { |
|
|
|
|
foreach (Value v in InnerList) { |
|
|
|
|
if (v.Name == variableName) { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
@ -65,25 +65,25 @@ namespace Debugger
@@ -65,25 +65,25 @@ namespace Debugger
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
internal void Add(Variable variable) |
|
|
|
|
internal void Add(Value variable) |
|
|
|
|
{ |
|
|
|
|
if (readOnly) { |
|
|
|
|
throw new DebuggerException("VariableCollection is marked as read only"); |
|
|
|
|
} |
|
|
|
|
if (variable != null) { |
|
|
|
|
InnerList.Add(variable); |
|
|
|
|
OnVariableAdded(new VariableEventArgs(variable)); |
|
|
|
|
OnVariableAdded(new ValueEventArgs(variable)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
internal void Remove(Variable variable) |
|
|
|
|
internal void Remove(Value variable) |
|
|
|
|
{ |
|
|
|
|
if (readOnly) { |
|
|
|
|
throw new DebuggerException("VariableCollection is marked as read only"); |
|
|
|
|
} |
|
|
|
|
if (variable != null) { |
|
|
|
|
InnerList.Remove(variable); |
|
|
|
|
OnVariableRemoved(new VariableEventArgs(variable)); |
|
|
|
|
OnVariableRemoved(new ValueEventArgs(variable)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -92,19 +92,19 @@ namespace Debugger
@@ -92,19 +92,19 @@ namespace Debugger
|
|
|
|
|
/// </summary>
|
|
|
|
|
internal void Clear() |
|
|
|
|
{ |
|
|
|
|
foreach(Variable variable in InnerList) { |
|
|
|
|
foreach(Value variable in InnerList) { |
|
|
|
|
Remove(variable); |
|
|
|
|
} |
|
|
|
|
Updating = null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Variable this[int index] { |
|
|
|
|
public Value this[int index] { |
|
|
|
|
get { |
|
|
|
|
return (Variable) InnerList[index]; |
|
|
|
|
return (Value) InnerList[index]; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Variable this[string variableName] { |
|
|
|
|
public Value this[string variableName] { |
|
|
|
|
get { |
|
|
|
|
int index = variableName.IndexOf('.'); |
|
|
|
|
if (index != -1) { |
|
|
|
@ -112,7 +112,7 @@ namespace Debugger
@@ -112,7 +112,7 @@ namespace Debugger
|
|
|
|
|
string subVariable = variableName.Substring(index + 1); |
|
|
|
|
return this[rootVariable].SubVariables[subVariable]; |
|
|
|
|
} else { |
|
|
|
|
foreach (Variable v in InnerList) { |
|
|
|
|
foreach (Value v in InnerList) { |
|
|
|
|
if (v.Name == variableName) { |
|
|
|
|
return v; |
|
|
|
|
} |
|
|
|
@ -139,7 +139,7 @@ namespace Debugger
@@ -139,7 +139,7 @@ namespace Debugger
|
|
|
|
|
mergedCollection.Update(); |
|
|
|
|
|
|
|
|
|
// Update existing variables
|
|
|
|
|
foreach(Variable variable in mergedCollection) { |
|
|
|
|
foreach(Value variable in mergedCollection) { |
|
|
|
|
if (this.Contains(variable.Name)) { |
|
|
|
|
this.Remove(this[variable.Name]); |
|
|
|
|
this.Add(variable); |
|
|
|
@ -147,28 +147,28 @@ namespace Debugger
@@ -147,28 +147,28 @@ namespace Debugger
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Add new variables
|
|
|
|
|
foreach(Variable variable in mergedCollection) { |
|
|
|
|
foreach(Value variable in mergedCollection) { |
|
|
|
|
if (!this.Contains(variable.Name)) { |
|
|
|
|
this.Add(variable); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Remove variables that are not in merged collection
|
|
|
|
|
foreach(Variable variable in this) { |
|
|
|
|
foreach(Value variable in this) { |
|
|
|
|
if (!mergedCollection.Contains(variable.Name)) { |
|
|
|
|
this.Remove(variable); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected virtual void OnVariableAdded(VariableEventArgs e) |
|
|
|
|
protected virtual void OnVariableAdded(ValueEventArgs e) |
|
|
|
|
{ |
|
|
|
|
if (VariableAdded != null) { |
|
|
|
|
VariableAdded(this, e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected virtual void OnVariableRemoved(VariableEventArgs e) |
|
|
|
|
protected virtual void OnVariableRemoved(ValueEventArgs e) |
|
|
|
|
{ |
|
|
|
|
if (VariableRemoved != null) { |
|
|
|
|
VariableRemoved(this, e); |
|
|
|
@ -184,7 +184,7 @@ namespace Debugger
@@ -184,7 +184,7 @@ namespace Debugger
|
|
|
|
|
|
|
|
|
|
public override string ToString() { |
|
|
|
|
string txt = ""; |
|
|
|
|
foreach(Variable v in this) { |
|
|
|
|
foreach(Value v in this) { |
|
|
|
|
txt += v.ToString() + "\n"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -202,14 +202,14 @@ namespace Debugger
@@ -202,14 +202,14 @@ namespace Debugger
|
|
|
|
|
{ |
|
|
|
|
// Add items of subcollections and ensure the stay in sync
|
|
|
|
|
foreach(VariableCollection collection in collections) { |
|
|
|
|
foreach(Variable variable in collection) { |
|
|
|
|
foreach(Value variable in collection) { |
|
|
|
|
this.Add(variable); |
|
|
|
|
} |
|
|
|
|
collection.VariableAdded += delegate(object sender, VariableEventArgs e) { |
|
|
|
|
this.Add(e.Variable); |
|
|
|
|
collection.VariableAdded += delegate(object sender, ValueEventArgs e) { |
|
|
|
|
this.Add(e.Value); |
|
|
|
|
}; |
|
|
|
|
collection.VariableRemoved += delegate(object sender, VariableEventArgs e) { |
|
|
|
|
this.Remove(e.Variable); |
|
|
|
|
collection.VariableRemoved += delegate(object sender, ValueEventArgs e) { |
|
|
|
|
this.Remove(e.Value); |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|