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


C# Data.GetResponse类代码示例

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


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

示例1: HandleResponses

		public void HandleResponses(GetResponse[] responses, ShardStrategy shardStrategy)
		{
			var result = new FacetResults();

			foreach (var response in responses.Select(response => (RavenJObject)response.Result))
			{
				var facet = response.JsonDeserialization<FacetResults>();
				foreach (var facetResult in facet.Results)
				{
					if (!result.Results.ContainsKey(facetResult.Key))
						result.Results[facetResult.Key] = new FacetResult();

					var newFacetResult = result.Results[facetResult.Key];
					foreach (var facetValue in facetResult.Value.Values)
					{
						var existingFacetValueRange = newFacetResult.Values.Find((x) => x.Range == facetValue.Range);
						if (existingFacetValueRange != null)
							existingFacetValueRange.Hits += facetValue.Hits;
						else
							newFacetResult.Values.Add(new FacetValue() { Hits = facetValue.Hits, Range = facetValue.Range });
					}

					foreach (var facetTerm in facetResult.Value.RemainingTerms)
					{
						if (!newFacetResult.RemainingTerms.Contains(facetTerm))
							newFacetResult.RemainingTerms.Add(facetTerm);
					}
				}
			}

			Result = result;
		}
开发者ID:WimVergouwe,项目名称:ravendb,代码行数:32,代码来源:LazyFacetsOperation.cs

示例2: MultiGetHttpContext

			public MultiGetHttpContext(IRavenHttpConfiguration configuration, IHttpContext realContext, GetRequest req)
			{
				this.configuration = configuration;
				this.realContext = realContext;
				getResponse = new GetResponse();
				Request = new MultiGetHttpRequest(req, realContext.Request);
				Response = new MultiGetHttpResponse(getResponse, realContext.Response);
			}
开发者ID:larsudengaard,项目名称:ravendb,代码行数:8,代码来源:MultiGet.cs

示例3: HandleRequest

		private void HandleRequest(GetRequest[] requests, GetResponse[] results, int i, IHttpContext context, IRavenHttpConfiguration ravenHttpConfiguration, MultiGetHttpContext[] contexts)
		{
			var request = requests[i];
			if (request == null)
				return;
			server.HandleActualRequest(contexts[i]);
			results[i] = contexts[i].Complete();
		}
开发者ID:nhsevidence,项目名称:ravendb,代码行数:8,代码来源:MultiGet.cs

示例4: HandleRequest

		private void HandleRequest(GetRequest[] requests, GetResponse[] results, int i, IHttpContext context, IRavenHttpConfiguration ravenHttpConfiguration)
		{
			var request = requests[i];
			if (request == null)
				return;
			var ctx = new MultiGetHttpContext(ravenHttpConfiguration, context, request, TenantId);
			server.HandleActualRequest(ctx);
			results[i] = ctx.Complete();
		}
开发者ID:wbinford,项目名称:ravendb,代码行数:9,代码来源:MultiGet.cs

示例5: HandleResponse

		public void HandleResponse(GetResponse response)
		{
            if (response.RequestHasErrors())
            {
                throw new InvalidOperationException("Got an unexpected response code for the request: " + response.Status + "\r\n" + response.Result);
            }

			var result = (RavenJObject)response.Result;
			Result = result.JsonDeserialization<FacetResults>();
		}
开发者ID:felipeleusin,项目名称:ravendb,代码行数:10,代码来源:LazyFacetsOperation.cs

示例6: HandleResponse

		public void HandleResponse(GetResponse response)
		{
			if (response.Status != 200)
			{
				throw new InvalidOperationException("Got an unexpected response code for the request: " + response.Status + "\r\n" +
				                                    response.Result);
			}

			var result = RavenJObject.Parse(response.Result);
			Result = result.JsonDeserialization<IDictionary<string, IEnumerable<FacetValue>>>();
		}
开发者ID:robinminto,项目名称:ravendb,代码行数:11,代码来源:LazyFacetsOperation.cs

