GetIndexQueryUrl() public method

public GetIndexQueryUrl ( string operationUrl, string index, string operationName ) : string
operationUrl string
index string
operationName string
return string
コード例 #1
0
ファイル: AsyncServerClient.cs プロジェクト: vinone/ravendb
        /// <summary>
        /// Begins the async query.
        /// </summary>
        /// <param name="index">The index.</param>
        /// <param name="query">The query.</param>
        /// <returns></returns>
        public Task<QueryResult> QueryAsync(string index, IndexQuery query)
        {
            EnsureIsNotNullOrEmpty(index, "index");
            var path = query.GetIndexQueryUrl(url, index, "indexes");
            var request = HttpJsonRequest.CreateHttpJsonRequest(this, path, "GET", credentials);

            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"),
                        Results = json["Results"].Children().Cast<JObject>().ToList(),
                        TotalResults = Convert.ToInt32(json["TotalResults"].ToString()),
                        SkippedResults = Convert.ToInt32(json["SkippedResults"].ToString())
                    };
                });
        }
コード例 #2
0
ファイル: IndexQueryUrl.cs プロジェクト: Rationalle/ravendb
        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);
        }
コード例 #3
0
		public IAsyncResult BeginQuery(string index, IndexQuery query, AsyncCallback callback, object state)
		{
			EnsureIsNotNullOrEmpty(index, "index");
			string path = query.GetIndexQueryUrl(url, index, "indexes");
			var request = HttpJsonRequest.CreateHttpJsonRequest(this, path, "GET", credentials);

			var asyncCallback = callback;
			if (callback != null)
				asyncCallback = ar => callback(new UserAsyncData(request, ar));

			var asyncResult = request.BeginReadResponseString(asyncCallback, state);
			return new UserAsyncData(request, asyncResult);
		}