当前位置: 首页>>代码示例>>C#>>正文


C# IHttpClient类代码示例

本文整理汇总了C#中IHttpClient的典型用法代码示例。如果您正苦于以下问题:C# IHttpClient类的具体用法?C# IHttpClient怎么用?C# IHttpClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IHttpClient类属于命名空间,在下文中一共展示了IHttpClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HomeController

 public HomeController(
     IHttpClient client,
     IEndpointsConfiguration endpointsConfiguration)
 {
     _client = client;
     _endpointsConfiguration = endpointsConfiguration;
 }
开发者ID:carlos-vicente,项目名称:Playground,代码行数:7,代码来源:HomeController.cs

示例2: DefaultRequestExecutor

        public DefaultRequestExecutor(
            IHttpClient httpClient,
            IClientApiKey apiKey,
            AuthenticationScheme authenticationScheme,
            ILogger logger,
            IBackoffStrategy defaultBackoffStrategy,
            IBackoffStrategy throttlingBackoffStrategy)
        {
            if (!apiKey.IsValid())
            {
                throw new ApplicationException("API Key is invalid.");
            }

            this.httpClient = httpClient;
            this.syncHttpClient = httpClient as ISynchronousHttpClient;
            this.asyncHttpClient = httpClient as IAsynchronousHttpClient;

            this.apiKey = apiKey;
            this.authenticationScheme = authenticationScheme;

            IRequestAuthenticatorFactory requestAuthenticatorFactory = new DefaultRequestAuthenticatorFactory();
            this.requestAuthenticator = requestAuthenticatorFactory.Create(authenticationScheme);

            this.logger = logger;
            this.defaultBackoffStrategy = defaultBackoffStrategy;
            this.throttlingBackoffStrategy = throttlingBackoffStrategy;
        }
开发者ID:ssankar1234,项目名称:stormpath-sdk-dotnet,代码行数:27,代码来源:DefaultRequestExecutor.cs

示例3: UsageReporter

 public UsageReporter(IApplicationHost applicationHost, IHttpClient httpClient, IUserManager userManager, ILogger logger)
 {
     _applicationHost = applicationHost;
     _httpClient = httpClient;
     _userManager = userManager;
     _logger = logger;
 }
开发者ID:t-andre,项目名称:Emby,代码行数:7,代码来源:UsageReporter.cs

示例4: GetNegotiationResponse

        // virtual to allow mocking
        public virtual Task<NegotiationResponse> GetNegotiationResponse(IHttpClient httpClient, IConnection connection, string connectionData)
        {
            if (httpClient == null)
            {
                throw new ArgumentNullException("httpClient");
            }

            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }

            var negotiateUrl = UrlBuilder.BuildNegotiate(connection, connectionData);

            httpClient.Initialize(connection);

            return httpClient.Get(negotiateUrl, connection.PrepareRequest, isLongRunning: false)
                            .Then(response => response.ReadAsString())
                            .Then(raw =>
                            {
                                if (String.IsNullOrEmpty(raw))
                                {
                                    throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, Resources.Error_ServerNegotiationFailed));
                                }

                                return JsonConvert.DeserializeObject<NegotiationResponse>(raw);
                            });
        }
开发者ID:ZixiangBoy,项目名称:SignalR-1,代码行数:29,代码来源:TransportHelper.cs

示例5: WebSocketTransport

 public WebSocketTransport(IHttpClient client)
     : base(client, "webSockets")
 {
     _disconnectToken = CancellationToken.None;
     ReconnectDelay = TimeSpan.FromSeconds(2);
     _webSocketHandler = new ClientWebSocketHandler(this);
 }
开发者ID:Choulla-Naresh8264,项目名称:SignalR,代码行数:7,代码来源:WebSocketTransport.cs

示例6: ChannelImageProvider

 public ChannelImageProvider(ILiveTvManager liveTvManager, IHttpClient httpClient, ILogger logger, IApplicationHost appHost)
 {
     _liveTvManager = liveTvManager;
     _httpClient = httpClient;
     _logger = logger;
     _appHost = appHost;
 }
开发者ID:softworkz,项目名称:Emby,代码行数:7,代码来源:ChannelImageProvider.cs

示例7: FanArtAlbumProvider

 /// <summary>
 /// Initializes a new instance of the <see cref="FanArtAlbumProvider"/> class.
 /// </summary>
 /// <param name="httpClient">The HTTP client.</param>
 /// <param name="logManager">The log manager.</param>
 /// <param name="configurationManager">The configuration manager.</param>
 /// <param name="providerManager">The provider manager.</param>
 public FanArtAlbumProvider(IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager, IProviderManager providerManager, IFileSystem fileSystem)
     : base(logManager, configurationManager)
 {
     _providerManager = providerManager;
     _fileSystem = fileSystem;
     HttpClient = httpClient;
 }
