コード例 #1
0
        /// <summary></summary>
        /// <param name="baseUri">The base URL that all HTTP calls methods will refer to.</param>
        // ReSharper disable once UnusedParameter.Local
        public HttpSender(string baseUri)
        {
            try
            {
                if (!string.IsNullOrWhiteSpace(baseUri))
                {
                    BaseUri = new Uri(baseUri);
                }
            }
            catch (UriFormatException e)
            {
                InternalContract.Fail($"The format of {nameof(baseUri)} ({baseUri}) is not correct: {e.Message}");
            }
            lock (LockClass)
            {
                if (DefaultHttpClient == null)
                {
                    var handlers   = OutboundPipeFactory.CreateDelegatingHandlers();
                    var httpClient = HttpClientFactory.Create(handlers);
                    DefaultHttpClient = new HttpClientWrapper(httpClient);
                }
            }

            HttpClient = new HttpClientWrapper(DefaultHttpClient.ActualHttpClient)
            {
                SimulateOutgoingCalls = DefaultHttpClient.SimulateOutgoingCalls
            };
            Log.LogVerbose($"Created REST client {GetType().FullName}: {baseUri}");
        }
コード例 #2
0
        /// <inheritdoc />
        protected override void DependencyInjectServices(IServiceCollection services)
        {
            base.DependencyInjectServices(services);

            //
            // Nexus services
            //

            // Authentication
            services.AddScoped <IAuthenticationCapability>(provider =>
                                                           ValidateDependencyInjection(provider,
                                                                                       p => new AuthenticationCapability(NexusLinkAuthenticationBaseUrl, GetNexusCredentials())));

            // Business Events
            services.AddScoped <IBusinessEventsCapability>(provider =>
                                                           ValidateDependencyInjection(provider, p =>
                                                                                       new BusinessEventsCapability(BusinessEventsBaseUrl, GetNexusCredentials())));

            // Adapter services
            var httpClient = HttpClientFactory.Create(OutboundPipeFactory.CreateDelegatingHandlers());

            // Invoicing
            var invoicingUrl = FulcrumApplication.AppSettings.GetString("InvoiceCapability.Url", true);

            services.AddScoped <IInvoicingCapability>(provider =>
                                                      ValidateDependencyInjection(provider, p =>
                                                                                  new InvoicingCapability($"{invoicingUrl}", httpClient, GetLocalCredentials())));
        }
コード例 #3
0
 public ServiceAuthenticationHelper()
 {
     lock (LockClass)
     {
         if (HttpClient != null)
         {
             return;
         }
         var handlers   = OutboundPipeFactory.CreateDelegatingHandlers();
         var httpClient = HttpClientFactory.Create(handlers);
         HttpClient = new HttpClientWrapper(httpClient);
     }
 }
コード例 #4
0
        /// <inheritdoc />
        protected override void DependencyInjectServices(IServiceCollection services)
        {
            base.DependencyInjectServices(services);
            var httpClient = HttpClientFactory.Create(OutboundPipeFactory.CreateDelegatingHandlers());
            var serviceClientCredentials = GetLocalCredentials();

            //
            // Capabilities
            //

            // NexusApi
            services.AddScoped <INexusApiCapability>(p => new NexusApiCapability());

            // Register all controllers
            this.RegisterCapabilityControllers();
        }