/// <summary> /// 获取token /// </summary> /// <param name="userName">用户名</param> /// <param name="password">密码</param> /// <returns></returns> public TokenResult GetToken(string userName, string password) { TokenResult tokenResult = null; var parameters = new Dictionary <string, string>(); parameters.Add("username", userName); parameters.Add("password", password); parameters.Add("grant_type", "password"); try { //获取oauth2服务的api地址 var tokenApiUrl = ConfigManager.GetAppSettingString("tokenApiUrl"); //获取oauth2服务api返回的token字符串 var tokenString = HttpManager.Post(tokenApiUrl, parameters); //将json字符串转为json对象,获取参数 var jsonObj = JsonManager.Deserialize <Newtonsoft.Json.Linq.JObject>(tokenString); if (jsonObj != null) { tokenResult = new TokenResult(); tokenResult.AccessToken = jsonObj["access_token"].ToString(); tokenResult.TokenType = jsonObj["token_type"].ToString(); tokenResult.ExpiresIn = int.Parse(jsonObj["expires_in"].ToString()); } return(tokenResult); } catch (System.Exception) { return(tokenResult); } }
public in_game_load() { string data = PlayerPrefsWrapper.Get(StrPrefs.data_save); if (!data.IsNullOrEmpty()) { game = (abstract_game)JsonManager.Deserialize(data); } }
private void Update() { if (!EventQueue.IsEmpty) { if (EventQueue.TryDequeue(out string result)) { //Debug.Log("Will Try " + result + "|||"); j_typed response = JsonManager.Deserialize(result); Debug.Log("Try " + result + "|||" + JsonManager.Serialize(response)); response.Execute(); } } }
void Start() { _contexts = Contexts.sharedInstance; if (!_contexts.game.hasGlobals) { _contexts.game.SetGlobals(globals); } else { _contexts.game.ReplaceGlobals(globals); } if (!_contexts.game.hasUIRoot) { _contexts.game.SetUIRoot(uiRoot); } else { _contexts.game.ReplaceUIRoot(uiRoot); } if (!_contexts.game.hasGlobals) { _contexts.game.SetText(text); } else { _contexts.game.ReplaceText(text); } JsonManager.Serialize("save.json"); _contexts.game.SetGameData(JsonManager.Deserialize("save.json")); _systems = CreateSystems(_contexts, _systems); _systems.ActivateReactiveSystems(); _systems.Initialize(); timer = 0; }