Inheritance: System.Xml.Serialization.XmlSerializationReader
        private object DeserializePrimitive(XmlReader xmlReader, XmlDeserializationEvents events)
        {
            XmlSerializationPrimitiveReader reader = new XmlSerializationPrimitiveReader();
            reader.Init(xmlReader, events, null, null);
            switch (Type.GetTypeCode(this.primitiveType))
            {
                case TypeCode.Boolean:
                    return reader.Read_boolean();

                case TypeCode.Char:
                    return reader.Read_char();

                case TypeCode.SByte:
                    return reader.Read_byte();

                case TypeCode.Byte:
                    return reader.Read_unsignedByte();

                case TypeCode.Int16:
                    return reader.Read_short();

                case TypeCode.UInt16:
                    return reader.Read_unsignedShort();

                case TypeCode.Int32:
                    return reader.Read_int();

                case TypeCode.UInt32:
                    return reader.Read_unsignedInt();

                case TypeCode.Int64:
                    return reader.Read_long();

                case TypeCode.UInt64:
                    return reader.Read_unsignedLong();

                case TypeCode.Single:
                    return reader.Read_float();

                case TypeCode.Double:
                    return reader.Read_double();

                case TypeCode.Decimal:
                    return reader.Read_decimal();

                case TypeCode.DateTime:
                    return reader.Read_dateTime();

                case TypeCode.String:
                    return reader.Read_string();
            }
            if (this.primitiveType == typeof(XmlQualifiedName))
            {
                return reader.Read_QName();
            }
            if (this.primitiveType == typeof(byte[]))
            {
                return reader.Read_base64Binary();
            }
            if (this.primitiveType != typeof(Guid))
            {
                throw new InvalidOperationException(Res.GetString("XmlUnxpectedType", new object[] { this.primitiveType.FullName }));
            }
            return reader.Read_guid();
        }
        private object DeserializePrimitive(XmlReader xmlReader, XmlDeserializationEvents events)
        {
            XmlSerializationPrimitiveReader reader = new XmlSerializationPrimitiveReader();
            reader.Init(xmlReader, events, null, null);
            object o;
            switch (_primitiveType.GetTypeCode())
            {
                case TypeCode.String:
                    o = reader.Read_string();
                    break;
                case TypeCode.Int32:
                    o = reader.Read_int();
                    break;
                case TypeCode.Boolean:
                    o = reader.Read_boolean();
                    break;
                case TypeCode.Int16:
                    o = reader.Read_short();
                    break;
                case TypeCode.Int64:
                    o = reader.Read_long();
                    break;
                case TypeCode.Single:
                    o = reader.Read_float();
                    break;
                case TypeCode.Double:
                    o = reader.Read_double();
                    break;
                case TypeCode.Decimal:
                    o = reader.Read_decimal();
                    break;
                case TypeCode.DateTime:
                    o = reader.Read_dateTime();
                    break;
                case TypeCode.Char:
                    o = reader.Read_char();
                    break;
                case TypeCode.Byte:
                    o = reader.Read_unsignedByte();
                    break;
                case TypeCode.SByte:
                    o = reader.Read_byte();
                    break;
                case TypeCode.UInt16:
                    o = reader.Read_unsignedShort();
                    break;
                case TypeCode.UInt32:
                    o = reader.Read_unsignedInt();
                    break;
                case TypeCode.UInt64:
                    o = reader.Read_unsignedLong();
                    break;

                default:
                    if (_primitiveType == typeof(XmlQualifiedName))
                    {
                        o = reader.Read_QName();
                    }
                    else if (_primitiveType == typeof(byte[]))
                    {
                        o = reader.Read_base64Binary();
                    }
                    else if (_primitiveType == typeof(Guid))
                    {
                        o = reader.Read_guid();
                    }
                    else if (_primitiveType == typeof(TimeSpan))
                    {
                        o = reader.Read_TimeSpan();
                    }
                    else
                    {
                        throw new InvalidOperationException(SR.Format(SR.XmlUnxpectedType, _primitiveType.FullName));
                    }
                    break;
            }
            return o;
        }
Exemple #3
0
        private object DeserializePrimitive(XmlReader xmlReader, XmlDeserializationEvents events)
        {
            XmlSerializationPrimitiveReader reader = new XmlSerializationPrimitiveReader();

            reader.Init(xmlReader, events, null, null);
            object o;

            switch (_primitiveType.GetTypeCode())
            {
            case TypeCode.String:
                o = reader.Read_string();
                break;

            case TypeCode.Int32:
                o = reader.Read_int();
                break;

            case TypeCode.Boolean:
                o = reader.Read_boolean();
                break;

            case TypeCode.Int16:
                o = reader.Read_short();
                break;

            case TypeCode.Int64:
                o = reader.Read_long();
                break;

            case TypeCode.Single:
                o = reader.Read_float();
                break;

            case TypeCode.Double:
                o = reader.Read_double();
                break;

            case TypeCode.Decimal:
                o = reader.Read_decimal();
                break;

            case TypeCode.DateTime:
                o = reader.Read_dateTime();
                break;

            case TypeCode.Char:
                o = reader.Read_char();
                break;

            case TypeCode.Byte:
                o = reader.Read_unsignedByte();
                break;

            case TypeCode.SByte:
                o = reader.Read_byte();
                break;

            case TypeCode.UInt16:
                o = reader.Read_unsignedShort();
                break;

            case TypeCode.UInt32:
                o = reader.Read_unsignedInt();
                break;

            case TypeCode.UInt64:
                o = reader.Read_unsignedLong();
                break;

            default:
                if (_primitiveType == typeof(XmlQualifiedName))
                {
                    o = reader.Read_QName();
                }
                else if (_primitiveType == typeof(byte[]))
                {
                    o = reader.Read_base64Binary();
                }
                else if (_primitiveType == typeof(Guid))
                {
                    o = reader.Read_guid();
                }
                else if (_primitiveType == typeof(TimeSpan))
                {
                    o = reader.Read_TimeSpan();
                }
                else
                {
                    throw new InvalidOperationException(SR.Format(SR.XmlUnxpectedType, _primitiveType.FullName));
                }
                break;
            }
            return(o);
        }