Esempio n. 1
0
        private static EventsData LoadEventData()
        {
            //string data = SharePoint.ReadData(eventsFileName);
            EventsData events = Binary_Serializer.Deserialize <EventsData>(RelativePath.SaveDataPath + eventsFileName);

            return(events);
        }
Esempio n. 2
0
        private static UsersData LoadUserData()
        {
            //string data = SharePoint.ReadData(usersFileName);
            UsersData users = Binary_Serializer.Deserialize <UsersData>(RelativePath.SaveDataPath + usersFileName);

            return(users);
        }
Esempio n. 3
0
        /// <summary>
        /// Adds a new events entry to <paramref name="eventData"/> and saves it to file
        /// </summary>
        public static void AppendData(EventData eventData)
        {
            bool entryExists = false;
            int  index       = -1;

            foreach (EventData e in SaveLoad.events.eventsData)
            {
                if (e.EventId == eventData.EventId)
                {
                    entryExists = true;
                    index       = SaveLoad.events.eventsData.IndexOf(e);
                    continue;
                }
            }

            if (!entryExists)
            {
                SaveLoad.events.eventsData.Add(eventData);
            }
            else
            {
                SaveLoad.events.eventsData[index] = eventData;
            }

            EventsData combined = CombineEventData();

            Binary_Serializer.Serialize <EventsData>(combined, RelativePath.SaveDataPath + eventsFileName);
            //SharePoint.WriteData(eventsFileName, data);
        }
Esempio n. 4
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);
        }
Esempio n. 5
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);
        }
Esempio n. 6
0
        /// <summary>
        /// Removes event: <paramref name="eventData"/> from the save file
        /// </summary>
        public static void RemoveData(EventData eventData)
        {
            EventsData combined = CombineEventData();

            foreach (EventData e in combined.eventsData)
            {
                if (e.EventId == eventData.EventId)
                {
                    events.eventsData.Remove(e);
                    break;
                }
            }
            events = combined;

            Binary_Serializer.Serialize <EventsData>(combined, RelativePath.SaveDataPath + usersFileName);
            //SharePoint.WriteData(eventsFileName, data);
        }
Esempio n. 7
0
 //used for testing
 public static void CreateEmptyEventsFile()
 {
     Binary_Serializer.Serialize <EventsData>(new EventsData(), RelativePath.SaveDataPath + eventsFileName);
 }
Esempio n. 8
0
 //used for testing
 public static void CreateEmptyUserFile()
 {
     Binary_Serializer.Serialize <UsersData>(new UsersData(), RelativePath.SaveDataPath + usersFileName);
 }