/
BaseObject.cs
52 lines (42 loc) · 1.44 KB
/
BaseObject.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
namespace DartSharp.Language
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class BaseObject : IObject
{
private IClass @class;
private Dictionary<string, object> values;
public BaseObject(IClass @class)
{
if (@class == null)
throw new ArgumentNullException("class");
this.@class = @class;
}
public IClass Class
{
get { return this.@class; }
}
public object GetValue(string name)
{
if (this.@class.GetVariableType(name) == null)
throw new InvalidOperationException(string.Format("Undefined Variable '{0}'", name));
if (this.values == null || !this.values.ContainsKey(name))
return null;
return this.values[name];
}
public void SetValue(string name, object value)
{
if (this.@class.GetVariableType(name) == null)
throw new InvalidOperationException(string.Format("Undefined Variable '{0}'", name));
if (this.values == null)
this.values = new Dictionary<string, object>();
this.values[name] = value;
}
public object Invoke(string name, object[] parameters)
{
throw new NotImplementedException();
}
}
}