Skip to content

Commit 6bb5e7e

Browse files
committed
remove IDisposable from ITransport and IElasticClient, not needed
1 parent 16c5cb2 commit 6bb5e7e

File tree

7 files changed

+147
-208
lines changed

7 files changed

+147
-208
lines changed

Diff for: src/Elasticsearch.Net/Transport/ITransport.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace Elasticsearch.Net
55
{
6-
public interface ITransport<out TConnectionSettings> : IDisposable
6+
public interface ITransport<out TConnectionSettings>
77
where TConnectionSettings : IConnectionConfigurationValues
88
{
99
TConnectionSettings Settings { get; }

Diff for: src/Elasticsearch.Net/Transport/Transport.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace Elasticsearch.Net
77
{
8-
public class Transport<TConnectionSettings> : ITransport<TConnectionSettings>, IDisposable
8+
public class Transport<TConnectionSettings> : ITransport<TConnectionSettings>
99
where TConnectionSettings : IConnectionConfigurationValues
1010
{
1111
//TODO should all of these be public?
@@ -187,8 +187,5 @@ private static async Task PingAsync(IRequestPipeline pipeline, Node node, List<P
187187
}
188188
}
189189

190-
void IDisposable.Dispose() => this.DisposeManagedResources();
191-
192-
protected virtual void DisposeManagedResources() { }
193190
}
194191
}

Diff for: src/Nest/CommonAbstractions/Infer/ElasticInferrer.cs

+144-143
Original file line numberDiff line numberDiff line change
@@ -1,143 +1,144 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Globalization;
4-
using System.Linq;
5-
6-
namespace Nest
7-
{
8-
public class ElasticInferrer
9-
{
10-
private readonly IConnectionSettingsValues _connectionSettings;
11-
12-
private IdResolver IdResolver { get; set; }
13-
private IndexNameResolver IndexNameResolver { get; set; }
14-
private TypeNameResolver TypeNameResolver { get; set; }
15-
private FieldResolver FieldResolver { get; set; }
16-
17-
public string DefaultIndex
18-
{
19-
get
20-
{
21-
var index = (this._connectionSettings == null) ? string.Empty : this._connectionSettings.DefaultIndex;
22-
return index.IsNullOrEmpty() ? "_all" : index;
23-
}
24-
}
25-
26-
public ElasticInferrer(IConnectionSettingsValues connectionSettings)
27-
{
28-
this._connectionSettings = connectionSettings;
29-
this.IdResolver = new IdResolver(this._connectionSettings);
30-
this.IndexNameResolver = new IndexNameResolver(this._connectionSettings);
31-
this.TypeNameResolver = new TypeNameResolver(this._connectionSettings);
32-
this.FieldResolver = new FieldResolver(this._connectionSettings);
33-
}
34-
35-
public string Field(Field field)
36-
{
37-
if (field.IsConditionless())
38-
return null;
39-
40-
var name = !field.Name.IsNullOrEmpty()
41-
? field.Name
42-
: field.Expression != null
43-
? this.FieldResolver.Resolve(field.Expression)
44-
: field.Property != null
45-
? this.FieldResolver.Resolve(field.Property)
46-
: null;
47-
48-
if (name == null)
49-
throw new ArgumentException("Could not resolve a field name");
50-
51-
if (field != null && field.Boost.HasValue)
52-
name += "^" + field.Boost.Value.ToString(CultureInfo.InvariantCulture);
53-
54-
return name;
55-
}
56-
57-
public string PropertyName(PropertyName property)
58-
{
59-
if (property.IsConditionless())
60-
return null;
61-
62-
var name = !property.Name.IsNullOrEmpty()
63-
? property.Name
64-
: property.Expression != null
65-
? this.FieldResolver.Resolve(property.Expression)
66-
: property.Property != null
67-
? this.FieldResolver.Resolve(property.Property)
68-
: null;
69-
70-
if (name == null)
71-
throw new ArgumentException("Could not resolve a property name");
72-
73-
return name;
74-
}
75-
76-
public string IndexName<T>() where T : class
77-
{
78-
return this.IndexName(typeof(T));
79-
}
80-
81-
public string IndexName(Type type)
82-
{
83-
return this.IndexNameResolver.GetIndexForType(type);
84-
}
85-
86-
public string IndexName(IndexName index)
87-
{
88-
if (index == null)
89-
return null;
90-
return index.Resolve(this._connectionSettings);
91-
}
92-
93-
public string IndexNames(params IndexName[] indices)
94-
{
95-
if (indices == null) return null;
96-
return string.Join(",", indices.Select(i => this.IndexNameResolver.GetIndexForType(i)));
97-
}
98-
99-
public string IndexNames(IEnumerable<IndexName> indices)
100-
{
101-
return !indices.HasAny() ? null : this.IndexNames(indices.ToArray());
102-
}
103-
104-
public string Id<T>(T obj) where T : class
105-
{
106-
if (obj == null) return null;
107-
108-
return this.IdResolver.GetIdFor(obj);
109-
}
110-
111-
public string Id(Type objType, object obj)
112-
{
113-
if (obj == null) return null;
114-
115-
return this.IdResolver.GetIdFor(objType, obj);
116-
}
117-
public string TypeName<T>() where T : class
118-
{
119-
return this.TypeName(typeof(T));
120-
}
121-
public string TypeName(Type t)
122-
{
123-
return t == null ? null : this.TypeNameResolver.GetTypeNameFor(t);
124-
}
125-
126-
public string TypeNames(params TypeName[] typeNames)
127-
{
128-
return typeNames == null
129-
? null
130-
: string.Join(",", typeNames.Select(t => this.TypeNameResolver.GetTypeNameFor(t)));
131-
}
132-
133-
public string TypeNames(IEnumerable<TypeName> typeNames)
134-
{
135-
return !typeNames.HasAny() ? null : this.TypeNames(typeNames.ToArray());
136-
}
137-
138-
public string TypeName(TypeName type)
139-
{
140-
return type == null ? null : this.TypeNameResolver.GetTypeNameFor(type);
141-
}
142-
}
143-
}
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Globalization;
4+
using System.Linq;
5+
6+
namespace Nest
7+
{
8+
public class ElasticInferrer
9+
{
10+
private readonly IConnectionSettingsValues _connectionSettings;
11+
12+
private IdResolver IdResolver { get; set; }
13+
private IndexNameResolver IndexNameResolver { get; set; }
14+
private TypeNameResolver TypeNameResolver { get; set; }
15+
private FieldResolver FieldResolver { get; set; }
16+
17+
public string DefaultIndex
18+
{
19+
get
20+
{
21+
var index = (this._connectionSettings == null) ? string.Empty : this._connectionSettings.DefaultIndex;
22+
return index.IsNullOrEmpty() ? "_all" : index;
23+
}
24+
}
25+
26+
public ElasticInferrer(IConnectionSettingsValues connectionSettings)
27+
{
28+
this._connectionSettings = connectionSettings;
29+
this.IdResolver = new IdResolver(this._connectionSettings);
30+
this.IndexNameResolver = new IndexNameResolver(this._connectionSettings);
31+
this.TypeNameResolver = new TypeNameResolver(this._connectionSettings);
32+
this.FieldResolver = new FieldResolver(this._connectionSettings);
33+
}
34+
35+
public string Field(Field field)
36+
{
37+
if (field.IsConditionless())
38+
return null;
39+
40+
var name = !field.Name.IsNullOrEmpty()
41+
? field.Name
42+
: field.Expression != null
43+
? this.FieldResolver.Resolve(field.Expression)
44+
: field.Property != null
45+
? this.FieldResolver.Resolve(field.Property)
46+
: null;
47+
48+
if (name == null)
49+
throw new ArgumentException("Could not resolve a field name");
50+
51+
if (field != null && field.Boost.HasValue)
52+
name += "^" + field.Boost.Value.ToString(CultureInfo.InvariantCulture);
53+
54+
return name;
55+
}
56+
57+
public string PropertyName(PropertyName property)
58+
{
59+
if (property.IsConditionless())
60+
return null;
61+
62+
var name = !property.Name.IsNullOrEmpty()
63+
? property.Name
64+
: property.Expression != null
65+
? this.FieldResolver.Resolve(property.Expression)
66+
: property.Property != null
67+
? this.FieldResolver.Resolve(property.Property)
68+
: null;
69+
70+
if (name == null)
71+
throw new ArgumentException("Could not resolve a property name");
72+
73+
return name;
74+
}
75+
76+
public string IndexName<T>() where T : class
77+
{
78+
return this.IndexName(typeof(T));
79+
}
80+
81+
public string IndexName(Type type)
82+
{
83+
return this.IndexNameResolver.GetIndexForType(type);
84+
}
85+
86+
public string IndexName(IndexName index)
87+
{
88+
if (index == null)
89+
return null;
90+
return index.Resolve(this._connectionSettings);
91+
}
92+
93+
public string IndexNames(params IndexName[] indices)
94+
{
95+
if (indices == null) return null;
96+
return string.Join(",", indices.Select(i => this.IndexNameResolver.GetIndexForType(i)));
97+
}
98+
99+
public string IndexNames(IEnumerable<IndexName> indices)
100+
{
101+
return !indices.HasAny() ? null : this.IndexNames(indices.ToArray());
102+
}
103+
104+
public string Id<T>(T obj) where T : class
105+
{
106+
if (obj == null) return null;
107+
108+
return this.IdResolver.GetIdFor(obj);
109+
}
110+
111+
public string Id(Type objType, object obj)
112+
{
113+
if (obj == null) return null;
114+
115+
return this.IdResolver.GetIdFor(objType, obj);
116+
}
117+
118+
public string TypeName<T>() where T : class
119+
{
120+
return this.TypeName(typeof(T));
121+
}
122+
public string TypeName(Type t)
123+
{
124+
return t == null ? null : this.TypeNameResolver.GetTypeNameFor(t);
125+
}
126+
127+
public string TypeNames(params TypeName[] typeNames)
128+
{
129+
return typeNames == null
130+
? null
131+
: string.Join(",", typeNames.Select(t => this.TypeNameResolver.GetTypeNameFor(t)));
132+
}
133+
134+
public string TypeNames(IEnumerable<TypeName> typeNames)
135+
{
136+
return !typeNames.HasAny() ? null : this.TypeNames(typeNames.ToArray());
137+
}
138+
139+
public string TypeName(TypeName type)
140+
{
141+
return type == null ? null : this.TypeNameResolver.GetTypeNameFor(type);
142+
}
143+
}
144+
}

Diff for: src/Nest/CommonAbstractions/Infer/IndexName/IndexNameResolver.cs

-5
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ public IndexNameResolver(IConnectionSettingsValues connectionSettings)
1212
this._connectionSettings = connectionSettings;
1313
}
1414

15-
public string GetIndexForType<T>()
16-
{
17-
return this.GetIndexForType(typeof(T));
18-
}
19-
2015
public string GetIndexForType(Type type)
2116
{
2217
var defaultIndices = this._connectionSettings.DefaultIndices;

Diff for: src/Nest/ElasticClient.cs

-7
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,5 @@ private TRequest ForceConfiguration<TRequest, TParams>(TRequest request, Action<
9898
return request;
9999
}
100100

101-
void IDisposable.Dispose() => this.DisposeManagedResources();
102-
103-
protected virtual void DisposeManagedResources()
104-
{
105-
IDisposable transport = this.Transport;
106-
transport?.Dispose();
107-
}
108101
}
109102
}

Diff for: src/Nest/IElasticClient.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace Nest
55
{
6-
public partial interface IElasticClient : IDisposable
6+
public partial interface IElasticClient
77
{
88
IConnectionSettingsValues ConnectionSettings { get; }
99
IElasticsearchSerializer Serializer { get; }

0 commit comments

Comments
 (0)