Last change
on this file since 11083 was
10892,
checked in by abeham, 11 years ago
|
#2136: merged r10510, r10511, r10512, r10566, r10577, r10642, r10727, r10731, r10747, r10761, r10857, r10865 to stable
|
File size:
1.1 KB
|
Rev | Line | |
---|
[10566] | 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 Variables(VariableStore variableStore) {
|
---|
| 10 | this.variableStore = variableStore;
|
---|
| 11 | }
|
---|
| 12 |
|
---|
| 13 | public override bool TryGetMember(GetMemberBinder binder, out object result) {
|
---|
| 14 | return variableStore.TryGetValue(binder.Name, out result);
|
---|
| 15 | }
|
---|
| 16 |
|
---|
| 17 | public override bool TrySetMember(SetMemberBinder binder, object value) {
|
---|
| 18 | variableStore[binder.Name] = value;
|
---|
| 19 | return true;
|
---|
| 20 | }
|
---|
| 21 |
|
---|
| 22 | public bool Contains(string variableName) {
|
---|
| 23 | return variableStore.ContainsKey(variableName);
|
---|
| 24 | }
|
---|
| 25 |
|
---|
[10892] | 26 | public void Clear() {
|
---|
| 27 | variableStore.Clear();
|
---|
| 28 | }
|
---|
| 29 |
|
---|
[10566] | 30 | public IEnumerator<KeyValuePair<string, object>> GetEnumerator() {
|
---|
| 31 | return variableStore.GetEnumerator();
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | IEnumerator IEnumerable.GetEnumerator() {
|
---|
| 35 | return GetEnumerator();
|
---|
| 36 | }
|
---|
| 37 | }
|
---|
| 38 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.