Ejemplo n.º 1
0
        public override object ReadValue(Stream stream, DeserializerSession session)
        {
            var bytes = stream.ReadByteArrayKey(session);

            if (bytes == null)
            {
                return(null);
            }
            var byteArr = bytes.Value;

            var shortname = StringEx.FromUtf8Bytes(byteArr.Bytes, 0, byteArr.Bytes.Length);
            var options   = session.Serializer.Options;

            var type = TypeNameLookup.GetOrAdd(shortname,
                                               name => TypeEx.LoadTypeByName(shortname, options.DisallowUnsafeTypes, options.TypeFilter));

            //add the deserialized type to lookup
            if (session.Serializer.Options.PreserveObjectReferences)
            {
                session.TrackDeserializedObject(type);
            }
            return(type);
        }