3838using Polenter . Serialization . Deserializing ;
3939using Polenter . Serialization . Serializing ;
4040using System . Runtime . CompilerServices ;
41+ using System . Collections . Generic ;
4142
4243namespace Polenter . Serialization
4344{
@@ -51,6 +52,7 @@ public sealed class SharpSerializer
5152 private PropertyProvider _propertyProvider ;
5253 private string _rootName ;
5354 private IPropertySerializer _serializer ;
55+ private IEqualityComparer < object > _objectComparer ;
5456
5557 /// <summary>
5658 /// Standard Constructor. Default is Xml serializing
@@ -136,6 +138,19 @@ public string RootName
136138 set { _rootName = value ; }
137139 }
138140
141+ /// <summary>
142+ /// A Comparer, used to define objects with the same references
143+ /// </summary>
144+ public IEqualityComparer < object > ObjectComparer
145+ {
146+ get
147+ {
148+ if ( _objectComparer == null ) _objectComparer = EqualityComparer < object > . Default ;
149+ return _objectComparer ;
150+ }
151+ set { _objectComparer = value ; }
152+ }
153+
139154 /// <summary>
140155 /// Gets or sets the instance creator for creating objects.
141156 /// </summary>
@@ -255,7 +270,7 @@ public void Serialize(object data, Stream stream)
255270
256271 lock ( _syncObj )
257272 {
258- var factory = new PropertyFactory ( PropertyProvider ) ;
273+ var factory = new PropertyFactory ( PropertyProvider , ObjectComparer ) ;
259274
260275 Property property = factory . CreateProperty ( RootName , data ) ;
261276
0 commit comments