Example #1
0
 private void InitFullDeserialization()
 {
     _fullDeserialization = true;
     _stack         = new SerStack("ObjectReader Object Stack");
     _objectManager = new ObjectManager(_surrogates, _context);
     _formatterConverter ??= new FormatterConverter();
 }
 internal void Init(
     [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type?objectType,
     string[] memberNames,
     Type[]?memberTypes,
     ISurrogateSelector?surrogateSelector,
     StreamingContext context,
     ObjectManager?objectManager,
     SerObjectInfoInit?serObjectInfoInit,
     IFormatterConverter?converter,
     bool bSimpleAssembly)
 {
     _objectType         = objectType;
     _objectManager      = objectManager;
     _wireMemberNames    = memberNames;
     _wireMemberTypes    = memberTypes;
     _context            = context;
     _serObjectInfoInit  = serObjectInfoInit;
     _formatterConverter = converter;
     _isSimpleAssembly   = bSimpleAssembly;
     if (memberTypes != null)
     {
         _isTyped = true;
     }
     if (objectType != null)
     {
         InitReadConstructor(objectType, surrogateSelector, context);
     }
 }
        internal object Deserialize(BinaryParser serParser, bool fCheck)
        {
            if (serParser == null)
            {
                throw new ArgumentNullException(nameof(serParser));
            }

            _fullDeserialization = false;
            TopObject            = null;
            _topId = 0;

            _isSimpleAssembly = (_formatterEnums._assemblyFormat == FormatterAssemblyStyle.Simple);

            using (DeserializationToken token = SerializationInfo.StartDeserialization())
            {
                if (_fullDeserialization)
                {
                    // Reinitialize
                    _objectManager     = new ObjectManager(_surrogates, _context);
                    _serObjectInfoInit = new SerObjectInfoInit();
                }

                // Will call back to ParseObject, ParseHeader for each object found
                serParser.Run();

                if (_fullDeserialization)
                {
                    _objectManager !.DoFixups();
                }

                if (TopObject == null)
                {
                    throw new SerializationException(SR.Serialization_TopObject);
                }

                //if TopObject has a surrogate then the actual object may be changed during special fixup
                //So refresh it using topID.
                if (HasSurrogate(TopObject.GetType()) && _topId != 0)//Not yet resolved
                {
                    Debug.Assert(_objectManager != null);
                    TopObject = _objectManager.GetObject(_topId);
                }

                if (TopObject is IObjectReference)
                {
                    TopObject = ((IObjectReference)TopObject).GetRealObject(_context);
                }

                if (_fullDeserialization)
                {
                    _objectManager !.RaiseDeserializationEvent(); // This will raise both IDeserialization and [OnDeserialized] events
                }

                return(TopObject !);
            }
        }
Example #4
0
        internal void Init(Type objectType, ISurrogateSelector?surrogateSelector, StreamingContext context, ObjectManager?objectManager, SerObjectInfoInit?serObjectInfoInit, IFormatterConverter?converter, bool bSimpleAssembly)
        {
            _objectType         = objectType;
            _objectManager      = objectManager;
            _context            = context;
            _serObjectInfoInit  = serObjectInfoInit;
            _formatterConverter = converter;
            _isSimpleAssembly   = bSimpleAssembly;

            InitReadConstructor(objectType, surrogateSelector, context);
        }
        internal static ReadObjectInfo Create(
            [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type objectType,
            ISurrogateSelector?surrogateSelector,
            StreamingContext context,
            ObjectManager?objectManager,
            SerObjectInfoInit?serObjectInfoInit,
            IFormatterConverter?converter,
            bool bSimpleAssembly)
        {
            ReadObjectInfo roi = GetObjectInfo(serObjectInfoInit);

            roi.Init(objectType, surrogateSelector, context, objectManager, serObjectInfoInit, converter, bSimpleAssembly);
            return(roi);
        }
Example #6
0
        internal static ReadObjectInfo Create(Type?objectType, string[] memberNames, Type[]?memberTypes, ISurrogateSelector?surrogateSelector, StreamingContext context, ObjectManager?objectManager, SerObjectInfoInit?serObjectInfoInit, IFormatterConverter?converter, bool bSimpleAssembly)
        {
            ReadObjectInfo roi = GetObjectInfo(serObjectInfoInit);

            roi.Init(objectType, memberNames, memberTypes, surrogateSelector, context, objectManager, serObjectInfoInit, converter, bSimpleAssembly);
            return(roi);
        }