Esempio 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"
            };
            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()
        {
            var alwaysFeatures = new[]
            {
                "IHttpRequestFeature",
                "IHttpResponseFeature",
                "IResponseBodyPipeFeature",
                "IRequestBodyPipeFeature",
                "IHttpRequestIdentifierFeature",
                "IServiceProvidersFeature",
                "IHttpRequestLifetimeFeature",
                "IHttpConnectionFeature",
            };

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

            var sometimesFeatures = new[]
            {
                "IHttpUpgradeFeature",
                "IHttp2StreamIdFeature",
                "IHttpResponseTrailersFeature",
                "IResponseCookiesFeature",
                "IItemsFeature",
                "ITlsConnectionFeature",
                "IHttpWebSocketFeature",
                "ISessionFeature",
                "IHttpMaxRequestBodySizeFeature",
                "IHttpMinRequestBodyDataRateFeature",
                "IHttpMinResponseDataRateFeature",
                "IHttpBodyControlFeature",
                "IHttpResponseStartFeature"
            };

            var rareFeatures = new[]
            {
                "IHttpSendFileFeature",
            };

            var allFeatures = alwaysFeatures
                              .Concat(commonFeatures)
                              .Concat(sometimesFeatures)
                              .Concat(rareFeatures)
                              .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",
                "IResponseBodyPipeFeature",
                "IRequestBodyPipeFeature",
                "IHttpUpgradeFeature",
                "IHttpRequestIdentifierFeature",
                "IHttpRequestLifetimeFeature",
                "IHttpConnectionFeature",
                "IHttpMaxRequestBodySizeFeature",
                "IHttpBodyControlFeature",
                "IHttpResponseStartFeature"
            };

            var usings = $@"
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"));
        }