@@ -14,7 +14,8 @@ internal class TypeMappingWriter
1414 {
1515 private readonly Type _type ;
1616 private readonly PropertyNameResolver _propertyNameResolver = new PropertyNameResolver ( ) ;
17- private readonly IConnectionSettings _connectionSettings ;
17+ private readonly IConnectionSettings _connectionSettings ;
18+ private readonly ElasticSerializer _elasticSerializer ;
1819
1920 private int MaxRecursion { get ; set ; }
2021 private TypeNameMarker TypeName { get ; set ; }
@@ -30,6 +31,8 @@ public TypeMappingWriter(Type t, TypeNameMarker typeName, IConnectionSettings co
3031
3132 this . SeenTypes = new ConcurrentDictionary < Type , int > ( ) ;
3233 this . SeenTypes . TryAdd ( t , 0 ) ;
34+
35+ this . _elasticSerializer = new ElasticSerializer ( this . _connectionSettings ) ;
3336 }
3437 internal TypeMappingWriter ( Type t , string typeName , IConnectionSettings connectionSettings , int maxRecursion , ConcurrentDictionary < Type , int > seenTypes )
3538 {
@@ -39,6 +42,8 @@ internal TypeMappingWriter(Type t, string typeName, IConnectionSettings connecti
3942 this . TypeName = typeName ;
4043 this . MaxRecursion = maxRecursion ;
4144 this . SeenTypes = seenTypes ;
45+
46+ this . _elasticSerializer = new ElasticSerializer ( this . _connectionSettings ) ;
4247 }
4348
4449 internal JObject MapPropertiesFromAttributes ( )
@@ -67,21 +72,21 @@ internal RootObjectMapping RootObjectMappingFromAttributes()
6772 var json = JObject . Parse ( this . MapFromAttributes ( ) ) ;
6873
6974 var nestedJson = json . Properties ( ) . First ( ) . Value . ToString ( ) ;
70- return JsonConvert . DeserializeObject < RootObjectMapping > ( nestedJson ) ;
75+ return this . _elasticSerializer . Deserialize < RootObjectMapping > ( nestedJson ) ;
7176 }
7277 internal ObjectMapping ObjectMappingFromAttributes ( )
7378 {
7479 var json = JObject . Parse ( this . MapFromAttributes ( ) ) ;
7580
7681 var nestedJson = json . Properties ( ) . First ( ) . Value . ToString ( ) ;
77- return JsonConvert . DeserializeObject < ObjectMapping > ( nestedJson ) ;
82+ return this . _elasticSerializer . Deserialize < ObjectMapping > ( nestedJson ) ;
7883 }
7984 internal NestedObjectMapping NestedObjectMappingFromAttributes ( )
8085 {
8186 var json = JObject . Parse ( this . MapFromAttributes ( ) ) ;
8287
8388 var nestedJson = json . Properties ( ) . First ( ) . Value . ToString ( ) ;
84- return JsonConvert . DeserializeObject < NestedObjectMapping > ( nestedJson ) ;
89+ return this . _elasticSerializer . Deserialize < NestedObjectMapping > ( nestedJson ) ;
8590 }
8691 internal string MapFromAttributes ( )
8792 {
0 commit comments