public void Init(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, ObjectManager objectManager, SerializationObjectInfo serObjectInfoInit, IFormatterConverter converter, bool bSimpleAssembly) { this.ObjectType = objectType; this.ObjectManager = objectManager; this.context = context; this.serObjectInfoInit = serObjectInfoInit; this.converter = converter; this.isSimpleAssembly = bSimpleAssembly; this.InitReadConstructor(objectType, surrogateSelector, context); }
internal ObjectWriter(ISurrogateSelector selector, StreamingContext context, FormatterHelper formatterEnums, SerializationBinder binder) { this._surrogates = selector; this._context = context; this._binder = binder; this._formatterEnums = formatterEnums; this.ObjectManager = new SerializationObjectManager(context); this._idGenerator = new ObjectIDGenerator(); this._objectQueue = new Queue <object>(); this._formatterConverter = new FormatterConverter(); this._serObjectInfoInit = new SerializationObjectInfo(); }
internal void InitSerialize(object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerializationObjectInfo serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder) { _context = context; _obj = obj; _serObjectInfoInit = serObjectInfoInit; _objectType = obj.GetType(); if (_objectType.IsArray) { _isArray = true; InitNoMembers(); } else if (_objectType.IsSerializable) { InvokeSerializationBinder(binder); objectWriter.ObjectManager.RegisterObject(obj); if (surrogateSelector != null && (_serializationSurrogate = surrogateSelector.GetSurrogate(_objectType, context, out _)) != null) { _si = new SerializationInfo(_objectType, converter); if (!_objectType.IsPrimitive) { _serializationSurrogate.GetObjectData(obj, _si, context); } InitSiWrite(); } else if (obj is ISerializable serializable) { if (!_objectType.IsSerializable) { throw new SerializationException(RemotingResources.NotMarkedForSerialization.Format(_objectType.FullName, _objectType.Assembly.FullName)); } _si = new SerializationInfo(_objectType, converter); serializable.GetObjectData(_si, context); InitSiWrite(); //CheckTypeForwardedFrom(_cache, _objectType, _binderAssemblyString); } else { InitMemberInfo(); //CheckTypeForwardedFrom(_cache, _objectType, _binderAssemblyString); } } else { throw new SerializationException(RemotingResources.NotMarkedForSerialization.Format(_objectType.FullName, _objectType.Assembly.FullName)); } }
private static WriteObjectInfo GetObjectInfo(SerializationObjectInfo serObjectInfoInit) { WriteObjectInfo info; if (!serObjectInfoInit._oiPool.IsEmpty()) { info = (WriteObjectInfo)serObjectInfoInit._oiPool.Pop(); info.InternalInit(); } else { info = new WriteObjectInfo(); int num = serObjectInfoInit._objectInfoIdCount; serObjectInfoInit._objectInfoIdCount = num + 1; info._objectInfoId = num; } return(info); }
public void Init(Type objectType, string[] memberNames, Type[] memberTypes, ISurrogateSelector surrogateSelector, StreamingContext context, ObjectManager objectManager, SerializationObjectInfo serObjectInfoInit, IFormatterConverter converter, bool bSimpleAssembly) { this.ObjectType = objectType; this.ObjectManager = objectManager; this.wireMemberNames = memberNames; this.wireMemberTypes = memberTypes; this.context = context; this.serObjectInfoInit = serObjectInfoInit; this.converter = converter; this.isSimpleAssembly = bSimpleAssembly; if (memberTypes != null) { this.IsTyped = true; } if (objectType != null) { this.InitReadConstructor(objectType, surrogateSelector, context); } }
public object Deserialize(BinaryParser parser) { if (parser == null) { throw new ArgumentNullException("serParser"); } this.fullDeserialization = false; this.TopObject = null; this.topId = 0L; this.isSimpleAssembly = this.fh.AssemblyFormat == FormatterAssemblyStyle.Simple; //using (SerializationInfo.StartDeserialization()) //{ if (this.fullDeserialization) { this.objectManager = new ObjectManager(this.surrogates, this.context); this.objectInfo = new SerializationObjectInfo(); } parser.Run(); if (this.fullDeserialization) { this.objectManager.DoFixups(); } if (this.TopObject == null) { throw new SerializationException(RemotingResources.SerializationTopObjectMissing); } if (this.HasSurrogate(this.TopObject.GetType()) && (this.topId != 0)) { this.TopObject = this.objectManager.GetObject(this.topId); } if (TopObject is IObjectReference) { this.TopObject = ((IObjectReference)this.TopObject).GetRealObject(this.context); } if (this.fullDeserialization) { this.objectManager.RaiseDeserializationEvent(); } return(this.TopObject); //} }
internal void InitSerialize(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, SerializationObjectInfo serObjectInfoInit, IFormatterConverter converter, SerializationBinder binder) { _objectType = objectType; _context = context; _serObjectInfoInit = serObjectInfoInit; if (objectType.IsArray) { InitNoMembers(); } else { InvokeSerializationBinder(binder); if (surrogateSelector != null) { _serializationSurrogate = surrogateSelector.GetSurrogate(objectType, context, out _); } if (_serializationSurrogate != null) { _si = new SerializationInfo(objectType, converter); _cache = new SerializationObjectInfoCache(objectType); _isSi = true; } else if (!ReferenceEquals(objectType, Converter.s_typeofObject) && Converter.s_typeofISerializable.IsAssignableFrom(objectType)) { _si = new SerializationInfo(objectType, converter); _cache = new SerializationObjectInfoCache(objectType); //CheckTypeForwardedFrom(_cache, objectType, _binderAssemblyString); _isSi = true; } if (!_isSi) { InitMemberInfo(); //CheckTypeForwardedFrom(_cache, objectType, _binderAssemblyString); } } }
public static ReadObjectInfo Create(Type objectType, string[] memberNames, Type[] memberTypes, ISurrogateSelector surrogateSelector, StreamingContext context, ObjectManager objectManager, SerializationObjectInfo serObjectInfoInit, IFormatterConverter converter, bool bSimpleAssembly) { ReadObjectInfo objectInfo = GetObjectInfo(); objectInfo.Init(objectType, memberNames, memberTypes, surrogateSelector, context, objectManager, serObjectInfoInit, converter, bSimpleAssembly); return(objectInfo); }
internal static WriteObjectInfo Serialize(object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerializationObjectInfo serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder) { WriteObjectInfo objectInfo = GetObjectInfo(serObjectInfoInit); objectInfo.InitSerialize(obj, surrogateSelector, context, serObjectInfoInit, converter, objectWriter, binder); return(objectInfo); }
private static void PutObjectInfo(SerializationObjectInfo serObjectInfoInit, WriteObjectInfo objectInfo) { serObjectInfoInit._oiPool.Push(objectInfo); }