/// <summary> /// Returns test data /// </summary> /// <param name="databaseRecordId">Returns ID for records are storing in Data Base</param> /// <param name="getFromCookie">'True' to get data from cookie rather then database</param> /// <returns></returns> private TestData GetTestData(out int databaseRecordId, bool getFromCookie = false) { var testInfoCookie = (HttpCookie)TempData["TestInfo"]; var securityTokenCookie = (HttpCookie)TempData["SecurityToken"]; databaseRecordId = 0; if (testInfoCookie == null || securityTokenCookie == null || string.IsNullOrWhiteSpace(testInfoCookie.Value) || string.IsNullOrWhiteSpace(securityTokenCookie.Value)) { testInfoCookie = Request.Cookies["TestInfo"]; securityTokenCookie = Request.Cookies["SecurityToken"]; if (testInfoCookie == null || securityTokenCookie == null || string.IsNullOrWhiteSpace(testInfoCookie.Value) || string.IsNullOrWhiteSpace(securityTokenCookie.Value)) { return(null); } } else { Response.Cookies.Add(testInfoCookie); Response.Cookies.Add(securityTokenCookie); } string data = testInfoCookie.Value; string securityToken = securityTokenCookie.Value; if (getFromCookie) { data = HttpUtility.UrlDecode(data); } else { var id = 0; try { id = int.Parse(testInfoCookie.Value); } catch (Exception) { return(null); } databaseRecordId = id; data = TestSessionManager.Read(id); } if (MD5HashManager.GenerateKey(data) != securityToken) { return(null); } return(XmlManager.DeserializeObject <TestData>(data)); }
static public void Load() { string xml = PlayerPrefs.GetString("GameDataSlot"); if (string.IsNullOrEmpty(xml) == false) { current = (GameData)XmlManager.DeserializeObject(typeof(GameData), xml); } if (current == null) { current = new GameData(); } }
static public void Load() { if (current == null) { current = new PlayerProfile(); } string xml = PlayerPrefs.GetString("PlayerProfile"); if (string.IsNullOrEmpty(xml.Trim()) == false) { //Debug.Log(xml); current = (PlayerProfile)XmlManager.DeserializeObject(typeof(PlayerProfile), xml); } }
public void Load() { string dataFilePath = GetDataPath() + "/" + dataFileName; if (xm.HasFile(dataFilePath)) { string dataString = xm.LoadXML(dataFilePath); PlayerData pdFromXML = xm.DeserializeObject(dataString, typeof(PlayerData)) as PlayerData; if (pdFromXML != null) { pd = pdFromXML; } else { Debug.Log("xml is null!"); } } }