public ExtensionObject ReadExtensionObject(string fieldName)
{
if (!BeginField(fieldName, true))
{
return null;
}
PushNamespace(Namespaces.OpcUaXsd);
// read local type id.
NodeId typeId = ReadNodeId("TypeId");
// convert to absolute type id.
ExpandedNodeId absoluteId = NodeId.ToExpandedNodeId(typeId, m_context.NamespaceUris);
if (!NodeId.IsNull(typeId) && NodeId.IsNull(absoluteId))
{
Utils.Trace(
"Cannot de-serialized extension objects if the NamespaceUri is not in the NamespaceTable: Type = {0}",
typeId);
}
// read body.
if (!BeginField("Body", true))
{
// read end of extension object.
EndField(fieldName);
PopNamespace();
return new ExtensionObject(absoluteId);
}
// read the body.
object body = ReadExtensionObjectBody(absoluteId);
// read end of body.
EndField("Body");
PopNamespace();
// read end of extension object.
EndField(fieldName);
return new ExtensionObject(absoluteId, body);
}