public CuratedApiService(HttpClientHandler authenticatedClientHanbdler, string apiBaseAddress = null, bool enableDiagnostics = false)
        {
            if (authenticatedClientHanbdler == null)
            {
                throw new ArgumentNullException(nameof(authenticatedClientHanbdler));
            }

            HttpMessageHandler handler;

            if (enableDiagnostics)
            {
                handler = new HttpClientDiagnosticsHandler(authenticatedClientHanbdler);
            }
            else
            {
                handler = authenticatedClientHanbdler;
            }

            var client = new HttpClient(handler)
            {
                BaseAddress = new Uri(apiBaseAddress ?? ApiBaseAddress)
            };

            _curatedApi = new Lazy <ICuratedApi>(() => RestService.For <ICuratedApi>(client));
        }
예제 #2
0
        public WeeklyXamarinApiService(string apiBaseAddress = null, bool enableDiagnostics = false)
        {
            HttpMessageHandler handler;

            if (enableDiagnostics)
            {
                handler = new HttpClientDiagnosticsHandler(new HttpClientHandler());
            }
            else
            {
                handler = new HttpClientHandler();
            }

            var client = new HttpClient(handler)
            {
                BaseAddress = new Uri(apiBaseAddress ?? ApiBaseAddress)
            };

            _weeklyXamarinApi = new Lazy <IWeeklyXamarinApi>(() => RestService.For <IWeeklyXamarinApi>(client));
        }