private static CheckTypeForwardedFrom ( |
||
cache | ||
objectType | ||
binderAssemblyString | string | |
return | void |
internal void InitSerialize(object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder) { this.context = context; this.obj = obj; this.serObjectInfoInit = serObjectInfoInit; if (RemotingServices.IsTransparentProxy(obj)) { this.objectType = Converter.typeofMarshalByRefObject; } else { this.objectType = obj.GetType(); } if (this.objectType.IsArray) { this.isArray = true; this.InitNoMembers(); return; } this.InvokeSerializationBinder(binder); objectWriter.ObjectManager.RegisterObject(obj); ISurrogateSelector surrogateSelector2; if (surrogateSelector != null && (this.serializationSurrogate = surrogateSelector.GetSurrogate(this.objectType, context, out surrogateSelector2)) != null) { this.si = new SerializationInfo(this.objectType, converter); if (!this.objectType.IsPrimitive) { this.serializationSurrogate.GetObjectData(obj, this.si, context); } this.InitSiWrite(); return; } if (!(obj is ISerializable)) { this.InitMemberInfo(); WriteObjectInfo.CheckTypeForwardedFrom(this.cache, this.objectType, this.binderAssemblyString); return; } if (!this.objectType.IsSerializable) { throw new SerializationException(Environment.GetResourceString("Serialization_NonSerType", new object[] { this.objectType.FullName, this.objectType.Assembly.FullName })); } this.si = new SerializationInfo(this.objectType, converter, !FormatterServices.UnsafeTypeForwardersIsEnabled()); ((ISerializable)obj).GetObjectData(this.si, context); this.InitSiWrite(); WriteObjectInfo.CheckTypeForwardedFrom(this.cache, this.objectType, this.binderAssemblyString); }
internal void InitSerialize(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, SerializationBinder binder) { this.objectType = objectType; this.context = context; this.serObjectInfoInit = serObjectInfoInit; if (objectType.IsArray) { this.InitNoMembers(); } else { this.InvokeSerializationBinder(binder); ISurrogateSelector selector = (ISurrogateSelector)null; if (surrogateSelector != null) { this.serializationSurrogate = surrogateSelector.GetSurrogate(objectType, context, out selector); } if (this.serializationSurrogate != null) { this.si = new SerializationInfo(objectType, converter); this.cache = new SerObjectInfoCache(objectType); this.isSi = true; } else if (objectType != Converter.typeofObject && Converter.typeofISerializable.IsAssignableFrom(objectType)) { this.si = new SerializationInfo(objectType, converter, !FormatterServices.UnsafeTypeForwardersIsEnabled()); this.cache = new SerObjectInfoCache(objectType); WriteObjectInfo.CheckTypeForwardedFrom(this.cache, objectType, this.binderAssemblyString); this.isSi = true; } if (this.isSi) { return; } this.InitMemberInfo(); WriteObjectInfo.CheckTypeForwardedFrom(this.cache, objectType, this.binderAssemblyString); } }