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

ReadByteArray() public method

Reads a byte array from the stream.
public ReadByteArray ( string fieldName ) : ByteCollection
fieldName string
return ByteCollection
        public ByteCollection ReadByteArray(string fieldName)
        {
            bool isNil = false;

            ByteCollection values = new ByteCollection();

            if (BeginField(fieldName, true, out isNil))
            {
                PushNamespace(Namespaces.OpcUaXsd);

                while (MoveToElement("Byte"))
                {
                    values.Add(ReadByte("Byte"));
                }

                // check the length.
                if (m_context.MaxArrayLength > 0 && m_context.MaxArrayLength < values.Count)
                {
                    throw new ServiceResultException(StatusCodes.BadEncodingLimitsExceeded);
                }

                PopNamespace();

                EndField(fieldName);
                return values;
            }

            if (isNil)
            {
                return null;
            }

            return values;
        }