Ejemplo n.º 1
0
        /// <summary>
        /// Decode a scalar type
        /// </summary>
        private object DecodeRawScalar(JsonDecoder jsonDecoder, byte builtInType, string fieldName)
        {
            try
            {
                switch ((BuiltInType)builtInType)
                {
                case BuiltInType.Boolean:
                    return(jsonDecoder.ReadBoolean(fieldName));

                case BuiltInType.SByte:
                    return(jsonDecoder.ReadSByte(fieldName));

                case BuiltInType.Byte:
                    return(jsonDecoder.ReadByte(fieldName));

                case BuiltInType.Int16:
                    return(jsonDecoder.ReadInt16(fieldName));

                case BuiltInType.UInt16:
                    return(jsonDecoder.ReadUInt16(fieldName));

                case BuiltInType.Int32:
                    return(jsonDecoder.ReadInt32(fieldName));

                case BuiltInType.UInt32:
                    return(jsonDecoder.ReadUInt32(fieldName));

                case BuiltInType.Int64:
                    return(jsonDecoder.ReadInt64(fieldName));

                case BuiltInType.UInt64:
                    return(jsonDecoder.ReadUInt64(fieldName));

                case BuiltInType.Float:
                    return(jsonDecoder.ReadFloat(fieldName));

                case BuiltInType.Double:
                    return(jsonDecoder.ReadDouble(fieldName));

                case BuiltInType.String:
                    return(jsonDecoder.ReadString(fieldName));

                case BuiltInType.DateTime:
                    return(jsonDecoder.ReadDateTime(fieldName));

                case BuiltInType.Guid:
                    return(jsonDecoder.ReadGuid(fieldName));

                case BuiltInType.ByteString:
                    return(jsonDecoder.ReadByteString(fieldName));

                case BuiltInType.XmlElement:
                    return(jsonDecoder.ReadXmlElement(fieldName));

                case BuiltInType.NodeId:
                    return(jsonDecoder.ReadNodeId(fieldName));

                case BuiltInType.ExpandedNodeId:
                    return(jsonDecoder.ReadExpandedNodeId(fieldName));

                case BuiltInType.QualifiedName:
                    return(jsonDecoder.ReadQualifiedName(fieldName));

                case BuiltInType.LocalizedText:
                    return(jsonDecoder.ReadLocalizedText(fieldName));

                case BuiltInType.DataValue:
                    return(jsonDecoder.ReadDataValue(fieldName));

                case BuiltInType.Enumeration:
                    return(jsonDecoder.ReadInt32(fieldName));

                case BuiltInType.Variant:
                    return(jsonDecoder.ReadVariant(fieldName));

                case BuiltInType.ExtensionObject:
                    return(jsonDecoder.ReadExtensionObject(fieldName));

                case BuiltInType.DiagnosticInfo:
                    return(jsonDecoder.ReadDiagnosticInfo(fieldName));

                case BuiltInType.StatusCode:
                    return(jsonDecoder.ReadStatusCode(fieldName));
                }
            }
            catch (Exception ex)
            {
                Utils.Trace(ex, "JsonDataSetMessage - Error decoding field {0}", fieldName);
            }

            return(null);
        }