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