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

ReadString() public method

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

                if (value != null)
                {
                    value = value.Trim();
                }
                
                EndField(fieldName);
                return value;
            }

            if (!isNil)
            {
                return String.Empty;
            }

            return null;
        }
        

Same methods

XmlDecoder::ReadString ( ) : string

Usage Example

        /// <summary>
        /// Updates the attributes from the stream.
        /// </summary>
        /// <param name="context">The context for the system being accessed.</param>
        /// <param name="decoder">The decoder wrapping the stream to read.</param>
        public override void Update(ISystemContext context, XmlDecoder decoder)
        {
            base.Update(context, decoder);

            decoder.PushNamespace(Namespaces.OpcUaXsd);

            if (decoder.Peek("Value"))
            {
                WrappedValue = decoder.ReadVariant("Value");
            }

            if (decoder.Peek("DataType"))
            {
                DataType = decoder.ReadNodeId("DataType");
            }

            if (decoder.Peek("ValueRank"))
            {
                ValueRank = decoder.ReadInt32("ValueRank");
            }

            if (decoder.Peek("ArrayDimensions"))
            {
                ArrayDimensions = BaseVariableState.ArrayDimensionsFromXml(decoder.ReadString("ArrayDimensions"));
            }

            decoder.PopNamespace();
        }