• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IRequestConfiguration类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: TestIndicesUtilCustomization

 public TestIndicesUtilCustomization(
     IRequestConfiguration requestConfig,
     ISettingsProvider settings = null)
 {
     this.settings = settings;
     this.requestConfig = requestConfig;
 }
开发者ID:freemsly,项目名称:Sitecore-ElasticAnalytics,代码行数:7,代码来源:TestIndicesUtilCustomization.cs


示例2: RequestData

		public RequestData(HttpMethod method, string path, PostData<object> data, IConnectionConfigurationValues global, IRequestConfiguration local, IMemoryStreamFactory memoryStreamFactory)
		{
			this.ConnectionSettings = global;
			this.MemoryStreamFactory = memoryStreamFactory;
			this.Method = method;
			this.PostData = data;
			this.Path = this.CreatePathWithQueryStrings(path, this.ConnectionSettings, null);

			this.Pipelined = global.HttpPipeliningEnabled || (local?.EnableHttpPipelining).GetValueOrDefault(false);
			this.HttpCompression = global.EnableHttpCompression;
			this.ContentType = local?.ContentType ?? MimeType;
			this.Headers = global.Headers;

			this.RequestTimeout = local?.RequestTimeout ?? global.RequestTimeout;
			this.PingTimeout = 
				local?.PingTimeout
				?? global?.PingTimeout
				?? (global.ConnectionPool.UsingSsl ? ConnectionConfiguration.DefaultPingTimeoutOnSSL : ConnectionConfiguration.DefaultPingTimeout);

			this.KeepAliveInterval = (int)(global.KeepAliveInterval?.TotalMilliseconds ?? 2000);
			this.KeepAliveTime = (int)(global.KeepAliveTime?.TotalMilliseconds ?? 2000);

			this.ProxyAddress = global.ProxyAddress;
			this.ProxyUsername = global.ProxyUsername;
			this.ProxyPassword = global.ProxyPassword;
			this.DisableAutomaticProxyDetection = global.DisableAutomaticProxyDetection;
			this.BasicAuthorizationCredentials = local?.BasicAuthenticationCredentials ?? global.BasicAuthenticationCredentials;
			this.CancellationToken = local?.CancellationToken ?? CancellationToken.None;
			this.AllowedStatusCodes = local?.AllowedStatusCodes ?? Enumerable.Empty<int>();
		}
开发者ID:jeroenheijmans,项目名称:elasticsearch-net,代码行数:30,代码来源:RequestData.cs


示例3: CreateAsync

        /// <summary>
        /// Calculates the number of required connections for routing and request messages.
        /// </summary>
        /// <param name="routingConfiguration">Contains the number of routing requests in parallel.</param>
        /// <param name="requestConfiguration">Contains the number of requests for P2P operations in parallel.</param>
        /// <param name="builder">The builder that tells us if we should TCP or UDP.</param>
        /// <returns>The future channel creator.</returns>
        public Task<ChannelCreator> CreateAsync(RoutingConfiguration routingConfiguration,
            IRequestConfiguration requestConfiguration, DefaultConnectionConfiguration builder)
        {
            if (routingConfiguration == null && requestConfiguration == null)
            {
                throw new ArgumentException("Both routing configuration and request configuration must be set.");
            }

            int nrConnectionsUdp = 0;
            int nrConnectionsTcp = 0;
            if (requestConfiguration != null)
            {
                if (builder.IsForceUdp)
                {
                    nrConnectionsUdp = requestConfiguration.Parallel;
                }
                else
                {
                    nrConnectionsTcp = requestConfiguration.Parallel;
                }
            }
            if (routingConfiguration != null)
            {
                if (!builder.IsForceTcp)
                {
                    nrConnectionsUdp = Math.Max(nrConnectionsUdp, routingConfiguration.Parallel);
                }
                else
                {
                    nrConnectionsTcp = Math.Max(nrConnectionsTcp, routingConfiguration.Parallel);
                }
            }

            return CreateAsync(nrConnectionsUdp, nrConnectionsTcp);
        }
开发者ID:pacificIT,项目名称:TomP2P.NET,代码行数:42,代码来源:Reservation.cs


示例4: DoAsyncRequest

		protected override Task<ElasticsearchResponse<Stream>> DoAsyncRequest(HttpWebRequest request, byte[] data = null, IRequestConfiguration requestSpecificConfig = null)
		{
			return Task.Factory.StartNew(() =>
			{
				var cs = this.ReturnConnectionStatus(request, data, requestSpecificConfig);
				return cs;
			});
		}
开发者ID:JebteK,项目名称:elasticsearch-net,代码行数:8,代码来源:InMemoryConnection.cs


