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);
}