@@ -112,69 +112,101 @@ IDuplexPipe IConnectionTransportFeature.Application
112
112
113
113
object IFeatureCollection . this [ Type key ]
114
114
{
115
- get => FastFeatureGet ( key ) ;
116
- set => FastFeatureSet ( key , value ) ;
117
- }
115
+ get
116
+ {
117
+ if ( key == IHttpConnectionFeatureType )
118
+ {
119
+ return _currentIHttpConnectionFeature ;
120
+ }
118
121
119
- TFeature IFeatureCollection . Get < TFeature > ( )
120
- {
121
- return ( TFeature ) FastFeatureGet ( typeof ( TFeature ) ) ;
122
- }
122
+ if ( key == IConnectionIdFeatureType )
123
+ {
124
+ return _currentIConnectionIdFeature ;
125
+ }
123
126
124
- void IFeatureCollection . Set < TFeature > ( TFeature instance )
125
- {
126
- FastFeatureSet ( typeof ( TFeature ) , instance ) ;
127
- }
127
+ if ( key == IConnectionTransportFeatureType )
128
+ {
129
+ return _currentIConnectionTransportFeature ;
130
+ }
128
131
129
- IEnumerator < KeyValuePair < Type , object > > IEnumerable < KeyValuePair < Type , object > > . GetEnumerator ( ) => FastEnumerable ( ) . GetEnumerator ( ) ;
132
+ if ( MaybeExtra != null )
133
+ {
134
+ return ExtraFeatureGet ( key ) ;
135
+ }
130
136
131
- IEnumerator IEnumerable . GetEnumerator ( ) => FastEnumerable ( ) . GetEnumerator ( ) ;
137
+ return null ;
138
+ }
139
+ set
140
+ {
141
+ _featureRevision ++ ;
132
142
133
- private object FastFeatureGet ( Type key )
143
+ if ( key == IHttpConnectionFeatureType )
144
+ {
145
+ _currentIHttpConnectionFeature = value ;
146
+ }
147
+ else if ( key == IConnectionIdFeatureType )
148
+ {
149
+ _currentIConnectionIdFeature = value ;
150
+ }
151
+ else if ( key == IConnectionTransportFeatureType )
152
+ {
153
+ _currentIConnectionTransportFeature = value ;
154
+ }
155
+ else
156
+ {
157
+ ExtraFeatureSet ( key , value ) ;
158
+ }
159
+ }
160
+ }
161
+
162
+ TFeature IFeatureCollection . Get < TFeature > ( )
134
163
{
135
- if ( key == IHttpConnectionFeatureType )
164
+ if ( typeof ( TFeature ) == typeof ( IHttpConnectionFeature ) )
136
165
{
137
- return _currentIHttpConnectionFeature ;
166
+ return ( TFeature ) _currentIHttpConnectionFeature ;
138
167
}
139
-
140
- if ( key == IConnectionIdFeatureType )
168
+ else if ( typeof ( TFeature ) == typeof ( IConnectionIdFeature ) )
141
169
{
142
- return _currentIConnectionIdFeature ;
170
+ return ( TFeature ) _currentIConnectionIdFeature ;
143
171
}
144
-
145
- if ( key == IConnectionTransportFeatureType )
172
+ else if ( typeof ( TFeature ) == typeof ( IConnectionTransportFeature ) )
146
173
{
147
- return _currentIConnectionTransportFeature ;
174
+ return ( TFeature ) _currentIConnectionTransportFeature ;
175
+ }
176
+ else if ( MaybeExtra != null )
177
+ {
178
+ return ( TFeature ) ExtraFeatureGet ( typeof ( TFeature ) ) ;
148
179
}
149
180
150
- return ExtraFeatureGet ( key ) ;
181
+ return default ;
151
182
}
152
183
153
- private void FastFeatureSet ( Type key , object feature )
184
+ void IFeatureCollection . Set < TFeature > ( TFeature instance )
154
185
{
155
186
_featureRevision ++ ;
156
187
157
- if ( key == IHttpConnectionFeatureType )
188
+ if ( typeof ( TFeature ) == typeof ( IHttpConnectionFeature ) )
158
189
{
159
- _currentIHttpConnectionFeature = feature ;
160
- return ;
190
+ _currentIHttpConnectionFeature = instance ;
161
191
}
162
-
163
- if ( key == IConnectionIdFeatureType )
192
+ else if ( typeof ( TFeature ) == typeof ( IConnectionIdFeature ) )
164
193
{
165
- _currentIConnectionIdFeature = feature ;
166
- return ;
194
+ _currentIConnectionIdFeature = instance ;
167
195
}
168
-
169
- if ( key == IConnectionTransportFeatureType )
196
+ else if ( typeof ( TFeature ) == typeof ( IConnectionTransportFeature ) )
170
197
{
171
- _currentIConnectionTransportFeature = feature ;
172
- return ;
198
+ _currentIConnectionTransportFeature = instance ;
199
+ }
200
+ else
201
+ {
202
+ ExtraFeatureSet ( typeof ( TFeature ) , instance ) ;
173
203
}
174
-
175
- ExtraFeatureSet ( key , feature ) ;
176
204
}
177
205
206
+ IEnumerator < KeyValuePair < Type , object > > IEnumerable < KeyValuePair < Type , object > > . GetEnumerator ( ) => FastEnumerable ( ) . GetEnumerator ( ) ;
207
+
208
+ IEnumerator IEnumerable . GetEnumerator ( ) => FastEnumerable ( ) . GetEnumerator ( ) ;
209
+
178
210
private IEnumerable < KeyValuePair < Type , object > > FastEnumerable ( )
179
211
{
180
212
if ( _currentIHttpConnectionFeature != null )
0 commit comments