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(); } } }
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(); } } }