Beispiel #1
0
        /// <summary>
        /// Reads an object from the current node.
        /// </summary>
        private bool DoReadProxy <ProxyType, InnerType>(string inKey, ref ProxyType ioData, ProxyType inDefault, FieldOptions inOptions, ReadFunc <InnerType> inReader)
            where ProxyType : struct, ISerializedProxy <InnerType>
        {
            bool bSuccess = BeginReadValue(inKey);

            if (IsMissing() || IsNull())
            {
                ioData   = inDefault;
                bSuccess = true;
            }
            else
            {
                InnerType innerData = default(InnerType);
                if (inReader(ref innerData))
                {
                    ISerializedProxy <InnerType> proxy = ioData;
                    proxy.SetProxyValue(innerData, Context);
                    ioData = (ProxyType)proxy;
                }
                else
                {
                    bSuccess = false;
                }
            }
            EndValue();

            return(bSuccess);
        }
Beispiel #2
0
        /// <summary>
        /// Reads an object from the current node.
        /// </summary>
        private bool DoReadProxy <ProxyType, InnerType>(int inIndex, ref ProxyType ioData, FieldOptions inOptions, ReadFunc <InnerType> inReader)
            where ProxyType : struct, ISerializedProxy <InnerType>
        {
            bool bSuccess = BeginReadValue(inIndex);

            if (IsMissing())
            {
                if ((inOptions & FieldOptions.Optional) != 0)
                {
                    ioData   = default(ProxyType);
                    bSuccess = true;
                }
                else
                {
                    bSuccess &= false;
                }
            }
            else if (IsNull())
            {
                ioData   = default(ProxyType);
                bSuccess = true;
            }
            else
            {
                InnerType innerData = default(InnerType);
                if (inReader(ref innerData))
                {
                    ISerializedProxy <InnerType> proxy = ioData;
                    proxy.SetProxyValue(innerData, Context);
                    ioData = (ProxyType)proxy;
                }
                else
                {
                    bSuccess = false;
                }
            }
            EndValue();

            return(bSuccess);
        }