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