/// <inheritdoc /> public object Get(Type featureType) { if (featureType == typeof(IAspNetCoreFeature)) { if (feature == null) { feature = AspNetCoreFeature.FromHttpContext(Context); } return(feature); } return(BaseCollection?.Get(featureType)); }
/// <summary> /// Gets an <see cref="AspNetCoreFeature"/> wrapper from the specified <see cref="HttpContext"/> instance. /// </summary> /// <exception cref="ArgumentNullException"><paramref name="httpContext"/> is <c>null</c>.</exception> public static AspNetCoreFeature FromHttpContext(HttpContext httpContext) { if (httpContext == null) { throw new ArgumentNullException(nameof(httpContext)); } if (httpContext.Items.TryGetValue(jsonRpcAspNetCoreFeatureWrapperKey, out var feature) || feature == null) { feature = new AspNetCoreFeature(httpContext); httpContext.Items[jsonRpcAspNetCoreFeatureWrapperKey] = feature; } return((AspNetCoreFeature)feature); }