本文整理汇总了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);
}
示例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())
};
});
}
示例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);
}