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


C# IndexQuery.GetIndexQueryUrl方法代码示例

本文整理汇总了C#中IndexQuery.GetIndexQueryUrl方法的典型用法代码示例。如果您正苦于以下问题:C# IndexQuery.GetIndexQueryUrl方法的具体用法?C# IndexQuery.GetIndexQueryUrl怎么用?C# IndexQuery.GetIndexQueryUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IndexQuery的用法示例。


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

示例1: EncodeAndDecodeIndexQuery

		private static IndexQuery EncodeAndDecodeIndexQuery(IndexQuery query)
		{
			string indexQueryUrl = query.GetIndexQueryUrl(Some.String(), Some.String(), Some.String());

			// indexQueryUrl is in the form "/path?querystring#anchor"

			string indexQueryQuerystring = indexQueryUrl.Substring(indexQueryUrl.IndexOf('?') + 1);

			int indexOfPoint = indexQueryQuerystring.IndexOf('#');
			if (indexOfPoint != -1)
			{
				indexQueryQuerystring = indexQueryQuerystring.Substring(0, indexOfPoint);
			}

			IHttpRequest request = MockRepository.GenerateStub<IHttpRequest>();
			IHttpContext context = MockRepository.GenerateMock<IHttpContext>();
			context.Stub(c => c.Request).Return(request);
			request.Stub(r => r.QueryString).Return(HttpUtility.ParseQueryString(indexQueryQuerystring));

			return context.GetIndexQueryFromHttpContext(1024);
		}
开发者ID:robashton,项目名称:ravendb,代码行数:21,代码来源:IndexQueryUrl.cs

示例2: QueryAsync

		/// <summary>
		/// Begins the async query.
		/// </summary>
		/// <param name="index">The index.</param>
		/// <param name="query">The query.</param>
		/// <param name="includes">The include paths</param>
		public Task<QueryResult> QueryAsync(string index, IndexQuery query, string[] includes)
		{
			EnsureIsNotNullOrEmpty(index, "index");
			var path = query.GetIndexQueryUrl(url, index, "indexes");
			if (includes != null && includes.Length > 0)
			{
				path += "&" + string.Join("&", includes.Select(x => "include=" + x).ToArray());
			}
			var request = HttpJsonRequest.CreateHttpJsonRequest(this, path, "GET", credentials, convention);

			return Task.Factory.FromAsync<string>(request.BeginReadResponseString, request.EndReadResponseString, null)
				.ContinueWith(task =>
				{
					JToken json;
					using (var reader = new JsonTextReader(new StringReader(task.Result)))
						json = (JToken)convention.CreateSerializer().Deserialize(reader);

					return new QueryResult
					{
						IsStale = Convert.ToBoolean(json["IsStale"].ToString()),
						IndexTimestamp = json.Value<DateTime>("IndexTimestamp"),
						IndexEtag = new Guid(request.ResponseHeaders["ETag"]),
						Results = json["Results"].Children().Cast<JObject>().ToList(),
						TotalResults = Convert.ToInt32(json["TotalResults"].ToString()),
						IndexName = json.Value<string>("IndexName"),
						SkippedResults = Convert.ToInt32(json["SkippedResults"].ToString())
					};
				});

		}
开发者ID:eldersantos,项目名称:ravendb,代码行数:36,代码来源:AsyncServerClient.cs

示例3: Query

        public void Query(string index, IndexQuery query, string[] includes, CallbackFunction.Load<QueryResult> callback)
        {
            string path = query.GetIndexQueryUrl(string.Empty, index, "indexes");
            if (includes != null && includes.Length > 0)
            {
                path += "&" + string.Join("&", includes.Select(x => "include=" + x).ToArray());
            }

            HttpJsonRequest request;
            this.CreateContext(new Uri(string.Format("{0}/{1}?", this.DatabaseAddress, path)), RequestMethod.GET, out request);

            request.HttpWebRequest.BeginGetResponse((result) => Query_Callback(request, result, callback), request);
        }
开发者ID:andrewdavey,项目名称:ravendb,代码行数:13,代码来源:AsyncServerClient.cs


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