Last change
on this file since 13759 was
11819,
checked in by jkarder, 10 years ago
|
#2077:
- added temporary fix to avoid crash trough code completion
- fixed updating of compilation succeeded/failed messages
- added Keys and Values properties to the Variables class (again)
|
File size:
1.4 KB
|
Line | |
---|
1 | using System.Collections;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Dynamic;
|
---|
4 |
|
---|
5 | namespace HeuristicLab.Scripting {
|
---|
6 | public class Variables : DynamicObject, IEnumerable<KeyValuePair<string, object>> {
|
---|
7 | private readonly VariableStore variableStore;
|
---|
8 |
|
---|
9 | public IEnumerable<string> Keys {
|
---|
10 | get { return variableStore.Keys; }
|
---|
11 | }
|
---|
12 |
|
---|
13 | public IEnumerable<object> Values {
|
---|
14 | get { return variableStore.Values; }
|
---|
15 | }
|
---|
16 |
|
---|
17 | public Variables(VariableStore variableStore) {
|
---|
18 | this.variableStore = variableStore;
|
---|
19 | }
|
---|
20 |
|
---|
21 | public override bool TryGetMember(GetMemberBinder binder, out object result) {
|
---|
22 | return variableStore.TryGetValue(binder.Name, out result);
|
---|
23 | }
|
---|
24 |
|
---|
25 | public override bool TrySetMember(SetMemberBinder binder, object value) {
|
---|
26 | variableStore[binder.Name] = value;
|
---|
27 | return true;
|
---|
28 | }
|
---|
29 |
|
---|
30 | public object this[string key] {
|
---|
31 | get { return variableStore[key]; }
|
---|
32 | set { variableStore[key] = value; }
|
---|
33 | }
|
---|
34 |
|
---|
35 | public bool Contains(string variableName) {
|
---|
36 | return variableStore.ContainsKey(variableName);
|
---|
37 | }
|
---|
38 |
|
---|
39 | public void Clear() {
|
---|
40 | variableStore.Clear();
|
---|
41 | }
|
---|
42 |
|
---|
43 | public IEnumerator<KeyValuePair<string, object>> GetEnumerator() {
|
---|
44 | return variableStore.GetEnumerator();
|
---|
45 | }
|
---|
46 |
|
---|
47 | IEnumerator IEnumerable.GetEnumerator() {
|
---|
48 | return GetEnumerator();
|
---|
49 | }
|
---|
50 | }
|
---|
51 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.