Beispiel #1
0
 public HttpCommandDispatcherFactoryImpl(IHttpCommandSerializer httpCommandSerializer,
                                         IUriCommandQueryBuilder uriCommandQueryBuilder,
                                         IHttpClientProvider httpClientProvider)
 {
     _httpCommandSerializer  = httpCommandSerializer;
     _uriCommandQueryBuilder = uriCommandQueryBuilder;
     _httpClientProvider     = httpClientProvider;
 }
 public static void RegisterHttpCommand <TCommand, TResult>(this ICommandRegistry registry,
                                                            Uri uri,
                                                            HttpMethod httpMethod = null,
                                                            Func <string> authenticationHeaderContent      = null,
                                                            IHttpCommandSerializer httpCommandSerializer   = null,
                                                            IUriCommandQueryBuilder uriCommandQueryBuilder = null) where TCommand : ICommand <TResult>
 {
     registry.Register <TCommand, TResult>(() => new HttpCommandDispatcher(new HttpCommandExecuter(
                                                                               uri,
                                                                               httpMethod, authenticationHeaderContent, httpCommandSerializer ?? new JsonCommandSerializer(),
                                                                               uriCommandQueryBuilder ?? new UriCommandQueryBuilder(),
                                                                               HttpCommandingDependencies.HttpClientProvider)));
 }
Beispiel #3
0
 /// <summary>
 /// Will create a HTTP command dispatcher. Note if you've supplied a HttpClient to the AddHttpCommanding methods then you
 /// should use resolve an instance if IHttpCommandDispatcherFactory and use that instances create method to create a
 /// command dispatcher
 /// </summary>
 /// <param name="uri">The uri the command should be sent to</param>
 /// <param name="httpMethod">The verb to send the command with</param>
 /// <param name="authenticationHeaderContent">The content of the authentication header (null if none require)</param>
 /// <param name="serializer">An optional serializer. If unspecified the default JSON serializer will be used.</param>
 /// <param name="uriCommandQueryBuilder">An optional URI command query builder. If unspecified the default command query builder will be used.</param>
 /// <returns></returns>
 public static Func <ICommandDispatcher> Create(
     Uri uri,
     HttpMethod httpMethod = null,
     Func <string> authenticationHeaderContent      = null,
     IHttpCommandSerializer serializer              = null,
     IUriCommandQueryBuilder uriCommandQueryBuilder = null)
 {
     return(() =>
            new HttpCommandDispatcherFactoryImpl(
                serializer ?? new JsonCommandSerializer(),
                uriCommandQueryBuilder ?? new UriCommandQueryBuilder(),
                HttpClientProvider).Create(uri, httpMethod, authenticationHeaderContent));
 }
Beispiel #4
0
 public HttpCommandExecuter(
     Uri uri,
     HttpMethod httpMethod,
     Func <string> authenticationHeaderContent,
     IHttpCommandSerializer serializer,
     IUriCommandQueryBuilder uriCommandQueryBuilder,
     IHttpClientProvider httpClientProvider)
 {
     _uri        = uri;
     _httpMethod = httpMethod ?? HttpMethod.Post;
     _authenticationHeaderContent = authenticationHeaderContent;
     _serializer             = serializer;
     _uriCommandQueryBuilder = uriCommandQueryBuilder;
     _httpClientProvider     = httpClientProvider;
 }