Beispiel #1
0
        private static void LoadStoredDevices(ModelRepository repo)
        {
            // If there are no current stored devices config, simply add a new DeviceCollection.
            if (!File.Exists(DEVICES_CONFIG_PATH))
            {
                repo["devices"] = new DeviceCollection();
                return;
            }

            Stream read;

            try
            {
                read = new FileStream(DEVICES_CONFIG_PATH, FileMode.Open);
            }
            catch (Exception ex)
            {
                throw new IOException("Unable to load stored devices configuration.", ex);
            }

            try
            {
                repo.Deserialize("devices", typeof(iTunesAgent.Domain.DeviceCollection), read);
            }
            finally
            {
                if (read != null)
                {
                    read.Close();
                }
            }
        }
Beispiel #2
0
        private static void LoadApplicationConfiguration(ConfigurationChecker configurationChecker, ModelRepository repo)
        {
            Stream read;

            try
            {
                configurationChecker.CheckConfiguration();
                read = new FileStream(APP_CONFIG_PATH, FileMode.Open);
            }
            catch (Exception ex)
            {
                throw new IOException("Unable to load application configuration.", ex);
            }

            try
            {
                repo.Deserialize("appconfig", typeof(iTunesAgent.Domain.Configuration), read);
            }
            finally
            {
                if (read != null)
                {
                    read.Close();
                }
            }
        }