2 // CustomizableFileSettingsProvider.cs
5 // Noriaki Okimoto <seara@ojk.sppd.ne.jp>
6 // Atsushi Enomoto <atsushi@ximian.com>
8 // (C)2007 Noriaki Okimoto
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 #if NET_2_0 && CONFIGURATION_DEP
33 extern alias PrebuiltSystem;
37 using System.Collections;
38 using System.Collections.Generic;
39 using System.Configuration;
40 using System.Globalization;
42 using System.Reflection;
43 using System.Security.Cryptography;
48 using NameValueCollection = System.Collections.Specialized.NameValueCollection;
50 using NameValueCollection = PrebuiltSystem.System.Collections.Specialized.NameValueCollection;
53 namespace System.Configuration
55 // location to store user configuration settings.
56 internal enum UserConfigLocationOption : uint
59 Product_VersionMajor = 0x21,
60 Product_VersionMinor = 0x22,
61 Product_VersionBuild = 0x24,
62 Product_VersionRevision = 0x28,
63 Company_Product = 0x30,
64 Company_Product_VersionMajor = 0x31,
65 Company_Product_VersionMinor = 0x32,
66 Company_Product_VersionBuild = 0x34,
67 Company_Product_VersionRevision = 0x38,
72 internal class CustomizableFileSettingsProvider : SettingsProvider, IApplicationSettingsProvider
76 // This is used from within System.Web to allow mapping of the ExeConfigFilename to
77 // the correct Web.config for the current request. Otherwise web applications will
78 // not be able to access settings from Web.config. The type assigned to this
79 // variable must descend from the ConfigurationFileMap class and its
80 // MachineConfigFilename will be used to set the ExeConfigFilename.
82 // This is necessary to fix bug #491531
83 private static Type webConfigurationFileMapType;
85 private static string userRoamingPath = "";
86 private static string userLocalPath = "";
87 private static string userRoamingPathPrevVersion = "";
88 private static string userLocalPathPrevVersion = "";
89 private static string userRoamingName = "user.config";
90 private static string userLocalName = "user.config";
91 private static string userRoamingBasePath = "";
92 private static string userLocalBasePath = "";
93 private static string CompanyName = "";
94 private static string ProductName = "";
95 private static string ForceVersion = "";
96 private static string[] ProductVersion;
98 // whether to include parts in the folder name or not:
99 private static bool isVersionMajor = false; // 0x0001 major version
100 private static bool isVersionMinor = false; // 0x0002 minor version
101 private static bool isVersionBuild = false; // 0x0004 build version
102 private static bool isVersionRevision = false; // 0x0008 revision
103 private static bool isCompany = true; // 0x0010 corporate name
104 private static bool isProduct = true; // 0x0020 product name
105 private static bool isEvidence = false; // 0x0040 evidence hash
107 private static bool userDefine = false; // 0x8000 ignore all above and use user definition
109 private static UserConfigLocationOption userConfig = UserConfigLocationOption.Company_Product;
111 public override void Initialize (string name, NameValueCollection config)
113 base.Initialize (name, config);
116 // full path to roaming user.config
117 internal static string UserRoamingFullPath {
118 get { return Path.Combine (userRoamingPath, userRoamingName); }
121 // full path to local user.config
122 internal static string UserLocalFullPath {
123 get { return Path.Combine (userLocalPath, userLocalName); }
126 // previous full path to roaming user.config
127 public static string PrevUserRoamingFullPath {
128 get { return Path.Combine (userRoamingPathPrevVersion, userRoamingName); }
131 // previous full path to local user.config
132 public static string PrevUserLocalFullPath {
133 get { return Path.Combine (userLocalPathPrevVersion, userLocalName); }
136 // path to roaming user.config
137 public static string UserRoamingPath {
138 get { return userRoamingPath; }
141 // path to local user.config
142 public static string UserLocalPath {
143 get { return userLocalPath; }
146 // file name which is equivalent to user.config, for roaming user
147 public static string UserRoamingName {
148 get { return userRoamingName; }
151 // file name which is equivalent to user.config, for local user
152 public static string UserLocalName {
153 get { return userLocalName; }
156 public static UserConfigLocationOption UserConfigSelector
158 get { return userConfig; }
162 if (((uint) userConfig & 0x8000) != 0) {
163 isVersionMajor = false;
164 isVersionMinor = false;
165 isVersionBuild = false;
166 isVersionRevision = false;
171 isVersionRevision = ((uint) userConfig & 0x0008) != 0;
172 isVersionBuild = isVersionRevision | ((uint)userConfig & 0x0004) != 0;
173 isVersionMinor = isVersionBuild | ((uint)userConfig & 0x0002) != 0;
174 isVersionMajor = IsVersionMinor | ((uint)userConfig & 0x0001) != 0;
176 isCompany = ((uint) userConfig & 0x0010) != 0;
177 isProduct = ((uint) userConfig & 0x0020) != 0;
181 // whether the path to include the major version.
182 public static bool IsVersionMajor
184 get { return isVersionMajor; }
187 isVersionMajor = value;
188 isVersionMinor = false;
189 isVersionBuild = false;
190 isVersionRevision = false;
194 // whether the path to include minor version.
195 public static bool IsVersionMinor
197 get { return isVersionMinor; }
200 isVersionMinor = value;
202 isVersionMajor = true;
203 isVersionBuild = false;
204 isVersionRevision = false;
208 // whether the path to include build version.
209 public static bool IsVersionBuild
211 get { return isVersionBuild; }
214 isVersionBuild = value;
215 if (isVersionBuild) {
216 isVersionMajor = true;
217 isVersionMinor = true;
219 isVersionRevision = false;
223 // whether the path to include revision.
224 public static bool IsVersionRevision
226 get { return isVersionRevision; }
229 isVersionRevision = value;
230 if (isVersionRevision) {
231 isVersionMajor = true;
232 isVersionMinor = true;
233 isVersionBuild = true;
238 // whether the path to include company name.
239 public static bool IsCompany
241 get { return isCompany; }
242 set { isCompany = value; }
245 // whether the path to include evidence hash.
246 public static bool IsEvidence
248 get { return isEvidence; }
249 set { isEvidence = value; }
252 // AssemblyCompanyAttribute->Namespace->"Program"
253 private static string GetCompanyName ()
255 Assembly assembly = Assembly.GetEntryAssembly ();
256 if (assembly == null)
257 assembly = Assembly.GetCallingAssembly ();
259 AssemblyCompanyAttribute [] attrs = (AssemblyCompanyAttribute []) assembly.GetCustomAttributes (typeof (AssemblyCompanyAttribute), true);
261 if ((attrs != null) && attrs.Length > 0) {
262 return attrs [0].Company;
266 MethodInfo entryPoint = assembly.EntryPoint;
267 Type entryType = entryPoint != null ? entryPoint.DeclaringType : null;
268 if (entryType != null && !String.IsNullOrEmpty (entryType.Namespace)) {
269 int end = entryType.Namespace.IndexOf ('.');
270 return end < 0 ? entryType.Namespace : entryType.Namespace.Substring (0, end);
274 return assembly.GetName ().Name;
278 private static string GetProductName ()
280 Assembly assembly = Assembly.GetEntryAssembly ();
281 if (assembly == null)
282 assembly = Assembly.GetCallingAssembly ();
286 byte [] pkt = assembly.GetName ().GetPublicKeyToken ();
287 return String.Format ("{0}_{1}_{2}",
288 AppDomain.CurrentDomain.FriendlyName,
289 pkt != null ? "StrongName" : "Url",
292 #else // AssemblyProductAttribute-based code
293 AssemblyProductAttribute [] attrs = (AssemblyProductAttribute[]) assembly.GetCustomAttributes (typeof (AssemblyProductAttribute), true);
295 if ((attrs != null) && attrs.Length > 0) {
296 return attrs [0].Product;
298 return assembly.GetName ().Name;
302 // FIXME: it seems that something else is used
303 // here, to convert hash bytes to string.
304 private static string GetEvidenceHash ()
306 Assembly assembly = Assembly.GetEntryAssembly ();
307 if (assembly == null)
308 assembly = Assembly.GetCallingAssembly ();
310 byte [] pkt = assembly.GetName ().GetPublicKeyToken ();
311 byte [] hash = SHA1.Create ().ComputeHash (pkt != null ? pkt : Encoding.UTF8.GetBytes (assembly.EscapedCodeBase));
313 return Convert.ToBase64String (hash);
316 private static string GetProductVersion ()
318 Assembly assembly = Assembly.GetEntryAssembly ();
319 if (assembly == null)
320 assembly = Assembly.GetCallingAssembly ();
321 if (assembly == null)
324 return assembly.GetName ().Version.ToString ();
327 private static void CreateUserConfigPath ()
332 if (ProductName == "")
333 ProductName = GetProductName ();
334 if (CompanyName == "")
335 CompanyName = GetCompanyName ();
336 if (ForceVersion == "")
337 ProductVersion = GetProductVersion ().Split('.');
339 // C:\Documents and Settings\(user)\Application Data
341 if (userRoamingBasePath == "")
342 userRoamingPath = Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData);
345 userRoamingPath = userRoamingBasePath;
347 // C:\Documents and Settings\(user)\Local Settings\Application Data (on Windows)
349 if (userLocalBasePath == "")
350 userLocalPath = Environment.GetFolderPath (Environment.SpecialFolder.LocalApplicationData);
353 userLocalPath = userLocalBasePath;
356 userRoamingPath = Path.Combine (userRoamingPath, CompanyName);
357 userLocalPath = Path.Combine (userLocalPath, CompanyName);
362 Assembly assembly = Assembly.GetEntryAssembly ();
363 if (assembly == null)
364 assembly = Assembly.GetCallingAssembly ();
366 byte [] pkt = assembly.GetName ().GetPublicKeyToken ();
367 ProductName = String.Format ("{0}_{1}_{2}",
369 pkt != null ? "StrongName" : "Url",
373 userRoamingPath = Path.Combine (userRoamingPath, ProductName);
374 userLocalPath = Path.Combine (userLocalPath, ProductName);
380 if (ForceVersion == "") {
381 if (isVersionRevision)
382 versionName = String.Format ("{0}.{1}.{2}.{3}", ProductVersion [0], ProductVersion [1], ProductVersion [2], ProductVersion [3]);
383 else if (isVersionBuild)
384 versionName = String.Format ("{0}.{1}.{2}", ProductVersion [0], ProductVersion [1], ProductVersion [2]);
385 else if (isVersionMinor)
386 versionName = String.Format ("{0}.{1}", ProductVersion [0], ProductVersion [1]);
387 else if (isVersionMajor)
388 versionName = ProductVersion [0];
393 versionName = ForceVersion;
395 string prevVersionRoaming = PrevVersionPath (userRoamingPath, versionName);
396 string prevVersionLocal = PrevVersionPath (userLocalPath, versionName);
398 userRoamingPath = Path.Combine (userRoamingPath, versionName);
399 userLocalPath = Path.Combine (userLocalPath, versionName);
400 if (prevVersionRoaming != "")
401 userRoamingPathPrevVersion = Path.Combine(userRoamingPath, prevVersionRoaming);
402 if (prevVersionLocal != "")
403 userLocalPathPrevVersion = Path.Combine(userLocalPath, prevVersionLocal);
406 // string for the previous version. It ignores newer ones.
407 private static string PrevVersionPath (string dirName, string currentVersion)
409 string prevVersionString = "";
411 if (!Directory.Exists(dirName))
412 return prevVersionString;
413 DirectoryInfo currentDir = new DirectoryInfo (dirName);
414 foreach (DirectoryInfo dirInfo in currentDir.GetDirectories ())
415 if (String.Compare (currentVersion, dirInfo.Name, StringComparison.Ordinal) > 0)
416 if (String.Compare (prevVersionString, dirInfo.Name, StringComparison.Ordinal) < 0)
417 prevVersionString = dirInfo.Name;
419 return prevVersionString;
422 // sets the explicit path to store roaming user.config or equivalent.
423 // (returns the path validity.)
424 public static bool SetUserRoamingPath (string configPath)
426 if (CheckPath (configPath))
428 userRoamingBasePath = configPath;
435 // sets the explicit path to store local user.config or equivalent.
436 // (returns the path validity.)
437 public static bool SetUserLocalPath (string configPath)
439 if (CheckPath (configPath))
441 userLocalBasePath = configPath;
448 private static bool CheckFileName (string configFile)
451 char[] invalidFileChars = Path.GetInvalidFileNameChars();
453 foreach (char invalidChar in invalidFileChars)
455 if (configFile.Contains(invalidChar.ToString()))
462 return configFile.IndexOfAny (Path.GetInvalidFileNameChars ()) < 0;
465 // sets the explicit roaming file name which is user.config equivalent.
466 // (returns the file name validity.)
467 public static bool SetUserRoamingFileName (string configFile)
469 if (CheckFileName (configFile))
471 userRoamingName = configFile;
478 // sets the explicit local file name which is user.config equivalent.
479 // (returns the file name validity.)
480 public static bool SetUserLocalFileName (string configFile)
482 if (CheckFileName (configFile))
484 userLocalName = configFile;
491 // sets the explicit company name for folder.
492 // (returns the file name validity.)
493 public static bool SetCompanyName (string companyName)
495 if (CheckFileName (companyName))
497 CompanyName = companyName;
504 // sets the explicit product name for folder.
505 // (returns the file name validity.)
506 public static bool SetProductName (string productName)
508 if (CheckFileName (productName))
510 ProductName = productName;
517 // sets the explicit major version for folder.
518 public static bool SetVersion (int major)
520 ForceVersion = string.Format ("{0}", major);
524 // sets the explicit major and minor versions for folder.
525 public static bool SetVersion (int major, int minor)
527 ForceVersion = string.Format ("{0}.{1}", major, minor);
531 // sets the explicit major/minor/build numbers for folder.
532 public static bool SetVersion (int major, int minor, int build)
534 ForceVersion = string.Format ("{0}.{1}.{2}", major, minor, build);
538 // sets the explicit major/minor/build/revision numbers for folder.
539 public static bool SetVersion (int major, int minor, int build, int revision)
541 ForceVersion = string.Format ("{0}.{1}.{2}.{3}", major, minor, build, revision);
545 // sets the explicit version number string for folder.
546 public static bool SetVersion (string forceVersion)
548 if (CheckFileName (forceVersion))
550 ForceVersion = forceVersion;
557 private static bool CheckPath (string configPath)
559 char[] invalidPathChars = Path.GetInvalidPathChars ();
562 foreach (char invalidChar in invalidPathChars)
564 if (configPath.Contains (invalidChar.ToString()))
570 if (configPath.IndexOfAny (invalidPathChars) >= 0)
573 string folder = configPath;
575 while ((fileName = Path.GetFileName (folder)) != "")
577 if (!CheckFileName (fileName))
581 folder = Path.GetDirectoryName (folder);
588 public override string Name {
589 get { return base.Name; }
592 string app_name = String.Empty;//"OJK.CustomSetting.CustomizableLocalFileSettingsProvider";
593 public override string ApplicationName {
594 get { return app_name; }
595 set { app_name = value; }
598 private ExeConfigurationFileMap exeMapCurrent = null;
599 private ExeConfigurationFileMap exeMapPrev = null;
600 private SettingsPropertyValueCollection values = null;
602 private void SaveProperties (ExeConfigurationFileMap exeMap, SettingsPropertyValueCollection collection, ConfigurationUserLevel level, SettingsContext context, bool checkUserLevel)
604 Configuration config = ConfigurationManager.OpenMappedExeConfiguration (exeMap, level);
606 UserSettingsGroup userGroup = config.GetSectionGroup ("userSettings") as UserSettingsGroup;
607 bool isRoaming = (level == ConfigurationUserLevel.PerUserRoaming);
609 #if true // my reimplementation
611 if (userGroup == null) {
612 userGroup = new UserSettingsGroup ();
613 config.SectionGroups.Add ("userSettings", userGroup);
614 ApplicationSettingsBase asb = context.CurrentSettings;
615 ClientSettingsSection cs = new ClientSettingsSection ();
616 userGroup.Sections.Add ((asb != null ? asb.GetType () : typeof (ApplicationSettingsBase)).FullName, cs);
619 bool hasChanges = false;
621 foreach (ConfigurationSection section in userGroup.Sections) {
622 ClientSettingsSection userSection = section as ClientSettingsSection;
623 if (userSection == null)
626 foreach (SettingsPropertyValue value in collection) {
627 if (checkUserLevel && value.Property.Attributes.Contains (typeof (SettingsManageabilityAttribute)) != isRoaming)
630 SettingElement element = userSection.Settings.Get (value.Name);
631 if (element == null) {
632 element = new SettingElement (value.Name, value.Property.SerializeAs);
633 userSection.Settings.Add (element);
635 if (element.Value.ValueXml == null)
636 element.Value.ValueXml = new XmlDocument ().CreateElement ("value");
637 switch (value.Property.SerializeAs) {
638 case SettingsSerializeAs.Xml:
639 element.Value.ValueXml.InnerXml = (value.SerializedValue as string) ?? string.Empty;
641 case SettingsSerializeAs.String:
642 element.Value.ValueXml.InnerText = value.SerializedValue as string;
644 case SettingsSerializeAs.Binary:
645 element.Value.ValueXml.InnerText = value.SerializedValue != null ? Convert.ToBase64String (value.SerializedValue as byte []) : string.Empty;
648 throw new NotImplementedException ();
653 config.Save (ConfigurationSaveMode.Minimal, true);
655 #else // original impl. - likely buggy to miss some properties to save
657 foreach (ConfigurationSection configSection in userGroup.Sections)
659 ClientSettingsSection userSection = configSection as ClientSettingsSection;
660 if (userSection != null)
663 userSection.Settings.Clear();
665 foreach (SettingsPropertyValue propertyValue in collection)
667 if (propertyValue.IsDirty)
669 SettingElement element = new SettingElement(propertyValue.Name, SettingsSerializeAs.String);
670 element.Value.ValueXml = new XmlDocument();
671 element.Value.ValueXml.InnerXml = (string)propertyValue.SerializedValue;
672 userSection.Settings.Add(element);
676 foreach (SettingElement element in userSection.Settings)
678 if (collection [element.Name] != null) {
679 if (collection [element.Name].Property.Attributes.Contains (typeof (SettingsManageabilityAttribute)) != isRoaming)
682 element.SerializeAs = SettingsSerializeAs.String;
683 element.Value.ValueXml.InnerXml = (string) collection [element.Name].SerializedValue; ///Value = XmlElement
689 config.Save (ConfigurationSaveMode.Minimal, true);
693 private void LoadPropertyValue (SettingsPropertyCollection collection, SettingElement element, bool allowOverwrite)
695 SettingsProperty prop = collection [element.Name];
696 if (prop == null) { // see bug #343459
697 prop = new SettingsProperty (element.Name);
698 collection.Add (prop);
701 SettingsPropertyValue value = new SettingsPropertyValue (prop);
702 value.IsDirty = false;
703 if (element.Value.ValueXml != null) {
704 switch (value.Property.SerializeAs) {
705 case SettingsSerializeAs.Xml:
706 value.SerializedValue = element.Value.ValueXml.InnerXml;
708 case SettingsSerializeAs.String:
709 value.SerializedValue = element.Value.ValueXml.InnerText;
711 case SettingsSerializeAs.Binary:
712 value.SerializedValue = Convert.FromBase64String (element.Value.ValueXml.InnerText);
717 value.SerializedValue = prop.DefaultValue;
721 values.Remove (element.Name);
723 } catch (ArgumentException ex) {
724 throw new ConfigurationErrorsException (string.Format (
725 CultureInfo.InvariantCulture,
726 "Failed to load value for '{0}'.",
731 private void LoadProperties (ExeConfigurationFileMap exeMap, SettingsPropertyCollection collection, ConfigurationUserLevel level, string sectionGroupName, bool allowOverwrite, string groupName)
733 Configuration config = ConfigurationManager.OpenMappedExeConfiguration (exeMap,level);
735 ConfigurationSectionGroup sectionGroup = config.GetSectionGroup (sectionGroupName);
736 if (sectionGroup != null) {
737 foreach (ConfigurationSection configSection in sectionGroup.Sections) {
738 if (configSection.SectionInformation.Name != groupName)
741 ClientSettingsSection clientSection = configSection as ClientSettingsSection;
742 if (clientSection == null)
745 foreach (SettingElement element in clientSection.Settings) {
746 LoadPropertyValue(collection, element, allowOverwrite);
748 // Only the first one seems to be processed by MS
755 public override void SetPropertyValues (SettingsContext context, SettingsPropertyValueCollection collection)
759 if (UserLocalFullPath == UserRoamingFullPath)
761 SaveProperties (exeMapCurrent, collection, ConfigurationUserLevel.PerUserRoaming, context, false);
763 SaveProperties (exeMapCurrent, collection, ConfigurationUserLevel.PerUserRoaming, context, true);
764 SaveProperties (exeMapCurrent, collection, ConfigurationUserLevel.PerUserRoamingAndLocal, context, true);
768 public override SettingsPropertyValueCollection GetPropertyValues (SettingsContext context, SettingsPropertyCollection collection)
772 if (values == null) {
773 values = new SettingsPropertyValueCollection ();
774 string groupName = context ["GroupName"] as string;
775 LoadProperties (exeMapCurrent, collection, ConfigurationUserLevel.None, "applicationSettings", false, groupName);
776 LoadProperties (exeMapCurrent, collection, ConfigurationUserLevel.None, "userSettings", false, groupName);
778 LoadProperties (exeMapCurrent, collection, ConfigurationUserLevel.PerUserRoaming, "userSettings", true, groupName);
779 LoadProperties (exeMapCurrent, collection, ConfigurationUserLevel.PerUserRoamingAndLocal, "userSettings", true, groupName);
781 // create default values if not exist
782 foreach (SettingsProperty p in collection)
783 if (values [p.Name] == null)
784 values.Add (new SettingsPropertyValue (p));
789 /// creates an ExeConfigurationFileMap
790 private void CreateExeMap ()
792 if (exeMapCurrent == null) {
793 CreateUserConfigPath ();
796 exeMapCurrent = new ExeConfigurationFileMap ();
798 // exeMapCurrent.ExeConfigFilename = System.Windows.Forms.Application.ExecutablePath + ".config";
799 Assembly entry = Assembly.GetEntryAssembly () ?? Assembly.GetExecutingAssembly ();
800 exeMapCurrent.ExeConfigFilename = entry.Location + ".config";
801 exeMapCurrent.LocalUserConfigFilename = UserLocalFullPath;
802 exeMapCurrent.RoamingUserConfigFilename = UserRoamingFullPath;
804 if (webConfigurationFileMapType != null && typeof (ConfigurationFileMap).IsAssignableFrom (webConfigurationFileMapType)) {
806 ConfigurationFileMap cfgFileMap = Activator.CreateInstance (webConfigurationFileMapType) as ConfigurationFileMap;
807 if (cfgFileMap != null) {
808 string fpath = cfgFileMap.MachineConfigFilename;
809 if (!String.IsNullOrEmpty (fpath))
810 exeMapCurrent.ExeConfigFilename = fpath;
818 if ((PrevUserLocalFullPath != "") && (PrevUserRoamingFullPath != ""))
820 exeMapPrev = new ExeConfigurationFileMap();
821 // exeMapPrev.ExeConfigFilename = System.Windows.Forms.Application.ExecutablePath + ".config";
822 exeMapPrev.ExeConfigFilename = entry.Location + ".config";
823 exeMapPrev.LocalUserConfigFilename = PrevUserLocalFullPath;
824 exeMapPrev.RoamingUserConfigFilename = PrevUserRoamingFullPath;
830 public SettingsPropertyValue GetPreviousVersion (SettingsContext context, SettingsProperty property)
835 public void Reset (SettingsContext context)
837 SettingsPropertyCollection coll = new SettingsPropertyCollection ();
838 GetPropertyValues (context, coll);
839 foreach (SettingsPropertyValue propertyValue in values) {
840 // Can't use propertyValue.Property.DefaultValue
841 // as it may cause InvalidCastException (see bug# 532180)
842 propertyValue.PropertyValue = propertyValue.Reset ();
844 SetPropertyValues (context, values);
848 public void Upgrade (SettingsContext context, SettingsPropertyCollection properties)
852 public static void setCreate ()
854 CreateUserConfigPath();