1
私はちょうど私の正気を点検しています。これはsimpleinjector 3.3.2RegisterPerWebRequestは廃止されていますが、Lifestyle.Scopedを使用できますか?
Container.RegisterPerWebRequest<HttpContextBase>(() =>
{
var context = HttpContext.Current;
if (context == null && Container.IsVerifying) return new FakeHttpContext();
return new HttpContextWrapper(context);
});
Container.Verify();
を使用しています私のコードです...
RegisterPerWebRequestが廃止とマークされているしかし、私はこれが変化するのが正しい方法であるかどうかは100%を確認していません新しいコードベースを反映するコード。
Container.Options.DefaultScopedLifestyle = new WebRequestLifestyle();
//So we can inject HttpContextBase into any class
Container.Register<HttpContextBase>(() =>
{
var context = HttpContext.Current;
if (context == null && Container.IsVerifying)
return new FakeHttpContext();
return new HttpContextWrapper(context);
}, Lifestyle.Scoped);
ので、私の質問は、「私はRegisterPerWebRequest
を置き換えるためにLifestyle.Scoped
を使用すべきとあるように私はまだコードを使用することができますか?
Judging by the docs I should be doing it right