Opc.Ua.JsonDecoder.ReadEncodeable C# (CSharp) Method

ReadEncodeable() public method

Reads an encodeable object from the stream.
public ReadEncodeable ( string fieldName, System systemType ) : IEncodeable
fieldName string
systemType System
return IEncodeable
        public IEncodeable ReadEncodeable(
            string      fieldName, 
            System.Type systemType)
        {
            if (systemType == null) throw new ArgumentNullException("systemType");

            object token = null;

            if (!ReadField(fieldName, out token))
            {
                return null;
            }

            IEncodeable value = Activator.CreateInstance(systemType) as IEncodeable;
            
            if (value == null)
            {               
                throw new ServiceResultException(StatusCodes.BadDecodingError, Utils.Format("Type does not support IEncodeable interface: '{0}'", systemType.FullName));
            }

            try
            {
                m_stack.Push(token);

                value.Decode(this);
            }
            finally
            {
                m_stack.Pop();
            }

            return value;
        }