Ejemplo n.º 1
0
        public SettingsViewModel()
        {
            _accountHandler = EdenKernel.Get<IAccountHandler>();
            _configurationManager = EdenKernel.Get<IConfigurationManager>();
            _configuration = _configurationManager.LoadConfiguration();

            if (_configuration.SaveUsername)
            {
                SaveUsername = _configuration.SaveUsername;
                Username = _configuration.Username;
            }

            LoginCommand = new AsynchronousCommand(Login);
            GetCommand = new AsynchronousCommand(Get);
        }
Ejemplo n.º 2
0
        public void SaveConfiguration(Configuration configuration)
        {
            Stream fileStream = new FileStream(_applicationFile.ConfigurationFile.FullName, FileMode.Truncate);

            try
            {
                XmlSerializer serializer = new XmlSerializer(typeof(Configuration));
                serializer.Serialize(fileStream, configuration);
            }
            catch (Exception e)
            {
                _logger.Fatal(e.ToString());
            }

            fileStream.Close();
        }
Ejemplo n.º 3
0
        public Configuration LoadConfiguration()
        {
            Stream fileStream = new FileStream(_applicationFile.ConfigurationFile.FullName, FileMode.Open);
            Configuration configuration = new Configuration();

            try
            {
                XmlSerializer serializer = new XmlSerializer(typeof(Configuration));
                configuration = (Configuration)serializer.Deserialize(fileStream);
            }
            catch (Exception e)
            {
                _logger.Fatal(e.ToString());
            }

            fileStream.Close();

            return configuration;
        }