ReadExtensionObject() private method

Reads an extension object from the stream.
private ReadExtensionObject ( ) : Opc.Ua.ExtensionObject
return Opc.Ua.ExtensionObject
Ejemplo n.º 1
0
        /// <summary>
        /// Converts a VARIANT value to a Builtin Type.
        /// </summary>
        private object VariantValueToScalarValue(object value, NodeId builtinTypeId)
        {        
            switch ((uint)builtinTypeId.Identifier)
            {
                case DataTypes.Guid:
                {
                    return new Uuid((string)value);
                }

                case DataTypes.XmlElement:
                {    
                    XmlDocument document = new XmlDocument();
                    document.InnerXml = (string)value;
                    return document.DocumentElement;
                }

                case DataTypes.NodeId:
                {
                    return NodeId.Parse((string)value);
                }

                case DataTypes.ExpandedNodeId:
                {
                    return ExpandedNodeId.Parse((string)value);
                }

                case DataTypes.QualifiedName:
                {
                    return QualifiedName.Parse((string)value);
                }

                case DataTypes.LocalizedText:
                {
                    return new LocalizedText(ComUtils.GetLocale(m_lcid), (string)value);
                }

                case DataTypes.StatusCode:
                {
                     return new StatusCode((uint)value);
                }

                case DataTypes.DiagnosticInfo:
                {
                    BinaryDecoder decoder = new BinaryDecoder((byte[])value, m_session.MessageContext);
                    DiagnosticInfo decodedValue = decoder.ReadDiagnosticInfo(null);
                    decoder.Close();
                    return decodedValue; 
                }

                case DataTypes.DataValue:
                {
                    BinaryDecoder decoder = new BinaryDecoder((byte[])value, m_session.MessageContext);
                    DataValue decodedValue = decoder.ReadDataValue(null);
                    decoder.Close();
                    return decodedValue; 
                }

                case DataTypes.Structure:
                {
                    BinaryDecoder decoder = new BinaryDecoder((byte[])value, m_session.MessageContext);
                    ExtensionObject decodedValue = decoder.ReadExtensionObject(null);
                    decoder.Close();
                    return decodedValue; 
                }
            }

            return value;
        }