///<summary>Reads settings from the XML file into Visual Studio's global settings.</summary> private void LoadSettings() { var xml = XDocument.Load(SettingsPath, LoadOptions.PreserveWhitespace); foreach (var section in SettingsSection.FromXmlSettingsFile(xml.Root)) { if (!KnownSettings.IsAllowed(section.Item1)) { logger.Log("Warning: Not loading unsafe category " + section.Item1 + ". You may have a malicious Rebracer.xml file."); continue; } Properties container; try { container = dte.Properties(section.Item1); } catch (Exception ex) { logger.Log("Warning: Not loading unsupported category " + section.Item1 + " from settings file; you may be missing an extension. Error: " + ex.Message); continue; } foreach (var property in section.Item2.Elements("PropertyValue")) { string name = property.Attribute("name").Value; if (KnownSettings.ShouldSkip(section.Item1, name)) { continue; } try { container.Item(name).Value = VsValue(property); } catch (Exception ex) { logger.Log("An error occurred while reading the setting " + section.Item1 + "#" + name + " from settings file. Error: " + ex.Message); } } } }
///<summary>Reads settings from the XML file into Visual Studio's global settings.</summary> private void LoadSettings() { var xml = XDocument.Load(SettingsPath, LoadOptions.PreserveWhitespace); bool modified = false; foreach (var section in SettingsSection.FromXmlSettingsFile(xml.Root)) { if (!KnownSettings.IsAllowed(section.Item1)) { logger.Log("Warning: Not loading unsafe category " + section.Item1 + ". You may have a malicious Rebracer.xml file."); continue; } Properties container; try { container = dte.Properties(section.Item1); } catch (Exception ex) { logger.Log("Warning: Not loading unsupported category " + section.Item1 + " from settings file; you may be missing an extension. Error: " + ex.Message); continue; } List <XElement> elements = section.Item2.Elements("PropertyValue").ToList(); foreach (var property in elements) { string name = property.Attribute("name").Value; if (KnownSettings.ShouldSkip(section.Item1, name)) { continue; } try { Property p; try { p = container.Item(name); } catch (ArgumentException ex) { if ((uint)ex.HResult == 0x80070057) // E_INVALIDARG, Property does not exists. { // This error occurs when the IDE property does not exist at this time. continue; } logger.Log("An error occurred while reading the setting " + section.Item1 + "#" + name + " from settings file. Error: " + ex.Message); continue; } p.Value = VsValue(property); } catch (COMException ex) { if ((uint)ex.HResult == 0x80020003) // DISP_E_MEMBERNOTFOUND { // MSDN: A return value indicating that the requested member does not exist, or the call to Invoke // tried to set the value of a read-only property. So this is not error. continue; } logger.Log("An error occurred while reading the setting " + section.Item1 + "#" + name + " from settings file. Error: " + ex.Message); } catch (Exception ex) { logger.Log("An error occurred while reading the setting " + section.Item1 + "#" + name + " from settings file. Error: " + ex.Message); } } } }