示例5: HeadSync

		public ElasticsearchResponse<Stream> HeadSync(Uri uri, IRequestConfiguration requestConfiguration = null)
		{
			var restRequest = new RestRequest();
			restRequest.Method = Method.HEAD;
			restRequest.Uri = uri;

			restRequest.Headers = new Dictionary<string, string>();
			restRequest.Headers.Add("Content-Type", "application/json");
			return this.Execute(restRequest, requestConfiguration);
		}
开发者ID:strongant,项目名称:elasticsearch-net,代码行数:10,代码来源:ThriftConnection.cs


示例6: ReturnConnectionStatus

		private ElasticsearchResponse<Stream> ReturnConnectionStatus(HttpWebRequest request, byte[] data, IRequestConfiguration requestSpecificConfig = null)
		{
			var method = request.Method;
			var path = request.RequestUri.ToString();

			var cs = ElasticsearchResponse<Stream>.Create(this.ConnectionSettings, _statusCode, method, path, data);
			cs.Response = new MemoryStream(_fixedResultBytes);
			if (this.ConnectionSettings.ConnectionStatusHandler != null)
				this.ConnectionSettings.ConnectionStatusHandler(cs);
			return cs;
		}
开发者ID:JebteK,项目名称:elasticsearch-net,代码行数:11,代码来源:InMemoryConnection.cs


示例7: CreateHttpWebRequest

        protected override HttpWebRequest CreateHttpWebRequest(Uri uri, string method, byte[] data,
            IRequestConfiguration requestSpecificConfig)
        {
            DateTime tsStart = DateTime.Now;
            HttpWebRequest request = base.CreateHttpWebRequest(uri, method, data, requestSpecificConfig);
            TimeSpan timeSpan = DateTime.Now.Subtract(tsStart);

            RequestHandler.Add(tsStart, timeSpan, request.Method, uri, Encoding.UTF8.GetString(data));

            return request;
        }
开发者ID:icool123,项目名称:Glimpse.ElasticSearch,代码行数:11,代码来源:GlimpseHttpContext.cs


示例8: CreateHttpWebRequest

        protected override HttpWebRequest CreateHttpWebRequest(Uri uri, string method, byte[] data, IRequestConfiguration requestSpecificConfig)
        {
            if (_authType == AuthType.InstanceProfile)
            {
                RefreshCredentials();
            }

            var request = base.CreateHttpWebRequest(uri, method, data, requestSpecificConfig);
            SignV4Util.SignRequest(request, data, _accessKey, _secretKey, _token, _region, "es");
            return request;
        }
开发者ID:emmekappa,项目名称:elasticsearch-net-aws,代码行数:11,代码来源:AwsHttpConnection.cs


示例9: Head

		public Task<ElasticsearchResponse<Stream>> Head(Uri uri, IRequestConfiguration requestConfiguration = null)
		{
			var restRequest = new RestRequest();
			restRequest.Method = Method.HEAD;
			restRequest.Uri = uri;

			restRequest.Headers = new Dictionary<string, string>();
			restRequest.Headers.Add("Content-Type", "application/json");
			return Task.Factory.StartNew<ElasticsearchResponse<Stream>>(() =>
			{
				return this.Execute(restRequest, requestConfiguration);
			});
		}
开发者ID:JebteK,项目名称:elasticsearch-net,代码行数:13,代码来源:ThriftConnection.cs


示例10: CreateIndex

        private void CreateIndex(IRequestConfiguration requestConfig)
        {
            var indexName = requestConfig.GenerateIndexIdentifier(this.ctx);
            this.client.Raw.IndicesCreate(indexName, null);

            const int CircuitBreaker = 2;
            int count = 0;
            do
            {
                if (count > 0) // on retries - wait a bit
                    System.Threading.Thread.Sleep(25);

                // ES creates new indices in an async fashion, so you have to check manually when the index is ready
                // across the whole cluster to receive writes.  Waiting for one healthy shard is good enough.
                this.client.ClusterHealth(p => p.Index(indexName).WaitForActiveShards(1).Timeout("5s"));
                count++;
            }
            while (count <= CircuitBreaker);
        }
开发者ID:freemsly,项目名称:Sitecore-ElasticAnalytics,代码行数:19,代码来源:TestIndexUtils.cs


