Additional GoLayer information

If I got 5 layers in a document, how can I save additional information about this layers, like a custom color I use for objects placed on the layers and the position if i read the layers information.

For Each o As GoLayer In myGV.Document.Layers wr.WriteStartElement("LayerName") wr.WriteAttributeString("Identifier", o.Identifier) wr.WriteAttributeString("AllowCopy", o.AllowCopy) wr.WriteAttributeString("AllowDelete", o.AllowDelete) wr.WriteAttributeString("AllowEdit", o.AllowEdit) wr.WriteAttributeString("AllowInsert", o.AllowInsert) wr.WriteAttributeString("AllowLink", o.AllowLink) wr.WriteAttributeString("AllowMove", o.AllowMove) wr.WriteAttributeString("AllowPrint", o.AllowPrint) wr.WriteAttributeString("AllowReshape", o.AllowReshape) wr.WriteAttributeString("AllowResize", o.AllowResize) wr.WriteAttributeString("AllowSelect", o.AllowSelect) wr.WriteAttributeString("AllowView", o.AllowView)
wr.WriteAttributeString("LayerColor", o.LayerColor)
wr.WriteAttributeString("LayerPostition", o.LayerPostition)

That looks right. You have to write the corresponding “Consume” code.

I am not sure If I express myself corrent, these properties does not exist in Golayer:

wr.WriteAttributeString("LayerColor", o.LayerColor)
wr.WriteAttributeString("LayerPostition", o.LayerPostition)
i cannot inherit Golayer, how can I get these properties as part of golayer to save it?

You’ll need to store those properties in your own objects that you associate with each GoLayer as part of your GoDocument.

Also, XmlWriter.WriteAttributeString only takes String values, so I don’t think the code you suggest would compile. You need to convert the values into strings. Remember to consider the current culture (or not!) when you do so.

I suggest that you use GoXml instead of System.Xml directly. GoXmlTransformer provides a bunch of methods that offer standard ways of converting various data types to strings for both writing and reading.

Better yet, use GoXmlBindingTransformer, new in version 3, for an even more declarative way of saying what you want. But you’ll still need to store additional per-layer information in a separate data structure.