2023-03-09 19:40:14 +00:00
|
|
|
namespace tlang
|
|
|
|
{
|
|
|
|
public class TDictionary : TObject
|
|
|
|
{
|
2023-03-09 23:57:16 +00:00
|
|
|
public override bool AsBoolean {get =>true;}
|
2023-03-09 19:40:14 +00:00
|
|
|
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); }
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|