Opc.Ua.XmlDecoder.ReadExtensionObjectBody C# (CSharp) Method

ReadExtensionObjectBody() public method

Reads the body extension object from the stream.
public ReadExtensionObjectBody ( Opc.Ua.ExpandedNodeId typeId ) : object
typeId Opc.Ua.ExpandedNodeId
return object
        public object ReadExtensionObjectBody(ExpandedNodeId typeId)
        {            
            m_reader.MoveToContent();
                                    
            // check for binary encoded body.
            if (m_reader.LocalName == "ByteString" && m_reader.NamespaceURI == Namespaces.OpcUaXsd)
            {
                PushNamespace(Namespaces.OpcUaXsd);
                byte[] bytes = ReadByteString("ByteString");       
                PopNamespace();
                
                return bytes;
            }

            // check for empty body.
            XmlDocument document = new XmlDocument();

            if (m_reader.IsEmptyElement)
            {        
                document.InnerXml = m_reader.ReadOuterXml();                        
                return document.DocumentElement;
            }

            // lookup type.
            IEncodeable encodeable = null;

            Type systemType = m_context.Factory.GetSystemType(typeId);

            // decode known type.
            if (systemType != null)
            {                      
                PushNamespace(m_reader.NamespaceURI);
                encodeable = ReadEncodeable(m_reader.LocalName, systemType);
                PopNamespace();
                                
                return encodeable;
            }
            
            // return undecoded xml body.                 
            document.InnerXml = m_reader.ReadOuterXml();                        
            return document.DocumentElement;
        }
        #endregion