示例7: HandleResponses

		public void HandleResponses(GetResponse[] responses, ShardStrategy shardStrategy)
		{
			var result = new SuggestionQueryResult
			{
				Suggestions = responses
					.Select(item => RavenJObject.Parse(item.Result))
					.SelectMany(data => ((RavenJArray) data["Suggestions"]).Select(x => x.Value<string>()))
					.Distinct()
					.ToArray()
			};

			Result = result;
		}
开发者ID:robinminto,项目名称:ravendb,代码行数:13,代码来源:LazySuggestOperation.cs

示例8: HandleResponse

		public void HandleResponse(GetResponse response)
		{
			if (response.Status != 200 && response.Status != 304)
			{
				throw new InvalidOperationException("Got an unexpected response code for the request: " + response.Status + "\r\n" +
													response.Result);
			}

			var result = (RavenJObject)response.Result;
			Result = new SuggestionQueryResult
			{
				Suggestions = ((RavenJArray)result["Suggestions"]).Select(x => x.Value<string>()).ToArray(),
			};
		}
开发者ID:WimVergouwe,项目名称:ravendb,代码行数:14,代码来源:LazySuggestOperation.cs

示例9: HandleResponses

		public void HandleResponses(GetResponse[] responses, ShardStrategy shardStrategy)
		{
			var result = new SuggestionQueryResult
			{
				Suggestions = (from item in responses
							   let data = (RavenJObject)item.Result
							   from suggestion in (RavenJArray)data["Suggestions"]
							   select suggestion.Value<string>())
							  .Distinct()
							  .ToArray()
			};

			Result = result;
		}
开发者ID:WimVergouwe,项目名称:ravendb,代码行数:14,代码来源:LazySuggestOperation.cs

示例10: HandleRequest

		private void HandleRequest(GetRequest[] requests, GetResponse[] results, int i, IHttpContext context, InMemoryRavenConfiguration ravenHttpConfiguration, MultiGetHttpContext[] contexts)
		{
			var request = requests[i];
			if (request == null)
				return;
		    ravenHttpConfiguration.ConcurrentMultiGetRequests.Wait();
		    try
		    {
		        server.HandleActualRequest(contexts[i]);
		    }
		    finally 
            {
                ravenHttpConfiguration.ConcurrentMultiGetRequests.Release();
		    }
			results[i] = contexts[i].Complete();
		}
开发者ID:925coder,项目名称:ravendb,代码行数:16,代码来源:MultiGet.cs

示例11: HandleCachingResponse

		public GetResponse[] HandleCachingResponse(GetResponse[] responses, HttpJsonRequestFactory jsonRequestFactory)
		{
			var hasCachedRequests = false;
			var requestStatuses = new RequestStatus[responses.Length];
			for (int i = 0; i < responses.Length; i++)
			{
				if (responses[i] == null || responses[i].Status == 304)
				{
					hasCachedRequests = true;

					requestStatuses[i] = responses[i] == null ? RequestStatus.AggressivelyCached : RequestStatus.Cached;
					responses[i] = responses[i] ?? new GetResponse { Status = 0 };

					foreach (string header in cachedData[i].Headers)
					{
						responses[i].Headers[header] = cachedData[i].Headers[header];
					}
					responses[i].Result = cachedData[i].Data.CloneToken();
					jsonRequestFactory.IncrementCachedRequests();
				}
				else
				{
					requestStatuses[i] = responses[i].RequestHasErrors() ? RequestStatus.ErrorOnServer : RequestStatus.SentToServer;

					var nameValueCollection = new NameValueCollection();
					foreach (var header in responses[i].Headers)
					{
						nameValueCollection[header.Key] = header.Value;
					}
					jsonRequestFactory.CacheResponse(url + requests[i].UrlAndQuery, responses[i].Result, nameValueCollection);
				}
			}

			if (hasCachedRequests == false || convention.DisableProfiling ||
                holdProfilingInformation.ProfilingInformation.Requests.Count == 0)
				return responses;

			var lastRequest = holdProfilingInformation.ProfilingInformation.Requests.Last();
			for (int i = 0; i < requestStatuses.Length; i++)
			{
				lastRequest.AdditionalInformation["NestedRequestStatus-" + i] = requestStatuses[i].ToString();
			}
			lastRequest.Result = JsonConvert.SerializeObject(responses);

			return responses;
		}
