Implementing OnSerialize - SmartPlant Foundation - IM Update 44 - Customization & Programming - Hexagon

SmartPlant Foundation Customization

Language
English
Product
SmartPlant Foundation
Search by Category
Customization & Programming
SmartPlant Foundation / SDx Version
10

The job of this method is exactly the opposite of DeSerialize (in case you hadn't already guessed). On the SPFServer object available as an inherited property of the Server API, there is a Response property:

Public Property Response() As System.Xml.XmlDocument

This is where the response is formed to be sent back to the client. An (extremely simple) example of using this is as follows:

Dim lnodReply As XmlNode = SPFRequestContext.Instance.Response.AppendChild(SPFRequestContext.Instance.Response.CreateElement("Reply"))

This just creates a reply node. You then have various serializers available to write out the information for you.

The default serializer is called EFXmlSerializationWriter. Normally, you pass in am IObject class or collection, and it will put a <Container> node around it and then append each of the items serialized underneath. There are a number of arguments that will give different behavior. Typical usage would be to pass your dictionary something like this:

Dim lelmTop As XmlElement =

CoreModule.Serializer.Serialize(mobjMyDictionary, New EFXmlSerializationWriter(False, False, "MainContainerNodeName"))

lelmReply.AppendChild(lelmReply.OwnerDocument.ImportNode(lelmTop, True))