44
55namespace GitCredentialManager ;
66
7+ public interface ICredentialManager : ICredentialStore
8+ {
9+ ICommandContext Context { get ; }
10+ }
11+
712/// <summary>
813/// Provides the factory method <see cref="Create"/> to instantiate a
914/// <see cref="ICredentialStore"/> appropriate for the current platform and
@@ -21,11 +26,21 @@ public static class CredentialManager
2126 /// </summary>
2227 /// <param name="namespace">Optional namespace to scope credential operations.</param>
2328 /// <returns>The <see cref="ICredentialStore"/>.</returns>
24- public static ICredentialStore Create ( string ? @namespace = default )
29+ public static ICredentialManager Create ( string ? @namespace = default )
2530 {
2631 // The context already does the check for the platform and configured store to initialize.
2732 // By overriding the settings with our wrapper, we ensure just the namespace is overriden.
28- return new CredentialStore ( new CommandContextWrapper ( new CommandContext ( ) , @namespace ) ) ;
33+ var context = new CommandContextWrapper ( new CommandContext ( ) , @namespace ) ;
34+ return new CredentialManagerStore ( new CredentialStore ( context ) , context ) ;
35+ }
36+
37+ class CredentialManagerStore ( ICredentialStore store , ICommandContext context ) : ICredentialManager
38+ {
39+ public ICommandContext Context => context ;
40+ public void AddOrUpdate ( string service , string account , string secret ) => store . AddOrUpdate ( service , account , secret ) ;
41+ public ICredential Get ( string service , string account ) => store . Get ( service , account ) ;
42+ public IList < string > GetAccounts ( string service ) => store . GetAccounts ( service ) ;
43+ public bool Remove ( string service , string account ) => store . Remove ( service , account ) ;
2944 }
3045
3146 class CommandContextWrapper ( CommandContext context , string ? @namespace ) : ICommandContext
0 commit comments