@@ -13,7 +13,7 @@ namespace Rubberduck.SettingsProvider
1313 {
1414 private const string DefaultConfigFile = "rubberduck.config" ;
1515
16- protected readonly string RootPath = Path . Combine ( Environment . GetFolderPath ( Environment . SpecialFolder . ApplicationData ) , "Rubberduck" ) ;
16+ protected readonly string RootPath ;
1717 protected static readonly UTF8Encoding OutputEncoding = new UTF8Encoding ( false ) ;
1818 protected const string RootElement = "Configuration" ;
1919
@@ -28,6 +28,12 @@ namespace Rubberduck.SettingsProvider
2828
2929 protected T Cached { get ; set ; }
3030
31+ protected XmlPersistanceServiceBase ( )
32+ {
33+ var pathProvider = PersistancePathProvider . Instance ;
34+ RootPath = pathProvider . DataRootPath ;
35+ }
36+
3137 private string _filePath ;
3238 public virtual string FilePath
3339 {
@@ -41,11 +47,16 @@ public virtual string FilePath
4147
4248 protected static T FailedLoadReturnValue ( )
4349 {
44- return ( T ) Convert . ChangeType ( null , typeof ( T ) ) ;
50+ return new T ( ) ;
4551 }
4652
4753 protected static XDocument GetConfigurationDoc ( string file )
4854 {
55+ if ( ! File . Exists ( file ) )
56+ {
57+ return new XDocument ( ) ;
58+ }
59+
4960 XDocument output ;
5061 try
5162 {
@@ -78,10 +89,5 @@ protected void EnsurePathExists()
7889 Directory . CreateDirectory ( folder ) ;
7990 }
8091 }
81-
82- protected T CachedOrNotFound ( )
83- {
84- return ! File . Exists ( FilePath ) ? FailedLoadReturnValue ( ) : Cached ;
85- }
8692 }
8793}
0 commit comments