Ejemplo n.º 1
0
    public static string GenerateFile()
    {
        // NOTE: This list MUST always match the set of feature interfaces implemented by TransportConnectionBase.
        // See also: shared/TransportConnectionBase.FeatureCollection.cs
        var allFeatures = new[]
        {
            "IConnectionIdFeature",
            "IConnectionTransportFeature",
            "IConnectionItemsFeature",
            "IMemoryPoolFeature",
            "IConnectionLifetimeFeature",
            "IProtocolErrorCodeFeature",
            "ITlsConnectionFeature"
        };
        var implementedFeatures = new[]
        {
            "IConnectionIdFeature",
            "IConnectionItemsFeature",
            "IMemoryPoolFeature",
            "IConnectionLifetimeFeature"
        };

        var usings = $@"
using Microsoft.AspNetCore.Connections.Features;
using Microsoft.AspNetCore.Http.Features;";

        return(FeatureCollectionGenerator.GenerateFile(
                   namespaceName: "Microsoft.AspNetCore.Connections",
                   className: "TransportMultiplexedConnection",
                   allFeatures: allFeatures,
                   implementedFeatures: implementedFeatures,
                   extraUsings: usings,
                   fallbackFeatures: null));
    }
        public static string GenerateFile()
        {
            // NOTE: This list MUST always match the set of feature interfaces implemented by TransportConnection.
            // See also: src/Kestrel.Transport.Abstractions/Internal/TransportConnection.FeatureCollection.cs
            var features = new[]
            {
                "IConnectionIdFeature",
                "IConnectionTransportFeature",
                "IConnectionItemsFeature",
                "IMemoryPoolFeature",
                "IConnectionLifetimeFeature"
            };

            var usings = $@"
using Microsoft.AspNetCore.Connections.Features;
using Microsoft.AspNetCore.Http.Features;";

            return(FeatureCollectionGenerator.GenerateFile(
                       namespaceName: "Microsoft.AspNetCore.Connections",
                       className: "TransportConnection",
                       allFeatures: features,
                       implementedFeatures: features,
                       extraUsings: usings,
                       fallbackFeatures: null));
        }
    public static string GenerateFile()
    {
        var alwaysFeatures = new[]
        {
            "IHttpRequestFeature",
            "IHttpResponseFeature",
            "IHttpResponseBodyFeature",
            "IRouteValuesFeature",
            "IEndpointFeature",
            "IServiceProvidersFeature",
            "IHttpActivityFeature"
        };

        var commonFeatures = new[]
        {
            "IItemsFeature",
            "IQueryFeature",
            "IRequestBodyPipeFeature",
            "IFormFeature",
            "IHttpAuthenticationFeature",
            "IHttpRequestIdentifierFeature",
        };

        var sometimesFeatures = new[]
        {
            "IHttpConnectionFeature",
            "ISessionFeature",
            "IResponseCookiesFeature",
            "IHttpRequestTrailersFeature",
            "IHttpResponseTrailersFeature",
            "ITlsConnectionFeature",
            "IHttpUpgradeFeature",
            "IHttpWebSocketFeature",
            "IBadRequestExceptionFeature"
        };
        var maybeFeatures = new[]
        {
            "IHttp2StreamIdFeature",
            "IHttpRequestLifetimeFeature",
            "IHttpMaxRequestBodySizeFeature",
            "IHttpMinRequestBodyDataRateFeature",
            "IHttpMinResponseDataRateFeature",
            "IHttpBodyControlFeature",
            "IHttpRequestBodyDetectionFeature",
            "IHttpResetFeature",
            "IPersistentStateFeature"
        };

        var allFeatures = alwaysFeatures
                          .Concat(commonFeatures)
                          .Concat(sometimesFeatures)
                          .Concat(maybeFeatures)
                          .ToArray();

        // NOTE: This list MUST always match the set of feature interfaces implemented by HttpProtocol.
        // See also: src/Kestrel.Core/Internal/Http/HttpProtocol.FeatureCollection.cs
        var implementedFeatures = new[]
        {
            "IHttpRequestFeature",
            "IHttpResponseFeature",
            "IHttpResponseBodyFeature",
            "IRouteValuesFeature",
            "IEndpointFeature",
            "IHttpRequestIdentifierFeature",
            "IHttpRequestTrailersFeature",
            "IHttpUpgradeFeature",
            "IRequestBodyPipeFeature",
            "IHttpConnectionFeature",
            "IHttpRequestLifetimeFeature",
            "IHttpBodyControlFeature",
            "IHttpMaxRequestBodySizeFeature",
            "IHttpRequestBodyDetectionFeature",
            "IBadRequestExceptionFeature"
        };

        var usings = $@"
using Microsoft.AspNetCore.Connections.Features;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Http.Features.Authentication;
using Microsoft.AspNetCore.Server.Kestrel.Core.Features;";

        return(FeatureCollectionGenerator.GenerateFile(
                   namespaceName: "Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http",
                   className: "HttpProtocol",
                   allFeatures: allFeatures,
                   implementedFeatures: implementedFeatures,
                   extraUsings: usings,
                   fallbackFeatures: "ConnectionFeatures"));
    }