public ObjectWriter(Stream stream, Serializer.WriteMethods writeMethods, Action<object> preSerializationCallback = null,
Action<object> postSerializationCallback = null, SwapList surrogatesForObjects = null, SwapList objectsForSurrogates = null,
bool treatCollectionAsUserObject = false, bool useBuffering = true, bool disableStamping = false,
ReferencePreservation referencePreservation = ReferencePreservation.Preserve)
{
this.treatCollectionAsUserObject = treatCollectionAsUserObject;
this.objectsForSurrogates = objectsForSurrogates;
this.referencePreservation = referencePreservation;
this.preSerializationCallback = preSerializationCallback;
this.postSerializationCallback = postSerializationCallback;
this.writeMethods = writeMethods;
this.surrogatesForObjects = surrogatesForObjects ?? new SwapList();
parentObjects = new Dictionary<object, object>();
postSerializationHooks = new List<Action>();
types = new IdentifiedElementsDictionary<TypeDescriptor>(this);
Methods = new IdentifiedElementsDictionary<MethodDescriptor>(this);
Assemblies = new IdentifiedElementsDictionary<AssemblyDescriptor>(this);
Modules = new IdentifiedElementsDictionary<ModuleDescriptor>(this);
writer = new PrimitiveWriter(stream, useBuffering);
if(referencePreservation == ReferencePreservation.Preserve)
{
identifier = new ObjectIdentifier();
}
touchTypeMethod = disableStamping ? (Func<Type, int>)TouchAndWriteTypeIdWithSimpleStamp : TouchAndWriteTypeIdWithFullStamp;
objectsWrittenInline = new HashSet<int>();
}