// Read Constructor // [System.Security.SecurityCritical] // auto-generated internal void Init(Type objectType, String[] memberNames, Type[] memberTypes, ISurrogateSelector surrogateSelector, StreamingContext context, ObjectManager objectManager, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, bool bSimpleAssembly) { SerTrace.Log(this, objectInfoId, " Constructor 5 ", objectType); this.objectType = objectType; this.objectManager = objectManager; this.wireMemberNames = memberNames; this.wireMemberTypes = memberTypes; this.context = context; this.serObjectInfoInit = serObjectInfoInit; this.formatterConverter = converter; this.bSimpleAssembly = bSimpleAssembly; if (memberNames != null) { isNamed = true; } if (memberTypes != null) { isTyped = true; } if ((object)objectType != null) { InitReadConstructor(objectType, surrogateSelector, context); } }
private static ReadObjectInfo GetObjectInfo(SerObjectInfoInit serObjectInfoInit) { ReadObjectInfo roi = new ReadObjectInfo(); roi.objectInfoId = Interlocked.Increment(ref readObjectInfoCounter); return(roi); }
// Read Constructor // [System.Security.SecurityCritical] // auto-generated internal void Init(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, ObjectManager objectManager, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, bool bSimpleAssembly) { SerTrace.Log(this, objectInfoId, " Constructor 3 ", objectType); this.objectType = objectType; this.objectManager = objectManager; this.context = context; this.serObjectInfoInit = serObjectInfoInit; this.formatterConverter = converter; this.bSimpleAssembly = bSimpleAssembly; InitReadConstructor(objectType, surrogateSelector, context); }
// Write Constructor used for array types or null members // [System.Security.SecurityCritical] // auto-generated internal void InitSerialize(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, SerializationBinder binder) { SerTrace.Log(this, objectInfoId, " Constructor 2 ", objectType); this.objectType = objectType; this.context = context; this.serObjectInfoInit = serObjectInfoInit; if (objectType.IsArray) { InitNoMembers(); return; } InvokeSerializationBinder(binder); ISurrogateSelector surrogateSelectorTemp = null; if (surrogateSelector != null) { serializationSurrogate = surrogateSelector.GetSurrogate(objectType, context, out surrogateSelectorTemp); } if (serializationSurrogate != null) { // surrogate does not have this problem since user has pass in through the BF's ctor si = new SerializationInfo(objectType, converter); cache = new SerObjectInfoCache(objectType); isSi = true; } else if (Object.ReferenceEquals(objectType, Converter.typeofObject)) { } else if (Converter.typeofISerializable.IsAssignableFrom(objectType)) { si = new SerializationInfo(objectType, converter, !FormatterServices.UnsafeTypeForwardersIsEnabled()); cache = new SerObjectInfoCache(objectType); CheckTypeForwardedFrom(cache, objectType, binderAssemblyString); isSi = true; } if (!isSi) { InitMemberInfo(); CheckTypeForwardedFrom(cache, objectType, binderAssemblyString); } SerTrace.Log(this, objectInfoId, " ", objectType, " InitSerialize Exit ", isSi); }
private static WriteObjectInfo GetObjectInfo(SerObjectInfoInit serObjectInfoInit) { WriteObjectInfo objectInfo = null; if (!serObjectInfoInit.oiPool.IsEmpty()) { objectInfo = (WriteObjectInfo)serObjectInfoInit.oiPool.Pop(); objectInfo.InternalInit(); //SerTrace.Log( "GetObjectInfo",objectInfo.objectInfoId," GetObjectInfo from pool"); } else { objectInfo = new WriteObjectInfo(); objectInfo.objectInfoId = serObjectInfoInit.objectInfoIdCount++; //SerTrace.Log( "GetObjectInfo",objectInfo.objectInfoId," GetObjectInfo new not from pool"); } return(objectInfo); }
// [System.Security.SecurityCritical] // auto-generated internal static ReadObjectInfo Create(Type objectType, String[] memberNames, Type[] memberTypes, ISurrogateSelector surrogateSelector, StreamingContext context, ObjectManager objectManager, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, bool bSimpleAssembly) { ReadObjectInfo soi = GetObjectInfo(serObjectInfoInit); soi.Init(objectType, memberNames, memberTypes, surrogateSelector, context, objectManager, serObjectInfoInit, converter, bSimpleAssembly); return(soi); }
private static void PutObjectInfo(SerObjectInfoInit serObjectInfoInit, WriteObjectInfo objectInfo) { serObjectInfoInit.oiPool.Push(objectInfo); //SerTrace.Log( "PutObjectInfo",objectInfo.objectInfoId," PutObjectInfo to pool"); }
// [System.Security.SecurityCritical] // auto-generated internal static WriteObjectInfo Serialize(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, SerializationBinder binder) { WriteObjectInfo soi = GetObjectInfo(serObjectInfoInit); soi.InitSerialize(objectType, surrogateSelector, context, serObjectInfoInit, converter, binder); return(soi); }
// Write constructor // [System.Security.SecurityCritical] // auto-generated internal void InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder) { SerTrace.Log(this, objectInfoId, " Constructor 1 ", obj); this.context = context; this.obj = obj; this.serObjectInfoInit = serObjectInfoInit; ISurrogateSelector surrogateSelectorTemp; #if FEATURE_REMOTING if (RemotingServices.IsTransparentProxy(obj)) { objectType = Converter.typeofMarshalByRefObject; } else #endif objectType = obj.GetType(); if (objectType.IsArray) { isArray = true; InitNoMembers(); return; } InvokeSerializationBinder(binder); SerTrace.Log(this, objectInfoId, " Constructor 1 trace 2"); objectWriter.ObjectManager.RegisterObject(obj); if (surrogateSelector != null && (serializationSurrogate = surrogateSelector.GetSurrogate(objectType, context, out surrogateSelectorTemp)) != null) { SerTrace.Log(this, objectInfoId, " Constructor 1 trace 3"); si = new SerializationInfo(objectType, converter); if (!objectType.IsPrimitive) { serializationSurrogate.GetObjectData(obj, si, context); } InitSiWrite(); } else if (obj is ISerializable) { if (!objectType.IsSerializable) { throw new SerializationException(Ssz.Runtime.Serialization.Environment.GetResourceString("Serialization_NonSerType", objectType.FullName, objectType.Assembly.FullName)); } si = new SerializationInfo(objectType, converter, !FormatterServices.UnsafeTypeForwardersIsEnabled()); #if FEATURE_SERIALIZATION ((ISerializable)obj).GetObjectData(si, context); #endif SerTrace.Log(this, objectInfoId, " Constructor 1 trace 4 ISerializable " + objectType); InitSiWrite(); CheckTypeForwardedFrom(cache, objectType, binderAssemblyString); } else { SerTrace.Log(this, objectInfoId, " Constructor 1 trace 5"); InitMemberInfo(); CheckTypeForwardedFrom(cache, objectType, binderAssemblyString); } }