Пример #1
0
        internal override object zDeserialize(Type type, string toFieldName, DeserializeSettings deserializeSettings)
        {
            if (type == typeof(string))
            {
                return(this.AsString());
            }

            throw (DeserializeException.forNonMatchingType(this, type, toFieldName));
        }
Пример #2
0
        internal override object zDeserialize(Type type, string toFieldName, DeserializeSettings deserializeSettings)
        {
            if (type == typeof(float))
            {
                return(this.AsFloat());
            }
            if (type == typeof(double))
            {
                return(this.AsDouble());
            }
            if (type == typeof(decimal))
            {
                return(this.AsDecimal());
            }

            if (type == typeof(int))
            {
                return(this.AsInt());
            }
            if (type == typeof(long))
            {
                return(this.AsLong());
            }
            if (type == typeof(short))
            {
                return(this.AsShort());
            }
            if (type == typeof(byte))
            {
                return(this.AsByte());
            }

            if (type == typeof(uint))
            {
                return(this.AsUInt());
            }
            if (type == typeof(ulong))
            {
                return(this.AsULong());
            }
            if (type == typeof(ushort))
            {
                return(this.AsUShort());
            }
            if (type == typeof(sbyte))
            {
                return(this.AsSByte());
            }

            throw (DeserializeException.forNonMatchingType(this, type, toFieldName));
        }
Пример #3
0
        internal override object zDeserialize(Type type, string toFieldName, DeserializeSettings deserializeSettings)
        {
            // Do at least some basic checking that not trying to add null to number or boolean field, as trying to set null to these objects using FieldInfo doesn't cause exception.
            // If field type is nullable like "bool?" or "int?", type is also System.Nullable so this check doesn't prevent adding null value to those fields.
            if (type == typeof(float) || type == typeof(double) || type == typeof(decimal) ||
                type == typeof(int) || type == typeof(long) || type == typeof(short) || type == typeof(byte) ||
                type == typeof(uint) || type == typeof(ulong) || type == typeof(ushort) || type == typeof(sbyte) ||
                type == typeof(bool))
            {
                throw (DeserializeException.forNonMatchingType(this, type, toFieldName));
            }

            return(null);
        }