/// <summary> /// Reads the <see cref="Guid"/> form a buffer using <see cref="IBinaryDecoder"/>. /// </summary> /// <param name="decoder">The decoder to be used to recover data from a buffer.</param> /// <returns>Guid.</returns> internal static Guid ReadGuid(this IBinaryDecoder decoder) { int m_EncodedGuidLength = 16; byte[] bytes = decoder.ReadBytes(m_EncodedGuidLength); return(new Guid(bytes)); }
/// <summary> /// Reads the string od bytes from UA Binary encoded as a 16-element byte array that contains the value. /// </summary> /// <param name="decoder">The decoder <see cref="IBinaryDecoder" /> to be used to read form the stream.</param> /// <returns>The <see cref="System.Byte" /> array decoded from the UA binary stream of bytes.</returns> public byte[] ReadByteString(IBinaryDecoder decoder) { Int32 _length = decoder.ReadInt32(); if (_length < 0) { return(null); } return(decoder.ReadBytes(_length)); }
/// <summary> /// Reads the <see cref="string" /> from UA binary encoded stream of bytes encoded as a sequence of UTF8 characters without a null terminator and preceded by the length in bytes. /// The length in bytes is encoded as Int32. A value of −1 is used to indicate a ‘null’ string. /// </summary> /// <param name="decoder">The decoder <see cref="IBinaryDecoder" /> to be used to read form the stream.</param> /// <returns>The <see cref="string" /> decoded from the UA binary stream of bytes.</returns> /// <exception cref="System.NotImplementedException"></exception> public string ReadString(IBinaryDecoder decoder) { int length = decoder.ReadInt32(); if (length == -1) { return(null); } byte[] bytes = decoder.ReadBytes(length); return(new UTF8Encoding().GetString(bytes, 0, bytes.Length)); }