public MediaProviderLastFm(IMediaProviderSupportV7 aSupport) { iSupport = aSupport; iService = new LastFmService(); iView = new ViewWidgetMediaProviderLastFm(aSupport, iService); iOptionsLastFm = new OptionsLastFm(aSupport.AppSupport.SavePath); iOptionsLastFm.EventUsernamePasswordChanged += EventUsernamePasswordChanged; EventUsernamePasswordChanged(this, EventArgs.Empty); }
private void Load() { TextReader reader = null; try { XmlSerializer serialiser = new XmlSerializer(typeof(OptionsLastFm)); reader = new StreamReader(iOptionsFile); OptionsLastFm options = serialiser.Deserialize(reader) as OptionsLastFm; reader.Close(); if (options.Version == kVersion) { iUsername = options.Username; iPassword = options.Password; iOptionsPageLastFm.SetUsername(options.Username); iOptionsPageLastFm.SetPassword(options.Password); } else { UserLog.WriteLine(DateTime.Now + ": Last.fm settings file version incorrect, found " + options.Version + " expected " + kVersion + ", using default settings"); SetDefaults(); Save(); } } catch (FileNotFoundException) { UserLog.WriteLine(DateTime.Now + ": Last.fm settings file not found, using default settings"); SetDefaults(); Save(); } catch (InvalidOperationException e) { if (reader != null) { reader.Close(); } UserLog.WriteLine(DateTime.Now + ": Last.fm settings file corrupt, using default settings (" + e.Message + ")"); SetDefaults(); Save(); } }