开发者ID:RomanDengin,项目名称:MediaBrowser,代码行数:14,代码来源:FanArtAlbumProvider.cs

示例8: MovieDbImagesProvider

 /// <summary>
 /// Initializes a new instance of the <see cref="MovieDbImagesProvider"/> class.
 /// </summary>
 /// <param name="logManager">The log manager.</param>
 /// <param name="configurationManager">The configuration manager.</param>
 /// <param name="providerManager">The provider manager.</param>
 /// <param name="jsonSerializer">The json serializer.</param>
 /// <param name="httpClient">The HTTP client.</param>
 public MovieDbImagesProvider(ILogManager logManager, IServerConfigurationManager configurationManager, IProviderManager providerManager, IJsonSerializer jsonSerializer, IHttpClient httpClient)
     : base(logManager, configurationManager)
 {
     _providerManager = providerManager;
     _jsonSerializer = jsonSerializer;
     _httpClient = httpClient;
 }
开发者ID:0sm0,项目名称:MediaBrowser,代码行数:15,代码来源:MovieDbImagesProvider.cs

示例9: PostAsync

 public static EventSignal<IResponse> PostAsync(
     IHttpClient client,
     string url,
     Action<IRequest> prepareRequest)
 {
     return client.PostAsync(url, prepareRequest, null);
 }
开发者ID:PlayFab,项目名称:PlayFab-Samples,代码行数:7,代码来源:IHttpClientExtensions.cs

示例10: PismoInstaller

 public PismoInstaller(IHttpClient httpClient, ILogger logger, IApplicationPaths appPaths, IZipClient zipClient)
 {
     _httpClient = httpClient;
     _logger = logger;
     _appPaths = appPaths;
     _zipClient = zipClient;
 }
开发者ID:AshleyYakeley,项目名称:MediaBrowser.IsoMounting,代码行数:7,代码来源:PismoInstaller.cs

示例11: GetRegistrationStatus

        public static async Task<MBRegistrationRecord> GetRegistrationStatus(IHttpClient httpClient, IJsonSerializer jsonSerializer, string feature, string mb2Equivalent = null, string version = null)
        {
            //check the reg file first to alleviate strain on the MB admin server - must actually check in every 30 days tho
            var reg = new RegRecord {registered = LicenseFile.LastChecked(feature) > DateTime.UtcNow.AddDays(-30)};

            if (!reg.registered)
            {
                var mac = _networkManager.GetMacAddress();
                var data = new Dictionary<string, string> { { "feature", feature }, { "key", SupporterKey }, { "mac", mac }, { "mb2equiv", mb2Equivalent }, { "legacykey", LegacyKey }, { "ver", version }, { "platform", Environment.OSVersion.VersionString } };

                try
                {
                    using (var json = await httpClient.Post(MBValidateUrl, data, CancellationToken.None).ConfigureAwait(false))
                    {
                        reg = jsonSerializer.DeserializeFromStream<RegRecord>(json);
                    }

                    if (reg.registered)
                    {
                        LicenseFile.AddRegCheck(feature);
                    }
                    else
                    {
                        LicenseFile.RemoveRegCheck(feature);
                    }

                }
                catch (Exception e)
                {
                    _logger.ErrorException("Error checking registration status of {0}", e, feature);
                }
            }

            return new MBRegistrationRecord {IsRegistered = reg.registered, ExpirationDate = reg.expDate, RegChecked = true};
        }
开发者ID:jscorrea,项目名称:MediaBrowser,代码行数:35,代码来源:MBRegistration.cs

示例12: FixtureSetup

        public void FixtureSetup()
        {
            HttpClientMock = MockRepository.GenerateMock<IHttpClient>();
            Client = new RestBroadcastClient(HttpClientMock);

            var localTimeZoneRestriction = new CfLocalTimeZoneRestriction(DateTime.Now, DateTime.Now);
            CfResult[] result = { CfResult.Received };
            CfRetryPhoneType[] phoneTypes = { CfRetryPhoneType.FirstNumber };
            var broadcastConfigRestryConfig = new CfBroadcastConfigRetryConfig(1000, 2, result, phoneTypes);
            var expectedTextBroadcastConfig = new CfTextBroadcastConfig(1, DateTime.Now, "fromNumber", localTimeZoneRestriction, broadcastConfigRestryConfig, "Test", CfBigMessageStrategy.DoNotSend);

            ExpectedBroadcast = new CfBroadcast(1894, "broadcast", CfBroadcastStatus.Running, DateTime.Now, CfBroadcastType.Text, expectedTextBroadcastConfig);

            var response = string.Format(
                "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" +
                "<r:ResourceReference xmlns=\"http://api.callfire.com/data\" xmlns:r=\"http://api.callfire.com/resource\">" +
                "<r:Id>{0}</r:Id>" +
                "<r:Location>https://www.callfire.com/api/1.1/rest/broadcast/{0}</r:Location>" +
                "</r:ResourceReference>", ExpectedBroadcast.Id);

            HttpClientMock
                .Stub(j => j.Send(Arg<string>.Is.Equal("/broadcast"),
                    Arg<HttpMethod>.Is.Equal(HttpMethod.Post),
                    Arg<BroadcastRequest>.Matches(x => x.Broadcast.id == ExpectedBroadcast.Id &&
                                                x.Broadcast.Name == ExpectedBroadcast.Name &&
                                                x.Broadcast.LastModified == ExpectedBroadcast.LastModified &&
                                                x.Broadcast.Status == BroadcastStatus.RUNNING &&
                                                x.Broadcast.Type == BroadcastType.TEXT)))
                .Return(response);
        }
