42 lines
930 B
C#
42 lines
930 B
C#
namespace tlang
|
|
{
|
|
public class TDictionary : TObject
|
|
{
|
|
public TDictionary()
|
|
{
|
|
|
|
}
|
|
|
|
Dictionary<string,TObject> items {get;set;}=new Dictionary<string, TObject>();
|
|
|
|
public TObject GetMember(string name)
|
|
{
|
|
if(items.ContainsKey(name))
|
|
{
|
|
return items[name];
|
|
}else{
|
|
return TObject.Uninit;
|
|
}
|
|
}
|
|
|
|
public void SetMember(string name, TObject obj)
|
|
{
|
|
if(items.ContainsKey(name))
|
|
{
|
|
items[name] = obj;
|
|
}
|
|
else
|
|
{
|
|
items.Add(name,obj);
|
|
}
|
|
}
|
|
|
|
public bool MemberExists(string name)
|
|
{
|
|
return items.ContainsKey(name);
|
|
}
|
|
public TObject this[string variable] { get => GetMember(variable); set => SetMember(variable,value); }
|
|
|
|
|
|
}
|
|
} |