示例11: DoRequestSync

		/// <summary>
		/// Wraps the DoRequest to run synchronously
		/// </summary>
		/// <param name="method">The method.</param>
		/// <param name="uri">The URI.</param>
		/// <param name="data">The data.</param>
		/// <param name="requestSpecificConfig">The request specific configuration.</param>
		/// <returns>ElasticsearchResponse&lt;Stream&gt;.</returns>
		public ElasticsearchResponse<Stream> DoRequestSync(HttpMethod method, Uri uri, byte[] data = null, IRequestConfiguration requestSpecificConfig = null)
		{
			ThrowIfDisposed();

			var requestTask = DoRequest(method, uri, data, requestSpecificConfig);

			try
			{
				requestTask.Wait();
				return requestTask.Result;
			}
			catch (AggregateException ex)
			{
				return ElasticsearchResponse<Stream>.CreateError(_settings, ex.Flatten(), method.ToString().ToLowerInvariant(), uri.ToString(), data);
			}
			catch (Exception ex)
			{
				return ElasticsearchResponse<Stream>.CreateError(_settings, ex, method.ToString().ToLowerInvariant(), uri.ToString(), data);
			}
		}
开发者ID:JebteK,项目名称:elasticsearch-net,代码行数:28,代码来源:HttpClientConnection.cs


示例12: RequestData

		private RequestData(
			HttpMethod method,
			string path,
			PostData<object> data,
			IConnectionConfigurationValues global,
			IRequestConfiguration local,
			IMemoryStreamFactory memoryStreamFactory)
		{
			this.ConnectionSettings = global;
			this.MemoryStreamFactory = memoryStreamFactory;
			this.Method = method;
			this.PostData = data;

			if (data != null)
				data.DisableDirectStreaming = local?.DisableDirectStreaming ?? global.DisableDirectStreaming;

			this.Path = this.CreatePathWithQueryStrings(path, this.ConnectionSettings, null);

			this.Pipelined = local?.EnableHttpPipelining ?? global.HttpPipeliningEnabled;
			this.HttpCompression = global.EnableHttpCompression;
			this.ContentType = local?.ContentType ?? MimeType;
			this.Accept = local?.Accept ?? MimeType;
			this.Headers = global.Headers != null ? new NameValueCollection(global.Headers) : new NameValueCollection();
			this.RunAs = local?.RunAs;

			this.RequestTimeout = local?.RequestTimeout ?? global.RequestTimeout;
			this.PingTimeout =
				local?.PingTimeout
				?? global?.PingTimeout
				?? (global.ConnectionPool.UsingSsl ? ConnectionConfiguration.DefaultPingTimeoutOnSSL : ConnectionConfiguration.DefaultPingTimeout);

			this.KeepAliveInterval = (int)(global.KeepAliveInterval?.TotalMilliseconds ?? 2000);
			this.KeepAliveTime = (int)(global.KeepAliveTime?.TotalMilliseconds ?? 2000);

			this.ProxyAddress = global.ProxyAddress;
			this.ProxyUsername = global.ProxyUsername;
			this.ProxyPassword = global.ProxyPassword;
			this.DisableAutomaticProxyDetection = global.DisableAutomaticProxyDetection;
			this.BasicAuthorizationCredentials = local?.BasicAuthenticationCredentials ?? global.BasicAuthenticationCredentials;
			this.AllowedStatusCodes = local?.AllowedStatusCodes ?? Enumerable.Empty<int>();
		}
开发者ID:niemyjski,项目名称:elasticsearch-net,代码行数:41,代码来源:RequestData.cs


示例13: CreateWebRequest

		protected virtual HttpWebRequest CreateWebRequest(Uri uri, string method, byte[] data, IRequestConfiguration requestSpecificConfig)
		{
			//TODO append global querystring
			//var url = this._CreateUriString(path);

			var myReq = (HttpWebRequest)WebRequest.Create(uri);
			myReq.Accept = "application/json";
			myReq.ContentType = "application/json";
			myReq.MaximumResponseHeadersLength = -1;
			myReq.Pipelined = false;
			//myReq.AllowWriteStreamBuffering = false;
			if (this.ConnectionSettings.EnableCompressedResponses)
			{
				myReq.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
				myReq.Headers.Add("Accept-Encoding", "gzip,deflate");
			}
			if (requestSpecificConfig != null && !string.IsNullOrWhiteSpace(requestSpecificConfig.ContentType))
			{
				myReq.Accept = requestSpecificConfig.ContentType;
				myReq.ContentType = requestSpecificConfig.ContentType;
			}
			var timeout = GetRequestTimeout(requestSpecificConfig);
			myReq.Timeout = timeout;
			myReq.ReadWriteTimeout = timeout;
			myReq.Method = method;

			//WebRequest won't send Content-Length: 0 for empty bodies
			//which goes against RFC's and might break i.e IIS when used as a proxy.
			//see: https://github.com/elasticsearch/elasticsearch-net/issues/562
			var m = method.ToLowerInvariant();
			if (m != "head" && m != "get" && (data == null || data.Length == 0))
				myReq.ContentLength = 0;

			return myReq;
		}
开发者ID:modulexcite,项目名称:Transformalize,代码行数:35,代码来源:HttpConnection.cs