开发者ID:vladimir-mhl,项目名称:CallFire-CSharp-SDK,代码行数:30,代码来源:CreateBroadcastRestClientTests.cs

示例13: DlnaEntryPoint

 public DlnaEntryPoint(IServerConfigurationManager config, 
     ILogManager logManager, 
     IServerApplicationHost appHost, 
     INetworkManager network, 
     ISessionManager sessionManager, 
     IHttpClient httpClient, 
     ILibraryManager libraryManager, 
     IUserManager userManager, 
     IDlnaManager dlnaManager, 
     IImageProcessor imageProcessor, 
     IUserDataManager userDataManager, 
     ILocalizationManager localization, 
     IMediaSourceManager mediaSourceManager, 
     ISsdpHandler ssdpHandler)
 {
     _config = config;
     _appHost = appHost;
     _network = network;
     _sessionManager = sessionManager;
     _httpClient = httpClient;
     _libraryManager = libraryManager;
     _userManager = userManager;
     _dlnaManager = dlnaManager;
     _imageProcessor = imageProcessor;
     _userDataManager = userDataManager;
     _localization = localization;
     _mediaSourceManager = mediaSourceManager;
     _ssdpHandler = (SsdpHandler)ssdpHandler;
     _logger = logManager.GetLogger("Dlna");
 }
开发者ID:jrags56,项目名称:MediaBrowser,代码行数:30,代码来源:DlnaEntryPoint.cs

示例14: DataServicePackageRepository

        public DataServicePackageRepository(IHttpClient client, PackageDownloader packageDownloader)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }
            if (packageDownloader == null)
            {
                throw new ArgumentNullException("packageDownloader");
            }

            _httpClient = client;
            _httpClient.AcceptCompression = true;
            
            _packageDownloader = packageDownloader;

            if (EnvironmentUtility.RunningFromCommandLine || EnvironmentUtility.IsMonoRuntime)
            {
                _packageDownloader.SendingRequest += OnPackageDownloaderSendingRequest;
            }
            else
            {
                // weak event pattern            
                SendingRequestEventManager.AddListener(_packageDownloader, this);
            }
        }
开发者ID:aaasoft,项目名称:NuGet.Server,代码行数:26,代码来源:DataServicePackageRepository.cs

示例15: GetTrailerList

        /// <summary>
        /// Downloads a list of trailer info's from the apple url
        /// </summary>
        /// <returns>Task{List{TrailerInfo}}.</returns>
        public static async Task<List<TrailerInfo>> GetTrailerList(IHttpClient httpClient, CancellationToken cancellationToken)
        {
            var stream = await httpClient.Get(new HttpRequestOptions
            {
                Url = TrailerFeedUrl,
                CancellationToken = cancellationToken,
                ResourcePool = Plugin.Instance.AppleTrailers

            }).ConfigureAwait(false);

            var list = new List<TrailerInfo>();

            using (var reader = XmlReader.Create(stream, new XmlReaderSettings { Async = true }))
            {
                await reader.MoveToContentAsync().ConfigureAwait(false);

                while (await reader.ReadAsync().ConfigureAwait(false))
                {
                    cancellationToken.ThrowIfCancellationRequested();

                    if (reader.NodeType == XmlNodeType.Element)
                    {
                        switch (reader.Name)
                        {
                            case "movieinfo":
                                var trailer = FetchTrailerInfo(reader.ReadSubtree());
                                list.Add(trailer);
                                break;
                        }
                    }
                }
            }

            return list;
        }
开发者ID:rrb008,项目名称:MediaBrowser.Plugins,代码行数:39,代码来源:AppleTrailerListingDownloader.cs


注:本文中的IHttpClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。