@@ -27,6 +27,9 @@ internal partial class TransportConnection : IFeatureCollection,
27
27
internal protected IMemoryPoolFeature ? _currentIMemoryPoolFeature ;
28
28
internal protected IConnectionLifetimeFeature ? _currentIConnectionLifetimeFeature ;
29
29
30
+ // Other reserved feature slots
31
+ internal protected IConnectionSocketFeature ? _currentIConnectionSocketFeature ;
32
+
30
33
private int _featureRevision ;
31
34
32
35
private List < KeyValuePair < Type , object > > ? MaybeExtra ;
@@ -39,6 +42,7 @@ private void FastReset()
39
42
_currentIMemoryPoolFeature = this ;
40
43
_currentIConnectionLifetimeFeature = this ;
41
44
45
+ _currentIConnectionSocketFeature = null ;
42
46
}
43
47
44
48
// Internal for testing
@@ -130,6 +134,10 @@ private void ExtraFeatureSet(Type key, object? value)
130
134
{
131
135
feature = _currentIConnectionLifetimeFeature ;
132
136
}
137
+ else if ( key == typeof ( IConnectionSocketFeature ) )
138
+ {
139
+ feature = _currentIConnectionSocketFeature ;
140
+ }
133
141
else if ( MaybeExtra != null )
134
142
{
135
143
feature = ExtraFeatureGet ( key ) ;
@@ -162,6 +170,10 @@ private void ExtraFeatureSet(Type key, object? value)
162
170
{
163
171
_currentIConnectionLifetimeFeature = ( IConnectionLifetimeFeature ? ) value ;
164
172
}
173
+ else if ( key == typeof ( IConnectionSocketFeature ) )
174
+ {
175
+ _currentIConnectionSocketFeature = ( IConnectionSocketFeature ? ) value ;
176
+ }
165
177
else
166
178
{
167
179
ExtraFeatureSet ( key , value ) ;
@@ -196,6 +208,10 @@ private void ExtraFeatureSet(Type key, object? value)
196
208
{
197
209
feature = Unsafe . As < IConnectionLifetimeFeature ? , TFeature ? > ( ref _currentIConnectionLifetimeFeature ) ;
198
210
}
211
+ else if ( typeof ( TFeature ) == typeof ( IConnectionSocketFeature ) )
212
+ {
213
+ feature = Unsafe . As < IConnectionSocketFeature ? , TFeature ? > ( ref _currentIConnectionSocketFeature ) ;
214
+ }
199
215
else if ( MaybeExtra != null )
200
216
{
201
217
feature = ( TFeature ? ) ( ExtraFeatureGet ( typeof ( TFeature ) ) ) ;
@@ -231,6 +247,10 @@ private void ExtraFeatureSet(Type key, object? value)
231
247
{
232
248
_currentIConnectionLifetimeFeature = Unsafe . As < TFeature ? , IConnectionLifetimeFeature ? > ( ref feature ) ;
233
249
}
250
+ else if ( typeof ( TFeature ) == typeof ( IConnectionSocketFeature ) )
251
+ {
252
+ _currentIConnectionSocketFeature = Unsafe . As < TFeature ? , IConnectionSocketFeature ? > ( ref feature ) ;
253
+ }
234
254
else
235
255
{
236
256
ExtraFeatureSet ( typeof ( TFeature ) , feature ) ;
@@ -259,6 +279,10 @@ private IEnumerable<KeyValuePair<Type, object>> FastEnumerable()
259
279
{
260
280
yield return new KeyValuePair < Type , object > ( typeof ( IConnectionLifetimeFeature ) , _currentIConnectionLifetimeFeature ) ;
261
281
}
282
+ if ( _currentIConnectionSocketFeature != null )
283
+ {
284
+ yield return new KeyValuePair < Type , object > ( typeof ( IConnectionSocketFeature ) , _currentIConnectionSocketFeature ) ;
285
+ }
262
286
263
287
if ( MaybeExtra != null )
264
288
{
0 commit comments