示例#1
0
        private void Serialize(SettingsEntity entity)
        {
            _entity = entity;

            var formatter = new BinaryFormatter();
            var fs        = new FileStream(SettingsFileName, FileMode.Create);

            formatter.Serialize(fs, _entity);
            fs.Close();
            fs.Dispose();
        }
示例#2
0
        private void InitializeEntity()
        {
            var formatter = new BinaryFormatter();

            if (File.Exists(SettingsFileName))
            {
                //Десериализовать из файла

                var fs = new FileStream(SettingsFileName, FileMode.Open, FileAccess.Read);
                _entity = (SettingsEntity)formatter.Deserialize(fs);
                fs.Close();
                fs.Dispose();
            }
            else
            {
                _entity = InitializeEntityByDefault();

                Serialize(_entity);
            }
        }
示例#3
0
        private void Serialize(SettingsEntity entity)
        {
            _entity = entity;

            var formatter = new BinaryFormatter();
            var fs = new FileStream(SettingsFileName, FileMode.Create);
            formatter.Serialize(fs, _entity);
            fs.Close();
            fs.Dispose();
        }
示例#4
0
        private void InitializeEntity()
        {
            var formatter = new BinaryFormatter();

            if(File.Exists(SettingsFileName))
            {
                //Десериализовать из файла

                var fs = new FileStream(SettingsFileName, FileMode.Open, FileAccess.Read);
                _entity = (SettingsEntity) formatter.Deserialize(fs);
                fs.Close();
                fs.Dispose();
            }
            else
            {

                _entity = InitializeEntityByDefault();

                Serialize(_entity);
            }
        }
示例#5
0
 public void SaveSettings(SettingsEntity entity)
 {
     Serialize(entity);
 }
示例#6
0
 public void SaveSettings(SettingsEntity entity)
 {
     Serialize(entity);
 }