Beispiel #1
0
        public ValueSerializer GetDeserializerByManifest(Stream stream, DeserializerSession session)
        {
            var first = stream.ReadByte();

            switch (first)
            {
            case NullSerializer.Manifest:
                return(NullSerializer.Instance);

//TODO: hmm why havent I added 1?
            case Int64Serializer.Manifest:
                return(Int64Serializer.Instance);

            case Int16Serializer.Manifest:
                return(Int16Serializer.Instance);

            case ByteSerializer.Manifest:
                return(ByteSerializer.Instance);

            case DateTimeSerializer.Manifest:
                return(DateTimeSerializer.Instance);

            case BoolSerializer.Manifest:
                return(BoolSerializer.Instance);

            case StringSerializer.Manifest:
                return(StringSerializer.Instance);

            case Int32Serializer.Manifest:
                return(Int32Serializer.Instance);

            case ByteArraySerializer.Manifest:
                return(ByteArraySerializer.Instance);

            case GuidSerializer.Manifest:
                return(GuidSerializer.Instance);

            case FloatSerializer.Manifest:
                return(FloatSerializer.Instance);

            case DoubleSerializer.Manifest:
                return(DoubleSerializer.Instance);

            case DecimalSerializer.Manifest:
                return(DecimalSerializer.Instance);

            case CharSerializer.Manifest:
                return(CharSerializer.Instance);

            case TypeSerializer.Manifest:
                return(TypeSerializer.Instance);

            case UInt16Serializer.Manifest:
                return(UInt16Serializer.Instance);

            case UInt32Serializer.Manifest:
                return(UInt32Serializer.Instance);

            case UInt64Serializer.Manifest:
                return(UInt64Serializer.Instance);

            case SByteSerializer.Manifest:
                return(SByteSerializer.Instance);

            case ObjectReferenceSerializer.Manifest:
                return(ObjectReferenceSerializer.Instance);

            case ConsistentArraySerializer.Manifest:
                return(ConsistentArraySerializer.Instance);

            case ObjectSerializer.ManifestFull:
            {
                var type = ObjectSerializer.GetTypeFromManifestFull(stream, session);
                return(GetCustomDeserialzer(type));
            }

            case ObjectSerializer.ManifestIndex:
            {
                var type = ObjectSerializer.GetTypeFromManifestIndex(stream, session);
                return(GetCustomDeserialzer(type));
            }

            default:
                throw new NotSupportedException("Unknown manifest value");
            }
        }