Exemple #1
0
        /// <summary>
        /// Adds a new users data entry to <paramref name="userData"/> and saves it to file
        /// </summary>
        public static void AppendData(UserData userData)
        {
            if (SaveLoad.users.FindUser(userData.Sign) != null)
            {
                return;
            }

            SaveLoad.users.usersData.Add(userData);
            UsersData users = CombineUserData();

            Binary_Serializer.Serialize <UsersData>(users, RelativePath.SaveDataPath + usersFileName);

            //SharePoint.WriteData(usersFileName, data);
        }
Exemple #2
0
        /// <summary>
        /// Removes user with sign: <paramref name="userSign"/> from the save file
        /// </summary>
        public static void RemoveData(string userSign)
        {
            UsersData combined = CombineUserData();

            for (int i = combined.usersData.Count - 1; i >= 0; i--)
            {
                if (combined.usersData[i].Sign == userSign)
                {
                    combined.usersData.RemoveAt(i);
                }
            }
            users = combined;

            Binary_Serializer.Serialize <UsersData>(combined, RelativePath.SaveDataPath + usersFileName);
            //SharePoint.WriteData(usersFileName, data);
        }
Exemple #3
0
        /// <summary>
        /// Combine user data created during runtime with already saved user data
        /// </summary>
        private static UsersData CombineUserData()
        {
            UsersData oldData = users;
            UsersData newData = LoadUserData();

            for (int i = 0; i < oldData.usersData.Count; i++)
            {
                if (newData.FindUser(oldData.usersData[i].Sign) == null)
                {
                    newData.usersData.Add(oldData.usersData[i]);
                }
                else
                {
                    newData.usersData[i] = oldData.usersData[i];
                }
            }
            users = newData;

            return(newData);
        }
Exemple #4
0
 /// <summary>
 /// Function used to refresh the saved users data.
 /// </summary>
 public static void RenewUsersData()
 {
     users = SaveLoad.LoadUserData();
 }