tlang-interperter-cs/TDictionary.cs

43 lines
983 B
C#

namespace tlang
{
public class TDictionary : TObject
{
public override bool AsBoolean {get =>true;}
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); }
}
}