+2010-02-12 Carlos Alberto Cortez <calberto.cortez@gmail.com>
+
+ * CustomizableLocalFileSettingsProvider.cs: The name of the child
+ class of Settings should be 'normalized' by replacing the chars that
+ are invalid in a xml element name with their corresponding hexadecimal
+ values. This is specially visible when using classes container in
+ other classes.
+ Fixes #471289.
+
2009-08-31 Gonzalo Paniagua Javier <gonzalo@novell.com>
* CustomizableFileSettingsProvider.cs: reset the property value
config.SectionGroups.Add ("userSettings", userGroup);
ApplicationSettingsBase asb = context.CurrentSettings;
ClientSettingsSection cs = new ClientSettingsSection ();
- userGroup.Sections.Add ((asb != null ? asb.GetType () : typeof (ApplicationSettingsBase)).FullName, cs);
+ string class_name = NormalizeInvalidXmlChars ((asb != null ? asb.GetType () : typeof (ApplicationSettingsBase)).FullName);
+ userGroup.Sections.Add (class_name, cs);
}
bool hasChanges = false;
#endif
}
+ // NOTE: We should add here all the chars that are valid in a name of a class (Ecma-wise),
+ // but invalid in an xml element name, and provide a better impl if we get too many of them.
+ string NormalizeInvalidXmlChars (string str)
+ {
+ char [] invalid_chars = new char [] { '+' };
+
+ if (str == null || str.IndexOfAny (invalid_chars) == -1)
+ return str;
+
+ // Replace with its hexadecimal values.
+ str = str.Replace ("+", "_x002B_");
+ return str;
+ }
+
private void LoadPropertyValue (SettingsPropertyCollection collection, SettingElement element, bool allowOverwrite)
{
SettingsProperty prop = collection [element.Name];
if (values == null) {
values = new SettingsPropertyValueCollection ();
string groupName = context ["GroupName"] as string;
+ groupName = NormalizeInvalidXmlChars (groupName); // we likely saved the element removing the non valid xml chars.
LoadProperties (exeMapCurrent, collection, ConfigurationUserLevel.None, "applicationSettings", false, groupName);
LoadProperties (exeMapCurrent, collection, ConfigurationUserLevel.None, "userSettings", false, groupName);