This repository was archived by the owner on Nov 20, 2018. It is now read-only.
File tree 1 file changed +14
-12
lines changed
src/Microsoft.AspNetCore.Http.Extensions
1 file changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -176,18 +176,19 @@ internal static T Get<T>(this IHeaderDictionary headers, string name)
176
176
}
177
177
178
178
object temp ;
179
- if ( KnownParsers . TryGetValue ( typeof ( T ) , out temp ) )
180
- {
181
- var func = ( Func < string , T > ) temp ;
182
- return func ( headers [ name ] ) ;
183
- }
184
-
185
179
var value = headers [ name ] ;
180
+
186
181
if ( StringValues . IsNullOrEmpty ( value ) )
187
182
{
188
183
return default ( T ) ;
189
184
}
190
185
186
+ if ( KnownParsers . TryGetValue ( typeof ( T ) , out temp ) )
187
+ {
188
+ var func = ( Func < string , T > ) temp ;
189
+ return func ( value ) ;
190
+ }
191
+
191
192
return GetViaReflection < T > ( value . ToString ( ) ) ;
192
193
}
193
194
@@ -199,18 +200,19 @@ internal static IList<T> GetList<T>(this IHeaderDictionary headers, string name)
199
200
}
200
201
201
202
object temp ;
202
- if ( KnownListParsers . TryGetValue ( typeof ( T ) , out temp ) )
203
- {
204
- var func = ( Func < IList < string > , IList < T > > ) temp ;
205
- return func ( headers [ name ] ) ;
206
- }
207
-
208
203
var values = headers [ name ] ;
204
+
209
205
if ( StringValues . IsNullOrEmpty ( values ) )
210
206
{
211
207
return null ;
212
208
}
213
209
210
+ if ( KnownListParsers . TryGetValue ( typeof ( T ) , out temp ) )
211
+ {
212
+ var func = ( Func < IList < string > , IList < T > > ) temp ;
213
+ return func ( values ) ;
214
+ }
215
+
214
216
return GetListViaReflection < T > ( values ) ;
215
217
}
216
218
You can’t perform that action at this time.
0 commit comments