示例14: DoAsyncRequest

		protected virtual Task<ElasticsearchResponse<Stream>> DoAsyncRequest(HttpWebRequest request, byte[] data = null, IRequestConfiguration requestSpecificConfig = null)
		{
			var tcs = new TaskCompletionSource<ElasticsearchResponse<Stream>>();
			if (this.ConnectionSettings.MaximumAsyncConnections <= 0
			  || this._resourceLock == null)
				return this.CreateIterateTask(request, data, requestSpecificConfig, tcs);

			var timeout = GetRequestTimeout(requestSpecificConfig);
			var path = request.RequestUri.ToString();
			var method = request.Method;
			if (!this._resourceLock.WaitOne(timeout))
			{
				var m = "Could not start the operation before the timeout of " + timeout +
				  "ms completed while waiting for the semaphore";
				var cs = ElasticsearchResponse<Stream>.CreateError(this.ConnectionSettings, new TimeoutException(m), method, path, data);
				tcs.SetResult(cs);
				return tcs.Task;
			}
			try
			{
				return this.CreateIterateTask(request, data, requestSpecificConfig, tcs);
			}
			finally
			{
				this._resourceLock.Release();
			}
		}
开发者ID:modulexcite,项目名称:Transformalize,代码行数:27,代码来源:HttpConnection.cs


示例15: DoSynchronousRequest

		protected virtual ElasticsearchResponse<Stream> DoSynchronousRequest(HttpWebRequest request, byte[] data = null, IRequestConfiguration requestSpecificConfig = null)
		{
			var path = request.RequestUri.ToString();
			var method = request.Method;

			if (data != null)
			{
				using (var r = request.GetRequestStream())
				{
					r.Write(data, 0, data.Length);
				}
			}
			try
			{
				//http://msdn.microsoft.com/en-us/library/system.net.httpwebresponse.getresponsestream.aspx
				//Either the stream or the response object needs to be closed but not both although it won't
				//throw any errors if both are closed atleast one of them has to be Closed.
				//Since we expose the stream we let closing the stream determining when to close the connection
				var response = (HttpWebResponse)request.GetResponse();
				var responseStream = response.GetResponseStream();
				return WebToElasticsearchResponse(data, responseStream, response, method, path);
			}
			catch (WebException webException)
			{
				return HandleWebException(data, webException, method, path);
			}
		}
开发者ID:modulexcite,项目名称:Transformalize,代码行数:27,代码来源:HttpConnection.cs


示例16: Delete

		public virtual Task<ElasticsearchResponse<Stream>> Delete(Uri uri, IRequestConfiguration requestSpecificConfig = null)
		{
			_uriObserver.Observe(uri);
			return Task.FromResult(_responseGenerator.Create());
		}
开发者ID:BiYiTuan,项目名称:elasticsearch-net,代码行数:5,代码来源:NoopConnection.cs


示例17: DoSynchronousRequest

		protected override ElasticsearchResponse<Stream> DoSynchronousRequest(HttpWebRequest request, byte[] data = null, IRequestConfiguration requestSpecificConfig = null)
		{
			return this.ReturnConnectionStatus(request, data, requestSpecificConfig);
		}
开发者ID:JebteK,项目名称:elasticsearch-net,代码行数:4,代码来源:InMemoryConnection.cs


示例18: GetRequestTimeout

		private int GetRequestTimeout(IRequestConfiguration requestConfiguration)
		{
			if (requestConfiguration != null && requestConfiguration.ConnectTimeout.HasValue)
				return requestConfiguration.RequestTimeout.Value;

			return this.ConnectionSettings.Timeout;
		}
开发者ID:modulexcite,项目名称:Transformalize,代码行数:7,代码来源:HttpConnection.cs


示例19: PutSync

		public virtual ElasticsearchResponse<Stream> PutSync(Uri uri, byte[] data, IRequestConfiguration requestSpecificConfig = null)
		{
			_uriObserver.Observe(uri);
			return _responseGenerator.Create();
		}
开发者ID:BiYiTuan,项目名称:elasticsearch-net,代码行数:5,代码来源:NoopConnection.cs


示例20: Post

		public virtual Task<ElasticsearchResponse<Stream>> Post(Uri uri, byte[] data, IRequestConfiguration requestSpecificConfig = null)
		{
			var r = this.CreateHttpWebRequest(uri, "POST", data, requestSpecificConfig);
			return this.DoAsyncRequest(r, data, requestSpecificConfig: requestSpecificConfig);
		}
开发者ID:modulexcite,项目名称:Transformalize,代码行数:5,代码来源:HttpConnection.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IRequestContext类代码示例发布时间:2022-05-24
下一篇:
C# IRequestCallback类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap