Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. public interface IUserContext {
  2. User CurrentUser { get; }
  3. }
  4.  
  5. container.Register<IUserContext>(() => {
  6. User user = null;
  7. try {
  8. user = HttpContext.Current?.Session[USER_CONTEXT] as IUser;
  9. }
  10. catch { }
  11.  
  12. return new UserContext(user);
  13. });
  14.  
  15. public static Func<User> UserContext { get; set; }
  16.  
  17. using (container.BeginLifetimeScope()) {
  18. .....
  19. var user = GetUserContext(message);
  20. UserContextInitializer.UserContext = () => new UserContext(user);
  21. .....
  22. }
  23.  
  24. container.Register<IUserContext>(() => UserContextInitializer.UserContext);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement