Permalink
Browse files

Replaced usages of CouchRequest with ICouchRequest

  • Loading branch information...
1 parent b8775a0 commit 97e5d25653e3f99a5b2e7f5c857add339c59bc8b Sebastian Negomireanu committed Dec 10, 2009
View
6 src/CouchDatabase.cs
@@ -89,12 +89,12 @@ public void SynchDesignDocuments()
}
}
- public CouchRequest Request()
+ public ICouchRequest Request()
{
return new CouchRequest(this);
}
- public CouchRequest Request(string path)
+ public ICouchRequest Request(string path)
{
return (new CouchRequest(this)).Path(path);
}
@@ -104,7 +104,7 @@ public int CountDocuments()
return (Request().Parse())["doc_count"].Value<int>();
}
- public CouchRequest RequestAllDocuments()
+ public ICouchRequest RequestAllDocuments()
{
return Request("_all_docs");
}
View
4 src/CouchQuery.cs
@@ -211,7 +211,7 @@ public bool IsCachedAndValid()
{
return false;
}
- CouchRequest req = View.Request().QueryOptions(Options);
+ ICouchRequest req = View.Request().QueryOptions(Options);
req.Etag(Result.etag);
return req.Head().Send().IsETagValid();
}
@@ -223,7 +223,7 @@ public string String()
}
- public CouchRequest Request()
+ public ICouchRequest Request()
{
var req = View.Request().QueryOptions(Options);
if (postData != null)
View
38 src/CouchRequest.cs
@@ -42,26 +42,26 @@ public CouchRequest(ICouchDatabase db)
this.db = db;
}
- public CouchRequest Etag(string value)
+ public ICouchRequest Etag(string value)
{
etagToCheck = value;
headers["If-Modified"] = value;
return this;
}
- public CouchRequest Path(string name)
+ public ICouchRequest Path(string name)
{
path = name;
return this;
}
- public CouchRequest Query(string name)
+ public ICouchRequest Query(string name)
{
query = name;
return this;
}
- public CouchRequest QueryOptions(ICollection<KeyValuePair<string, string>> options)
+ public ICouchRequest QueryOptions(ICollection<KeyValuePair<string, string>> options)
{
if (options == null || options.Count == 0)
{
@@ -88,73 +88,73 @@ public CouchRequest QueryOptions(ICollection<KeyValuePair<string, string>> optio
/// Turn the request into a HEAD request, HEAD requests are problematic
/// under Mono 2.4, but has been fixed in later releases.
/// </summary>
- public CouchRequest Head()
+ public ICouchRequest Head()
{
// NOTE: We need to do this until next release of mono where HEAD requests have been fixed!
method = server.RunningOnMono ? "GET" : "HEAD";
return this;
}
- public CouchRequest Copy()
+ public ICouchRequest Copy()
{
method = "COPY";
return this;
}
- public CouchRequest PostJson()
+ public ICouchRequest PostJson()
{
MimeTypeJson();
return Post();
}
- public CouchRequest Post()
+ public ICouchRequest Post()
{
method = "POST";
return this;
}
- public CouchRequest Get()
+ public ICouchRequest Get()
{
method = "GET";
return this;
}
- public CouchRequest Put()
+ public ICouchRequest Put()
{
method = "PUT";
return this;
}
- public CouchRequest Delete()
+ public ICouchRequest Delete()
{
method = "DELETE";
return this;
}
- public CouchRequest Data(string data)
+ public ICouchRequest Data(string data)
{
return Data(Encoding.UTF8.GetBytes(data));
}
- public CouchRequest Data(byte[] data)
+ public ICouchRequest Data(byte[] data)
{
postStream = new MemoryStream(data);
return this;
}
- public CouchRequest Data(Stream dataStream)
+ public ICouchRequest Data(Stream dataStream)
{
postStream = dataStream;
return this;
}
- public CouchRequest MimeType(string type)
+ public ICouchRequest MimeType(string type)
{
mimeType = type;
return this;
}
- public CouchRequest MimeTypeJson()
+ public ICouchRequest MimeTypeJson()
{
MimeType("application/json");
return this;
@@ -175,7 +175,7 @@ public string Etag()
return etag;
}
- public CouchRequest Check(string message)
+ public ICouchRequest Check(string message)
{
try
{
@@ -339,7 +339,7 @@ private WebResponse GetResponse()
return GetRequest().GetResponse();
}
- public CouchRequest Send()
+ public ICouchRequest Send()
{
using (WebResponse response = GetResponse())
{
@@ -353,7 +353,7 @@ public bool IsETagValid()
return etagToCheck == etag;
}
- public CouchRequest AddHeader(string key, string value)
+ public ICouchRequest AddHeader(string key, string value)
{
headers[key] = value;
return this;
View
2 src/CouchServer.cs
@@ -114,7 +114,7 @@ public string ServerName
get { return Host + ":" + Port; }
}
- public CouchRequest Request()
+ public ICouchRequest Request()
{
return new CouchRequest(this);
}
View
2 src/CouchViewDefinitionBase.cs
@@ -16,7 +16,7 @@ public ICouchDatabase Db()
return Doc.Owner;
}
- public CouchRequest Request()
+ public ICouchRequest Request()
{
return Db().Request(Path());
}
View
6 src/ICouchDatabase.cs
@@ -50,9 +50,9 @@ public interface ICouchDatabase
Newtonsoft.Json.Linq.JObject ReadDocument(string documentId);
void ReadDocumentIfChanged(ICouchDocument document);
string ReadDocumentString(string documentId);
- CouchRequest Request(string path);
- CouchRequest Request();
- CouchRequest RequestAllDocuments();
+ ICouchRequest Request(string path);
+ ICouchRequest Request();
+ ICouchRequest RequestAllDocuments();
bool RunningOnMono();
T SaveArbitraryDocument<T>(T document);
void SaveArbitraryDocuments<T>(System.Collections.Generic.IEnumerable<T> documents, bool allOrNothing);
View
38 src/ICouchRequest.cs
@@ -3,32 +3,32 @@ namespace Divan
{
public interface ICouchRequest
{
- CouchRequest AddHeader(string key, string value);
- CouchRequest Check(string message);
- CouchRequest Copy();
- CouchRequest Data(System.IO.Stream dataStream);
- CouchRequest Data(string data);
- CouchRequest Data(byte[] data);
- CouchRequest Delete();
+ ICouchRequest AddHeader(string key, string value);
+ ICouchRequest Check(string message);
+ ICouchRequest Copy();
+ ICouchRequest Data(System.IO.Stream dataStream);
+ ICouchRequest Data(string data);
+ ICouchRequest Data(byte[] data);
+ ICouchRequest Delete();
string Etag();
- CouchRequest Etag(string value);
- CouchRequest Get();
- CouchRequest Head();
+ ICouchRequest Etag(string value);
+ ICouchRequest Get();
+ ICouchRequest Head();
bool IsETagValid();
- CouchRequest MimeType(string type);
- CouchRequest MimeTypeJson();
+ ICouchRequest MimeType(string type);
+ ICouchRequest MimeTypeJson();
T Parse<T>() where T : Newtonsoft.Json.Linq.JToken;
Newtonsoft.Json.Linq.JObject Parse();
- CouchRequest Path(string name);
- CouchRequest Post();
- CouchRequest PostJson();
- CouchRequest Put();
- CouchRequest Query(string name);
- CouchRequest QueryOptions(System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<string, string>> options);
+ ICouchRequest Path(string name);
+ ICouchRequest Post();
+ ICouchRequest PostJson();
+ ICouchRequest Put();
+ ICouchRequest Query(string name);
+ ICouchRequest QueryOptions(System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<string, string>> options);
System.Net.WebResponse Response();
T Result<T>() where T : Newtonsoft.Json.Linq.JToken;
Newtonsoft.Json.Linq.JObject Result();
- CouchRequest Send();
+ ICouchRequest Send();
Newtonsoft.Json.JsonTextReader Stream();
string String();
}
View
2 src/ICouchServer.cs
@@ -17,7 +17,7 @@ public interface ICouchServer
ICouchDatabase GetNewDatabase(string name);
T GetNewDatabase<T>(string name) where T : ICouchDatabase, new();
bool HasDatabase(string name);
- CouchRequest Request();
+ ICouchRequest Request();
string ServerName { get; }
string DatabasePrefix { get; set; }
bool RunningOnMono { get; }
View
2 src/ICouchViewDefinitionBase.cs
@@ -7,6 +7,6 @@ public interface ICouchViewDefinitionBase
CouchDesignDocument Doc { get; set; }
string Name { get; set; }
string Path();
- CouchRequest Request();
+ ICouchRequest Request();
}
}
View
4 src/Lucene/CouchLuceneQuery.cs
@@ -171,7 +171,7 @@ public bool IsCachedAndValid()
{
return false;
}
- CouchRequest req = View.Request().QueryOptions(Options);
+ ICouchRequest req = View.Request().QueryOptions(Options);
req.Etag(Result.etag);
return req.Head().Send().IsETagValid();
}
@@ -182,7 +182,7 @@ public string String()
}
- public CouchRequest Request()
+ public ICouchRequest Request()
{
var req = View.Request().QueryOptions(Options);
if (postData != null)

0 comments on commit 97e5d25

Please sign in to comment.