Free cookie consent management tool by TermsFeed Policy Generator

source: stable/HeuristicLab.Scripting/3.3/Variables.cs @ 17014

Last change on this file since 17014 was 11937, checked in by jkarder, 10 years ago

#2077: merged r11807:11811, r11816, r11819, r11822, r11825, r11834, r11835, r11836, r11933 and r11936 into stable

File size: 1.4 KB
RevLine 
[10566]1using System.Collections;
2using System.Collections.Generic;
3using System.Dynamic;
4
5namespace HeuristicLab.Scripting {
6  public class Variables : DynamicObject, IEnumerable<KeyValuePair<string, object>> {
7    private readonly VariableStore variableStore;
8
[11937]9    public IEnumerable<string> Keys {
10      get { return variableStore.Keys; }
11    }
12
13    public IEnumerable<object> Values {
14      get { return variableStore.Values; }
15    }
16
[10566]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
[11154]30    public object this[string key] {
31      get { return variableStore[key]; }
32      set { variableStore[key] = value; }
33    }
34
[10566]35    public bool Contains(string variableName) {
36      return variableStore.ContainsKey(variableName);
37    }
38
[10892]39    public void Clear() {
40      variableStore.Clear();
41    }
42
[10566]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.