Example #1
0
        //---------------
        // Static methods
        //---------------
        public static bool Save(string filename, TeamObservable obj)
        {
            bool       success    = false;
            FileStream fileStream = null;

            try
            {
                fileStream = File.Open(filename, FileMode.Create);
                BinaryFormatter formatter = new BinaryFormatter();

                formatter.Serialize(fileStream, obj);
                obj.ChangesNotSaved = false;
                success             = true;
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Something went wrong during serialization: {ex.Message}");
            }
            finally
            {
                fileStream?.Close();
            }

            return(success);
        }
Example #2
0
        public static bool Load(string filename, ref TeamObservable obj)
        {
            bool       success    = false;
            FileStream fileStream = null;

            try
            {
                fileStream = File.Open(filename, FileMode.Open);
                BinaryFormatter formatter = new BinaryFormatter();

                obj     = formatter.Deserialize(fileStream) as TeamObservable;
                success = true;
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Something went wrong during deserialization: {ex.Message}");
            }
            finally
            {
                fileStream?.Close();
            }

            return(success);
        }