/
RavenUrlExtensions.cs
99 lines (83 loc) · 2.84 KB
/
RavenUrlExtensions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
using System;
using System.Collections.Generic;
using System.Net;
#if !NET_3_5
using Raven.Client.Connection.Async;
#endif
using Raven.Client.Document;
namespace Raven.Client.Connection
{
public static class RavenUrlExtensions
{
public static string Indexes(this string url, string index)
{
return url + "/indexes/" + index;
}
public static string IndexDefinition(this string url, string index)
{
return url + "/indexes/" + index + "?definition=yes";
}
public static string IndexNames(this string url, int start, int pageSize)
{
return url + "/indexes/?namesOnly=true&start=" + start + "&pageSize=" + pageSize;
}
public static string Stats(this string url)
{
return url + "/stats";
}
//public static string Static(this string url, string key)
//{
// return url + "/static/" + HttpUtility.HtmlEncode(key);
//}
public static string Databases(this string url, int pageSize)
{
return url + "/databases/?pageSize=" + pageSize;
}
public static string SilverlightEnsuresStartup(this string url)
{
return url + "/silverlight/ensureStartup";
}
public static string Terms(this string url, string index, string field, string fromValue, int pageSize)
{
return url + "/terms/" + index + "?field=" + field + "&fromValue=" + fromValue + "&pageSize=" + pageSize;
}
//public static string Docs(this string url, string key)
//{
// return url + "/docs/" + HttpUtility.HtmlEncode(key);
//}
public static string Docs(this string url, int start, int pageSize)
{
return url + "/docs/?start=" + start + "&pageSize=" + pageSize;
}
//public static string DocsStartingWith(this string url, string prefix, int start, int pageSize)
//{
// return Docs(url, start, pageSize) + "&startsWith=" + HttpUtility.HtmlEncode(prefix);
//}
public static string Queries(this string url)
{
return url + "/queries/";
}
public static string NoCache(this string url)
{
return (url.Contains("?"))
? url + "&noCache=" + Guid.NewGuid().GetHashCode()
: url + "?noCache=" + Guid.NewGuid().GetHashCode();
}
public static Uri ToUri(this string url)
{
return new Uri(url);
}
#if !NET_3_5
public static HttpJsonRequest ToJsonRequest(this string url, AsyncServerClient requestor, ICredentials credentials, Document.DocumentConvention convention)
{
return requestor.jsonRequestFactory.CreateHttpJsonRequest(requestor, url, "GET", credentials, convention);
}
public static HttpJsonRequest ToJsonRequest(this string url, AsyncServerClient requestor, ICredentials credentials, DocumentConvention convention, IDictionary<string, string> operationsHeaders, string method)
{
var httpJsonRequest = requestor.jsonRequestFactory.CreateHttpJsonRequest(requestor, url, method, credentials, convention);
httpJsonRequest.AddOperationHeaders(operationsHeaders);
return httpJsonRequest;
}
#endif
}
}