private void FixupSpecialObject(ObjectHolder holder)
{
ISurrogateSelector uselessSelector = null;
Debug.Assert(holder.RequiresSerInfoFixup, "[ObjectManager.FixupSpecialObject]holder.HasSurrogate||holder.HasISerializable");
if (holder.HasSurrogate)
{
ISerializationSurrogate surrogate = holder.Surrogate;
Debug.Assert(surrogate != null, "surrogate!=null");
object returnValue = surrogate.SetObjectData(holder.ObjectValue, holder.SerializationInfo, _context, uselessSelector);
if (returnValue != null)
{
if (!holder.CanSurrogatedObjectValueChange && returnValue != holder.ObjectValue)
{
throw new SerializationException(string.Format(CultureInfo.CurrentCulture, SR.Serialization_NotCyclicallyReferenceableSurrogate, surrogate.GetType().FullName));
}
holder.SetObjectValue(returnValue, this);
}
holder._surrogate = null;
holder.SetFlags();
}
else
{
//Set the object data
Debug.Assert(holder.ObjectValue is ISerializable, "holder.m_object is ISerializable");
CompleteISerializableObject(holder.ObjectValue, holder.SerializationInfo, _context);
}
//Clear anything that we know that we're not going to need.
holder.SerializationInfo = null;
holder.RequiresSerInfoFixup = false;
// For value types, fixups would have been done. So the newly fixed object must be copied
// to its container.
if (holder.RequiresValueTypeFixup && holder.ValueTypeFixupPerformed)
{
DoValueTypeFixup(null, holder, holder.ObjectValue);
}
DoNewlyRegisteredObjectFixups(holder);
}