public ObjectWriter(Stream stream, Action<object> preSerializationCallback = null, Action<object> postSerializationCallback = null, IDictionary<Type, Action<ObjectWriter, PrimitiveWriter, object>> writeMethods = null, SwapList surrogatesForObjects = null, bool isGenerating = true, bool treatCollectionAsUserObject = false, bool useBuffering = true, bool disableStamping = false, ReferencePreservation referencePreservation = ReferencePreservation.Preserve) { if(surrogatesForObjects == null) { surrogatesForObjects = new SwapList(); } currentlyWrittenTypes = new Stack<Type>(); this.writeMethods = writeMethods ?? new Dictionary<Type, Action<ObjectWriter, PrimitiveWriter, object>>(); postSerializationHooks = new List<Action>(); this.isGenerating = isGenerating; this.treatCollectionAsUserObject = treatCollectionAsUserObject; this.surrogatesForObjects = surrogatesForObjects; types = new IdentifiedElementsDictionary<TypeDescriptor>(this); Methods = new IdentifiedElementsDictionary<MethodDescriptor>(this); Assemblies = new IdentifiedElementsDictionary<AssemblyDescriptor>(this); Modules = new IdentifiedElementsDictionary<ModuleDescriptor>(this); this.preSerializationCallback = preSerializationCallback; this.postSerializationCallback = postSerializationCallback; writer = new PrimitiveWriter(stream, useBuffering); this.referencePreservation = referencePreservation; if(referencePreservation == ReferencePreservation.Preserve) { identifier = new ObjectIdentifier(); } touchTypeMethod = disableStamping ? (Func<Type, int>)TouchAndWriteTypeIdWithSimpleStamp : TouchAndWriteTypeIdWithFullStamp; }
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>(); }