Returns the referent as a List
Declaration Syntax
C# |
public override List AsList()
Return Value
The Referents AsList()
Examples
CopyC#
Sofu.Sofu.Map stuff = new Sofu.Sofu.Map(); stuff.SetAttribute("reflist",new Sofu.Sofu.Reference("listref",Sofu.Sofu.List())); stuff.SetAttribute("reallist",Sofu.Sofu.List()); stuff.list("listref").AppendElement(new Sofu.Sofu.Value(3)); //works as it was a List. stuff.list("reallist").AppendElement(new Sofu.Sofu.Value(4));//This one really is a List. foreach (KeyValuePair<string,Sofu.SofuObject> entry in stuff) { foreach (SofuObject val in entry.Value.AsList()) { //Works the same on the Reference and the "real" List Console.Out.WriteLine(val.ToString()); //Write 3 and 4 } }
Exceptions
Exception | Condition |
---|---|
SofuNoTargetException | Throws a SofuNoTargetException if the target does not exists or is not defined |
SofuNotListException | Throws a SofuNotListException if the target is not a List |