@@ -14,7 +14,8 @@ internal class TypeMappingWriter
14
14
{
15
15
private readonly Type _type ;
16
16
private readonly PropertyNameResolver _propertyNameResolver = new PropertyNameResolver ( ) ;
17
- private readonly IConnectionSettings _connectionSettings ;
17
+ private readonly IConnectionSettings _connectionSettings ;
18
+ private readonly ElasticSerializer _elasticSerializer ;
18
19
19
20
private int MaxRecursion { get ; set ; }
20
21
private TypeNameMarker TypeName { get ; set ; }
@@ -30,6 +31,8 @@ public TypeMappingWriter(Type t, TypeNameMarker typeName, IConnectionSettings co
30
31
31
32
this . SeenTypes = new ConcurrentDictionary < Type , int > ( ) ;
32
33
this . SeenTypes . TryAdd ( t , 0 ) ;
34
+
35
+ this . _elasticSerializer = new ElasticSerializer ( this . _connectionSettings ) ;
33
36
}
34
37
internal TypeMappingWriter ( Type t , string typeName , IConnectionSettings connectionSettings , int maxRecursion , ConcurrentDictionary < Type , int > seenTypes )
35
38
{
@@ -39,6 +42,8 @@ internal TypeMappingWriter(Type t, string typeName, IConnectionSettings connecti
39
42
this . TypeName = typeName ;
40
43
this . MaxRecursion = maxRecursion ;
41
44
this . SeenTypes = seenTypes ;
45
+
46
+ this . _elasticSerializer = new ElasticSerializer ( this . _connectionSettings ) ;
42
47
}
43
48
44
49
internal JObject MapPropertiesFromAttributes ( )
@@ -67,21 +72,21 @@ internal RootObjectMapping RootObjectMappingFromAttributes()
67
72
var json = JObject . Parse ( this . MapFromAttributes ( ) ) ;
68
73
69
74
var nestedJson = json . Properties ( ) . First ( ) . Value . ToString ( ) ;
70
- return JsonConvert . DeserializeObject < RootObjectMapping > ( nestedJson ) ;
75
+ return this . _elasticSerializer . Deserialize < RootObjectMapping > ( nestedJson ) ;
71
76
}
72
77
internal ObjectMapping ObjectMappingFromAttributes ( )
73
78
{
74
79
var json = JObject . Parse ( this . MapFromAttributes ( ) ) ;
75
80
76
81
var nestedJson = json . Properties ( ) . First ( ) . Value . ToString ( ) ;
77
- return JsonConvert . DeserializeObject < ObjectMapping > ( nestedJson ) ;
82
+ return this . _elasticSerializer . Deserialize < ObjectMapping > ( nestedJson ) ;
78
83
}
79
84
internal NestedObjectMapping NestedObjectMappingFromAttributes ( )
80
85
{
81
86
var json = JObject . Parse ( this . MapFromAttributes ( ) ) ;
82
87
83
88
var nestedJson = json . Properties ( ) . First ( ) . Value . ToString ( ) ;
84
- return JsonConvert . DeserializeObject < NestedObjectMapping > ( nestedJson ) ;
89
+ return this . _elasticSerializer . Deserialize < NestedObjectMapping > ( nestedJson ) ;
85
90
}
86
91
internal string MapFromAttributes ( )
87
92
{
0 commit comments