Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- interface IMyContext
- {
- string UserIP {get;}
- string UserAgent {get;}
- }
- interface IMyContextInitializer
- {
- void Init(string userIP, string userAgent);
- }
- class MyContext: IMyContext, IMyContextInitializer
- {
- ...
- }
- // на стерте где инициализируешь DI, добавляешь
- var ctx = new MyContext();
- RegisterScoped<IMyContext>(ctx);
- RegisterScoped<IMyContextInitializer>(ctx);
- // дельше пишешь свою midleware, где запрашиваешь IMyContextInitializer и через Init присваиваешь значения
- // потом просто инжектишь IMyContext где надо
Advertisement
Add Comment
Please, Sign In to add comment