Skip to content

Commit f7c152c

Browse files
committed
Create a path provider to provide an uniform method for getting the root path.
1 parent 3d129b6 commit f7c152c

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

Rubberduck.Parsing/ComReflection/XmlComProjectSerializer.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,19 @@
22
using System.IO;
33
using System.Runtime.Serialization;
44
using System.Xml;
5+
using Rubberduck.SettingsProvider;
56
using Rubberduck.VBEditor;
67

78
namespace Rubberduck.Parsing.ComReflection
89
{
910
public class XmlComProjectSerializer : IComProjectSerializationProvider
1011
{
11-
public static readonly string DefaultSerializationPath =
12-
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Rubberduck", "Declarations");
12+
public readonly string DefaultSerializationPath;
13+
14+
public XmlComProjectSerializer(IPersistancePathProvider pathProvider)
15+
{
16+
DefaultSerializationPath = pathProvider.DataFolderPath("Declarations");
17+
}
1318

1419
private static readonly XmlReaderSettings ReaderSettings = new XmlReaderSettings
1520
{
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace Rubberduck.SettingsProvider
2+
{
3+
public interface IPersistancePathProvider
4+
{
5+
string DataRootPath { get; }
6+
string DataFolderPath(string folderName);
7+
}
8+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.IO;
3+
4+
namespace Rubberduck.SettingsProvider
5+
{
6+
public class PersistancePathProvider : IPersistancePathProvider
7+
{
8+
public string DataRootPath => Path.Combine(
9+
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
10+
"Rubberduck");
11+
12+
public string DataFolderPath(string folderName)
13+
{
14+
return Path.Combine(DataRootPath, folderName);
15+
}
16+
}
17+
}

0 commit comments

Comments
 (0)