Ejemplo n.º 1
0
        /// <summary>
        /// Tries to load everything from the saved data directory
        /// </summary>
        /// <param name="objects">Reference list to store the loaded objects in</param>
        public void TryLoadAll(ref List <DataObject> objects)
        {
            if (!Directory.Exists(directory))
            {
                return;
            }

            objects.AddRange(LoadFiles(directory + "/Members",
                                       (readData) =>
            {
                var res            = new MemberData(dataController, readData[1], long.Parse(readData[2]));
                res.Name           = readData[3];
                res.PersonalNumber = readData[4];

                return(res);
            }));
            objects.AddRange(LoadFiles(directory + "/Boats",
                                       (readData) =>
            {
                var res = new BoatData(dataController, readData[1], long.Parse(readData[2]));

                var owner = (MemberData)dataController.RetrieveByID(readData[3]);
                owner.RegisterBoat(res);

                res.Length   = int.Parse(readData[4]);
                res.BoatType = (BoatType)Enum.Parse(typeof(BoatType), readData[5]);

                return(res);
            }));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Tries to load everything from the saved data directory
        /// </summary>
        /// <param name="objects">Reference list to store the loaded objects in</param>
        public void TryLoadAll(ref List <DataObject> objects)
        {
            if (!Directory.Exists(directory))
            {
                return;
            }

            objects.AddRange(LoadFiles(directory + "/Members",
                                       (readData) =>
            {
                var res = new MemberData(
                    dataController,
                    readData[1],
                    long.Parse(readData[2]),
                    readData[3],
                    readData[4]
                    );

                return(res);
            }));
            objects.AddRange(LoadFiles(directory + "/Boats",
                                       (readData) =>
            {
                var res = new BoatData(
                    dataController,
                    readData[1],
                    long.Parse(readData[2]),
                    (MemberData)dataController.RetrieveByID(readData[3]),
                    int.Parse(readData[4]),
                    (BoatType)Enum.Parse(typeof(BoatType), readData[5])
                    );

                return(res);
            }));
        }