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

ReadByteString() public method

Reads a byte string from the stream.
public ReadByteString ( string fieldName ) : byte[]
fieldName string
return byte[]
        public byte[] ReadByteString(string fieldName)
        {
            bool isNil = false;
                        
            if (BeginField(fieldName, true, out isNil))
            {
                byte[] value = null;

                string xml = m_reader.ReadContentAsString();

                if (!String.IsNullOrEmpty(xml))
                {
                    value = Convert.FromBase64String(xml);
                }
                else
                {
                    value = new byte[0];
                }
                
                // check the length.
                if (m_context.MaxByteStringLength > 0 && m_context.MaxByteStringLength < value.Length)
                {
                    throw new ServiceResultException(StatusCodes.BadEncodingLimitsExceeded);
                }

                EndField(fieldName);
                return value;
            }

            if (!isNil)
            {
                return new byte[0];
            }

            return null;
        }