public void LoadUserInfo() { UserItem userItem = IOTool.DeserializeFromString <UserItem>(PlayerPrefs.GetString(GlobalVars.PREF_USER_ITEM)); _headIndex = userItem.headIndex; _userName = userItem.userName; }
private void SaveLogDict() { foreach (var file in IOTool.GetFiles(GetChatDirPath())) { file.Delete(); } foreach (var userID in _chatLogDict.Keys) { string filePath = GetChatDirPath() + "/" + userID; IOTool.SerializeToFile <ChatLog>(filePath, _chatLogDict[userID]); } }
private void SaveFriendDict() { foreach (var file in IOTool.GetFiles(GetContactsDirPath())) { file.Delete(); } foreach (var userID in _friendDict.Keys) { string filePath = GetContactsDirPath() + "/" + userID; IOTool.SerializeToFile <UserItem>(filePath, _friendDict[userID]); } }
private void SaveGroupDict() { foreach (var file in IOTool.GetFiles(GetGroupDirPath())) { file.Delete(); } foreach (var groupID in _groupDict.Keys) { string filePath = GetGroupDirPath() + "/" + groupID; IOTool.SerializeToFile <GroupItem>(filePath, _groupDict[groupID]); } }
private void LoadLogDict() { ClearLogDict(); if (IOTool.IsDirExist(GetChatDirPath())) { foreach (var file in IOTool.GetFiles(GetChatDirPath())) { ChatLog chatLog = IOTool.DeserializeFromFile <ChatLog>(file.FullName); if (chatLog != null) { _chatLogDict[chatLog.chatID] = chatLog; } } } }
private void LoadFriendDict() { ClearFriendDict(); if (_friendDict.Count == 0 && IOTool.IsDirExist(GetContactsDirPath())) { foreach (var file in IOTool.GetFiles(GetContactsDirPath())) { UserItem userItem = IOTool.DeserializeFromFile <UserItem>(file.FullName); if (userItem != null) { _friendDict[userItem.userId] = userItem; } } } }
private void LoadGroupDict() { ClearGroupDict(); if (_groupDict.Count == 0 && IOTool.IsDirExist(GetGroupDirPath())) { foreach (var file in IOTool.GetFiles(GetGroupDirPath())) { GroupItem groupItem = IOTool.DeserializeFromFile <GroupItem>(file.FullName); if (groupItem != null) { _groupDict[groupItem.groupId] = groupItem; } } } }
public void CreateDir() { string[] dirPathList = new string[] { Application.persistentDataPath + "/" + _userId, Application.persistentDataPath + "/" + _userId + "/Chat", Application.persistentDataPath + "/" + _userId + "/Contacts", Application.persistentDataPath + "/" + _userId + "/Head", Application.persistentDataPath + "/" + _userId + "/Image", Application.persistentDataPath + "/" + _userId + "/Group", }; foreach (var dirPath in dirPathList) { IOTool.CreateDir(dirPath); } }
public void SaveUserInfo() { PlayerPrefs.SetString(GlobalVars.PREF_USER_ITEM, IOTool.SerializeToString <UserItem>(Self)); }