예제 #1
0
        public static bool Load(string filename, ref ResearcherObservable obj)
        {
            FileStream fileStream = null;

            try
            {
                fileStream = File.OpenRead(filename);
                BinaryFormatter binaryFormatter = new BinaryFormatter();
                obj = binaryFormatter.Deserialize(fileStream) as ResearcherObservable;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error!");
                //Console.WriteLine("Исключение: " + ex.Message);
                return(false);
            }
            finally
            {
                if (fileStream != null)
                {
                    fileStream.Close();
                }
            }
            obj.IfChanged          = false;
            obj.CollectionChanged += Handler;
            return(true);
        }
예제 #2
0
        public static bool Save(string filename, ref ResearcherObservable obj)
        {
            FileStream fileStream = null;

            try
            {
                fileStream = File.Create(filename);
                BinaryFormatter binaryFormatter = new BinaryFormatter();
                binaryFormatter.Serialize(fileStream, obj);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error!");
                //Console.WriteLine("Исключение: " + ex.Message);
                return(false);
            }
            finally
            {
                if (fileStream != null)
                {
                    fileStream.Close();
                }
            }
            obj.IfChanged = false;
            return(true);
        }