开发者ID:cocytus,项目名称:ravendb,代码行数:46,代码来源:MultiGetOperation.cs

示例12: Respond

		public override void Respond(IHttpContext context)
		{
			if (recursive.Value)
				throw new InvalidOperationException("Nested requests to multi_get are not supported");
			recursive.Value = true;
			try
			{
				var requests = context.ReadJsonObject<GetRequest[]>();
				var results = new GetResponse[requests.Length];

				Executerequests(context, Settings, results, requests);
				
				context.WriteJson(results);
			}
			finally
			{
				recursive.Value = false;
			}
		}
开发者ID:nhsevidence,项目名称:ravendb,代码行数:19,代码来源:MultiGet.cs

示例13: Executerequests

		private void Executerequests(
			IHttpContext context, 
			IRavenHttpConfiguration ravenHttpConfiguration, 
			GetResponse[] results,
			GetRequest[] requests)
		{
			if ("yes".Equals(context.Request.QueryString["parallel"], StringComparison.InvariantCultureIgnoreCase))
			{
				Parallel.For(0, requests.Length, position =>
					HandleRequest(requests, results, position, context, ravenHttpConfiguration)
					);
			}
			else
			{
				for (var i = 0; i < requests.Length; i++)
				{
					HandleRequest(requests, results, i, context, ravenHttpConfiguration);
				}
			}
		}
开发者ID:wbinford,项目名称:ravendb,代码行数:20,代码来源:MultiGet.cs

示例14: HandleResponses

		public void HandleResponses(GetResponse[] responses, ShardStrategy shardStrategy)
		{
			var result = new Dictionary<string, IEnumerable<FacetValue>>();

			IEnumerable<IGrouping<string, KeyValuePair<string, IEnumerable<FacetValue>>>> list = responses.Select(response => RavenJObject.Parse(response.Result))
				.SelectMany(jsonResult => jsonResult.JsonDeserialization<IDictionary<string, IEnumerable<FacetValue>>>())
				.GroupBy(x => x.Key);

			foreach (var facet in list)
			{
				var individualFacet = facet.SelectMany(x=>x.Value).GroupBy(x=>x.Range)
					.Select(g=>new FacetValue
					{
						Count = g.Sum(y=>y.Count),
						Range = g.Key
					});
				result[facet.Key] = individualFacet.ToList();
			}

			Result = result;
		}
开发者ID:robinminto,项目名称:ravendb,代码行数:21,代码来源:LazyFacetsOperation.cs

示例15: Executerequests

		private void Executerequests(
			IHttpContext context, 
			IRavenHttpConfiguration ravenHttpConfiguration, 
			GetResponse[] results,
			GetRequest[] requests)
		{
			// Need to create this here to preserve any current TLS data that we have to copy
			var contexts = requests.Select(request => new MultiGetHttpContext(ravenHttpConfiguration, context, request, TenantId))
				.ToArray();
			if ("yes".Equals(context.Request.QueryString["parallel"], StringComparison.InvariantCultureIgnoreCase))
			{
				Parallel.For(0, requests.Length, position =>
					HandleRequest(requests, results, position, context, ravenHttpConfiguration, contexts)
					);
			}
			else
			{
				for (var i = 0; i < requests.Length; i++)
				{
					HandleRequest(requests, results, i, context, ravenHttpConfiguration, contexts);
				}
			}
		}
开发者ID:nhsevidence,项目名称:ravendb,代码行数:23,代码来源:MultiGet.cs


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