public void WriteSettings(string settings) { AllAddinSettings allAddinSettings = GetFreshAllAddinSettings(); AddinSettings addinSettings = null; try { addinSettings = allAddinSettings.PersistedSettings.SingleOrDefault(x => x.ClassName == m_AddinTypeName); } catch (Exception ex) { Trace.WriteLine(ex.GetFullStackTrace()); } if (addinSettings == null) { addinSettings = new AddinSettings() { ClassName = m_AddinTypeName }; allAddinSettings.PersistedSettings.Add(addinSettings); } addinSettings.Settings = settings; var output = new StringBuilder(); using (var wrt = new StringWriter(output)) { m_AllSettingSerializer.Serialize(wrt, allAddinSettings); } Settings.Default.AddinSettings = output.ToString(); Settings.Default.Save(); }
public string ReadSettings() { AllAddinSettings allAddinSettings = GetFreshAllAddinSettings(); AddinSettings addinSettings = null; try { addinSettings = allAddinSettings.PersistedSettings.SingleOrDefault(x => x.ClassName == m_AddinTypeName); if (addinSettings != null) { return(addinSettings.Settings); } } catch (Exception ex) { Trace.WriteLine(ex.GetFullStackTrace()); } return(string.Empty); }