2013-07-04 43 views
1
public class SteamUserSession : AuthUserSession 
{ 
     public UserService UserService { get; set; } //Should be autowired 

     public long SteamID { get; private set; } 

     public User CurrentUser { get; private set; } 

     public Player SteamProfile { get; private set; } 

     public List<SteamGame> OwnedApps { get; private set; } 

     public override void OnAuthenticated(
      IServiceBase authService, 
      IAuthSession session, 
      IOAuthTokens tokens, 
      Dictionary<string, string> authInfo) 
     { 
      base.OnAuthenticated(authService, session, tokens, authInfo); 
      // access servicestack user server and load properies for session here 
      CurrentUser = (User)UserService.Get(new GetUser(SteamID)); 
     } 
} 

回答

2

AuthUserSession只是一個模式多數民衆贊成依然存在,從數據存儲檢索到的,也就是說,它不是一個服務/過濾/等或控制器的問題得以解決(與自動裝配Autowired)從國際奧委會。

可以,而不是從國際奧委會獲取依賴與傳遞authService,e.g:

public override void OnAuthenticated(
     IServiceBase authService, 
     IAuthSession session, 
     IOAuthTokens tokens, 
     Dictionary<string, string> authInfo) 
{ 
    base.OnAuthenticated(authService, session, tokens, authInfo); 
    // access servicestack user server and load properies for session here 
    var userService = authService.TryResolve<UserService>(); 
    CurrentUser = (User)userService.Get(new GetUser(SteamID)); 
} 
相關問題