@@ -56,21 +56,16 @@ public GitHubServiceBuilder UseHttpClientFactoryConnection()
56
56
: new HttpClientAdapter ( httpFactory . CreateHandler ) ;
57
57
return adapter ;
58
58
} ) ;
59
-
59
+ Services . TryAddSingleton < IJsonSerializer , SimpleJsonSerializer > ( ) ;
60
60
Services . AddTransient < IConnection , Connection > ( provider =>
61
61
{
62
- var credStore = provider . GetService < ICredentialStore > ( ) ;
63
- if ( credStore is null )
64
- {
65
- return ActivatorUtilities . CreateInstance < Connection > ( provider ) ;
66
- }
67
- else
68
- {
69
- var serializer = provider . GetService < IJsonSerializer > ( )
62
+ var credStore = provider . GetService < ICredentialStore > ( ) ??
63
+ new InMemoryCredentialStore ( Credentials . Anonymous ) ;
64
+ var serializer = provider . GetService < IJsonSerializer > ( )
70
65
?? new SimpleJsonSerializer ( ) ;
71
- return ActivatorUtilities . CreateInstance < Connection > (
72
- provider , GitHubClient . GitHubApiUrl , credStore , serializer ) ;
73
- }
66
+ var client = provider . GetRequiredService < IHttpClient > ( ) ;
67
+ return ActivatorUtilities . CreateInstance < Connection > (
68
+ provider , GitHubClient . GitHubApiUrl , credStore , client , serializer ) ;
74
69
} ) ;
75
70
Services . AddTransient < IApiConnection , ApiConnection > ( ) ;
76
71
@@ -101,7 +96,7 @@ private static Dictionary<Type, Type> GetGitHubClientTypesWithImplementation()
101
96
static void VisitAllClientTypes ( Type interfaceType , Dictionary < Type , Type > knownTypes )
102
97
{
103
98
const BindingFlags ifPropBinding = BindingFlags . Instance | BindingFlags . Public | BindingFlags . NonPublic ;
104
- if ( knownTypes . TryGetValue ( interfaceType , out _ ) )
99
+ if ( knownTypes . TryGetValue ( interfaceType , out _ ) )
105
100
return ; // Interface already known
106
101
107
102
if ( FindImplementationType ( interfaceType ) is Type implType )
0 commit comments