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

ReadLocalizedText() public method

Reads an LocalizedText from the stream.
public ReadLocalizedText ( string fieldName ) : Opc.Ua.LocalizedText
fieldName string
return Opc.Ua.LocalizedText
        public LocalizedText ReadLocalizedText(string fieldName)
        {
            if (BeginField(fieldName, true))
            {                
                PushNamespace(Namespaces.OpcUaXsd);
                
                bool isNil = false;
                string text = null;
                string locale = null;

                if (BeginField("Locale", true, out isNil))
                {
                    locale = ReadString(null);
                    EndField("Locale");
                }
                else if (!isNil)
                {
                    locale = String.Empty;
                }

                if (BeginField("Text", true, out isNil))
                {
                    text = ReadString(null);
                    EndField("Text");
                }                
                else if (!isNil)
                {
                    text = String.Empty;
                }

                LocalizedText value = new LocalizedText(locale, text);

                PopNamespace();
                
                EndField(fieldName);
                return value;
            }

            return LocalizedText.Null;
        }

Usage Example

コード例 #1
0
        /// <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("InverseName"))
            {
                InverseName = decoder.ReadLocalizedText("InverseName");
            }

            if (decoder.Peek("Symmetric"))
            {
                Symmetric = decoder.ReadBoolean("Symmetric");
            }

            decoder.PopNamespace();
        }