reuse typeof results in generated Frame code

This commit is contained in:
Nathan Anderson 2016-05-12 11:44:05 -07:00 committed by Stephen Halter
parent 185ad000bb
commit e1c64d2119
2 changed files with 34 additions and 34 deletions

View File

@ -63,67 +63,67 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
private object FastFeatureGet(Type key) private object FastFeatureGet(Type key)
{ {
if (key == typeof(global::Microsoft.AspNetCore.Http.Features.IHttpRequestFeature)) if (key == IHttpRequestFeatureType)
{ {
return _currentIHttpRequestFeature; return _currentIHttpRequestFeature;
} }
if (key == typeof(global::Microsoft.AspNetCore.Http.Features.IHttpResponseFeature)) if (key == IHttpResponseFeatureType)
{ {
return _currentIHttpResponseFeature; return _currentIHttpResponseFeature;
} }
if (key == typeof(global::Microsoft.AspNetCore.Http.Features.IHttpRequestIdentifierFeature)) if (key == IHttpRequestIdentifierFeatureType)
{ {
return _currentIHttpRequestIdentifierFeature; return _currentIHttpRequestIdentifierFeature;
} }
if (key == typeof(global::Microsoft.AspNetCore.Http.Features.IServiceProvidersFeature)) if (key == IServiceProvidersFeatureType)
{ {
return _currentIServiceProvidersFeature; return _currentIServiceProvidersFeature;
} }
if (key == typeof(global::Microsoft.AspNetCore.Http.Features.IHttpRequestLifetimeFeature)) if (key == IHttpRequestLifetimeFeatureType)
{ {
return _currentIHttpRequestLifetimeFeature; return _currentIHttpRequestLifetimeFeature;
} }
if (key == typeof(global::Microsoft.AspNetCore.Http.Features.IHttpConnectionFeature)) if (key == IHttpConnectionFeatureType)
{ {
return _currentIHttpConnectionFeature; return _currentIHttpConnectionFeature;
} }
if (key == typeof(global::Microsoft.AspNetCore.Http.Features.Authentication.IHttpAuthenticationFeature)) if (key == IHttpAuthenticationFeatureType)
{ {
return _currentIHttpAuthenticationFeature; return _currentIHttpAuthenticationFeature;
} }
if (key == typeof(global::Microsoft.AspNetCore.Http.Features.IQueryFeature)) if (key == IQueryFeatureType)
{ {
return _currentIQueryFeature; return _currentIQueryFeature;
} }
if (key == typeof(global::Microsoft.AspNetCore.Http.Features.IFormFeature)) if (key == IFormFeatureType)
{ {
return _currentIFormFeature; return _currentIFormFeature;
} }
if (key == typeof(global::Microsoft.AspNetCore.Http.Features.IHttpUpgradeFeature)) if (key == IHttpUpgradeFeatureType)
{ {
return _currentIHttpUpgradeFeature; return _currentIHttpUpgradeFeature;
} }
if (key == typeof(global::Microsoft.AspNetCore.Http.Features.IResponseCookiesFeature)) if (key == IResponseCookiesFeatureType)
{ {
return _currentIResponseCookiesFeature; return _currentIResponseCookiesFeature;
} }
if (key == typeof(global::Microsoft.AspNetCore.Http.Features.IItemsFeature)) if (key == IItemsFeatureType)
{ {
return _currentIItemsFeature; return _currentIItemsFeature;
} }
if (key == typeof(global::Microsoft.AspNetCore.Http.Features.ITlsConnectionFeature)) if (key == ITlsConnectionFeatureType)
{ {
return _currentITlsConnectionFeature; return _currentITlsConnectionFeature;
} }
if (key == typeof(global::Microsoft.AspNetCore.Http.Features.IHttpWebSocketFeature)) if (key == IHttpWebSocketFeatureType)
{ {
return _currentIHttpWebSocketFeature; return _currentIHttpWebSocketFeature;
} }
if (key == typeof(global::Microsoft.AspNetCore.Http.Features.ISessionFeature)) if (key == ISessionFeatureType)
{ {
return _currentISessionFeature; return _currentISessionFeature;
} }
if (key == typeof(global::Microsoft.AspNetCore.Http.Features.IHttpSendFileFeature)) if (key == IHttpSendFileFeatureType)
{ {
return _currentIHttpSendFileFeature; return _currentIHttpSendFileFeature;
} }
@ -134,82 +134,82 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
{ {
_featureRevision++; _featureRevision++;
if (key == typeof(global::Microsoft.AspNetCore.Http.Features.IHttpRequestFeature)) if (key == IHttpRequestFeatureType)
{ {
_currentIHttpRequestFeature = feature; _currentIHttpRequestFeature = feature;
return; return;
} }
if (key == typeof(global::Microsoft.AspNetCore.Http.Features.IHttpResponseFeature)) if (key == IHttpResponseFeatureType)
{ {
_currentIHttpResponseFeature = feature; _currentIHttpResponseFeature = feature;
return; return;
} }
if (key == typeof(global::Microsoft.AspNetCore.Http.Features.IHttpRequestIdentifierFeature)) if (key == IHttpRequestIdentifierFeatureType)
{ {
_currentIHttpRequestIdentifierFeature = feature; _currentIHttpRequestIdentifierFeature = feature;
return; return;
} }
if (key == typeof(global::Microsoft.AspNetCore.Http.Features.IServiceProvidersFeature)) if (key == IServiceProvidersFeatureType)
{ {
_currentIServiceProvidersFeature = feature; _currentIServiceProvidersFeature = feature;
return; return;
} }
if (key == typeof(global::Microsoft.AspNetCore.Http.Features.IHttpRequestLifetimeFeature)) if (key == IHttpRequestLifetimeFeatureType)
{ {
_currentIHttpRequestLifetimeFeature = feature; _currentIHttpRequestLifetimeFeature = feature;
return; return;
} }
if (key == typeof(global::Microsoft.AspNetCore.Http.Features.IHttpConnectionFeature)) if (key == IHttpConnectionFeatureType)
{ {
_currentIHttpConnectionFeature = feature; _currentIHttpConnectionFeature = feature;
return; return;
} }
if (key == typeof(global::Microsoft.AspNetCore.Http.Features.Authentication.IHttpAuthenticationFeature)) if (key == IHttpAuthenticationFeatureType)
{ {
_currentIHttpAuthenticationFeature = feature; _currentIHttpAuthenticationFeature = feature;
return; return;
} }
if (key == typeof(global::Microsoft.AspNetCore.Http.Features.IQueryFeature)) if (key == IQueryFeatureType)
{ {
_currentIQueryFeature = feature; _currentIQueryFeature = feature;
return; return;
} }
if (key == typeof(global::Microsoft.AspNetCore.Http.Features.IFormFeature)) if (key == IFormFeatureType)
{ {
_currentIFormFeature = feature; _currentIFormFeature = feature;
return; return;
} }
if (key == typeof(global::Microsoft.AspNetCore.Http.Features.IHttpUpgradeFeature)) if (key == IHttpUpgradeFeatureType)
{ {
_currentIHttpUpgradeFeature = feature; _currentIHttpUpgradeFeature = feature;
return; return;
} }
if (key == typeof(global::Microsoft.AspNetCore.Http.Features.IResponseCookiesFeature)) if (key == IResponseCookiesFeatureType)
{ {
_currentIResponseCookiesFeature = feature; _currentIResponseCookiesFeature = feature;
return; return;
} }
if (key == typeof(global::Microsoft.AspNetCore.Http.Features.IItemsFeature)) if (key == IItemsFeatureType)
{ {
_currentIItemsFeature = feature; _currentIItemsFeature = feature;
return; return;
} }
if (key == typeof(global::Microsoft.AspNetCore.Http.Features.ITlsConnectionFeature)) if (key == ITlsConnectionFeatureType)
{ {
_currentITlsConnectionFeature = feature; _currentITlsConnectionFeature = feature;
return; return;
} }
if (key == typeof(global::Microsoft.AspNetCore.Http.Features.IHttpWebSocketFeature)) if (key == IHttpWebSocketFeatureType)
{ {
_currentIHttpWebSocketFeature = feature; _currentIHttpWebSocketFeature = feature;
return; return;
} }
if (key == typeof(global::Microsoft.AspNetCore.Http.Features.ISessionFeature)) if (key == ISessionFeatureType)
{ {
_currentISessionFeature = feature; _currentISessionFeature = feature;
return; return;
} }
if (key == typeof(global::Microsoft.AspNetCore.Http.Features.IHttpSendFileFeature)) if (key == IHttpSendFileFeatureType)
{ {
_currentIHttpSendFileFeature = feature; _currentIHttpSendFileFeature = feature;
return; return;

View File

@ -83,7 +83,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
private object FastFeatureGet(Type key) private object FastFeatureGet(Type key)
{{{Each(allFeatures, feature => $@" {{{Each(allFeatures, feature => $@"
if (key == typeof(global::{feature.FullName})) if (key == {feature.Name}Type)
{{ {{
return _current{feature.Name}; return _current{feature.Name};
}}")} }}")}
@ -94,7 +94,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
{{ {{
_featureRevision++; _featureRevision++;
{Each(allFeatures, feature => $@" {Each(allFeatures, feature => $@"
if (key == typeof(global::{feature.FullName})) if (key == {feature.Name}Type)
{{ {{
_current{feature.Name} = feature; _current{feature.Name} = feature;
return; return;