@@ -13,71 +13,29 @@ namespace Nest
1313{
1414 public partial class RawElasticClient : IRawElasticClient
1515 {
16- protected IConnection Connection { get ; set ; }
16+ public IConnection Connection { get ; protected set ; }
1717 public IConnectionSettings Settings { get ; protected set ; }
18+ public ElasticSerializer Serializer { get ; protected set ; }
1819
1920 public RawElasticClient ( IConnectionSettings settings )
2021 : this ( settings , new Connection ( settings ) )
2122 {
2223
2324 }
2425
25- internal readonly JsonSerializerSettings SerializationSettings ;
26- internal readonly JsonSerializerSettings IndexSerializationSettings ;
27- internal readonly PropertyNameResolver PropertyNameResolver ;
28- private readonly List < JsonConverter > _extraConverters = new List < JsonConverter > ( ) ;
29-
30- private readonly List < JsonConverter > _defaultConverters = new List < JsonConverter >
31- {
32- new IsoDateTimeConverter ( ) ,
33- new FacetConverter ( )
34- } ;
35-
36- private JsonSerializerSettings CreateSettings ( )
37- {
38- return new JsonSerializerSettings ( )
39- {
40- ContractResolver = new ElasticResolver ( this . Settings ) ,
41- NullValueHandling = NullValueHandling . Ignore ,
42- DefaultValueHandling = DefaultValueHandling . Include ,
43- Converters = _defaultConverters . Concat ( _extraConverters ) . ToList ( )
44- } ;
45- }
46- public void AddConverter ( JsonConverter converter )
47- {
48- this . IndexSerializationSettings . Converters . Add ( converter ) ;
49- this . SerializationSettings . Converters . Add ( converter ) ;
50- _extraConverters . Add ( converter ) ;
51- }
52-
53- public void ModifyJsonSerializationSettings ( Action < JsonSerializerSettings > modifier )
54- {
55- modifier ( this . IndexSerializationSettings ) ;
56- modifier ( this . SerializationSettings ) ;
57- }
58-
59- /// <summary>
60- /// serialize an object using the internal registered converters without camelcasing properties as is done
61- /// while indexing objects
62- /// </summary>
63- public string Serialize ( object @object )
64- {
65- return JsonConvert . SerializeObject ( @object , Formatting . Indented , this . SerializationSettings ) ;
66- }
67-
6826 public RawElasticClient ( IConnectionSettings settings , IConnection connection )
6927 {
7028 if ( settings == null )
7129 throw new ArgumentNullException ( "settings" ) ;
7230
7331 this . Settings = settings ;
7432 this . Connection = connection ;
33+ this . Serializer = new ElasticSerializer ( this . Settings ) ;
34+ }
7535
76- this . SerializationSettings = this . CreateSettings ( ) ;
77- var indexSettings = this . CreateSettings ( ) ;
78-
79- indexSettings . ContractResolver = new ElasticCamelCaseResolver ( this . Settings ) ;
80- this . IndexSerializationSettings = indexSettings ;
36+ public string Serialize ( object @object )
37+ {
38+ return this . Serializer . Serialize ( @object ) ;
8139 }
8240
8341 protected ConnectionStatus DoRequest ( string method , string path , object data = null , NameValueCollection queryString = null )
0 commit comments