@@ -32,9 +32,8 @@ class Keychain : IKeychain
32
32
33
33
private readonly ILogging logger = Logging . GetLogger < Keychain > ( ) ;
34
34
35
- private readonly IEnvironment environment ;
36
35
private readonly ICredentialManager credentialManager ;
37
- private readonly string cachePath ;
36
+ private readonly NPath cachePath ;
38
37
39
38
// loaded at the start of application from cached/serialized data
40
39
private Dictionary < UriString , Connection > connectionCache = new Dictionary < UriString , Connection > ( ) ;
@@ -43,17 +42,14 @@ class Keychain : IKeychain
43
42
private readonly Dictionary < UriString , KeychainAdapter > keychainAdapters
44
43
= new Dictionary < UriString , KeychainAdapter > ( ) ;
45
44
46
- private IFileSystem FileSystem => environment . FileSystem ;
47
-
48
45
public Keychain ( IEnvironment environment , ICredentialManager credentialManager )
49
46
{
50
47
Guard . ArgumentNotNull ( environment , nameof ( environment ) ) ;
51
48
Guard . ArgumentNotNull ( credentialManager , nameof ( credentialManager ) ) ;
52
49
53
50
Guard . NotNull ( environment , environment . UserCachePath , nameof ( environment . UserCachePath ) ) ;
54
51
55
- cachePath = environment . UserCachePath . Combine ( ConnectionFile ) . ToString ( ) ;
56
- this . environment = environment ;
52
+ cachePath = environment . UserCachePath . Combine ( ConnectionFile ) ;
57
53
this . credentialManager = credentialManager ;
58
54
}
59
55
@@ -108,17 +104,17 @@ private void ReadCacheFromDisk()
108
104
109
105
ConnectionCacheItem [ ] connections = null ;
110
106
111
- if ( FileSystem . FileExists ( cachePath ) )
107
+ if ( cachePath . FileExists ( ) )
112
108
{
113
- var json = FileSystem . ReadAllText ( cachePath ) ;
109
+ var json = cachePath . ReadAllText ( ) ;
114
110
try
115
111
{
116
112
connections = SimpleJson . DeserializeObject < ConnectionCacheItem [ ] > ( json ) ;
117
113
}
118
114
catch ( Exception ex )
119
115
{
120
116
logger . Error ( ex , "Error deserializing connection cache: {0}" , cachePath ) ;
121
- FileSystem . FileDelete ( cachePath ) ;
117
+ cachePath . Delete ( ) ;
122
118
}
123
119
}
124
120
@@ -147,7 +143,7 @@ private void WriteCacheToDisk()
147
143
} ) . ToArray ( ) ;
148
144
149
145
var json = SimpleJson . SerializeObject ( connectionCacheItems ) ;
150
- FileSystem . WriteAllText ( cachePath , json ) ;
146
+ cachePath . WriteAllText ( json ) ;
151
147
}
152
148
153
149
public async Task Clear ( UriString host , bool deleteFromCredentialManager )
0 commit comments