Feb 7, 2011 at 2:32 PM
Edited Feb 7, 2011 at 2:39 PM
You should be able to access the properties via the Properties
property accessor. Let's say you assigned a property named "Foo" with the value "Bar" at the map level, then you get the value of "Foo" as follows:
Map map = /* create or load map here... */
string fooProperty = map.Properties["Foo"];
// fooProperty should now contain "Bar"
The Properties property is defined in the abstract Component
class from which the other components (Map, Layet,
TileSet and Tile) are derived. Note also that the string accessor in Properties automatically casts to the four types:
bool, int, float and string, so you don't need to do any explicit casting.
To programmatically assign a value to an existing property, do the following:
layer.Properties["Foo"] = 42; // assign integer 42 to existing property Foo
If the object does not have the required property, it will be created automatically and assigned the given value:
layer.Properties["Foo2"] = true; // assign new property Foo2 with boolean value True