vendredi 18 février 2022

why asp.net core use Feature for HttpRequest and HttpResponse? [closed]

For example, to represent Header, asp.net core uses HttpRequestFeature to get headers:

internal sealed class DefaultHttpRequest : HttpRequest {
   // ...
   private FeatureReferences<FeatureInterfaces> _features;
   private IHttpRequestFeature HttpRequestFeature => _features.Fetch(ref _features.Cache.Request, _nullRequestFeature)!;

   public override IHeaderDictionary Headers {
      get { return HttpRequestFeature.Headers; }
   }
}

so why not just design it directly as:

internal sealed class DefaultHttpRequest : HttpRequest {
   // ...
   private IHeaderDictionary headerDictionary = new HeaderDictionary();
  
   public override IHeaderDictionary Headers {
      get { return headerDictionary ; }
   }
}

why use an extra abstract layer HttpRequestFeature?

Aucun commentaire:

Enregistrer un commentaire