Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

RavenDB-697 Merge the Silverlight & standard Async Server Clients

  • Loading branch information...
commit 1253113e19ffc990ff9595c06b7124b08dce2a40 1 parent c7e943d
DanielDar DanielDar authored
Showing with 237 additions and 1,445 deletions.
  1. +33 −0 Raven.Abstractions/Extensions/MetadataExtensions.cs
  2. +19 −8 Raven.Client.Lightweight/Connection/Async/AsyncServerClient.cs
  3. +4 −1 Raven.Client.Lightweight/Connection/Async/IAsyncDatabaseCommands.cs
  4. +4 −0 Raven.Client.Lightweight/Connection/CachedRequest.cs
  5. +4 −0 Raven.Client.Lightweight/Connection/CreateHttpJsonRequestParams.cs
  6. +0 −4 Raven.Client.Lightweight/Connection/HttpExtensions.cs
  7. +9 −0 Raven.Client.Lightweight/Connection/HttpJsonRequest.cs
  8. +4 −0 Raven.Client.Lightweight/Connection/HttpJsonRequestFactory.cs
  9. +7 −1 Raven.Client.Lightweight/Connection/MultiGetOperation.cs
  10. +3 −0  Raven.Client.Lightweight/Connection/RavenUrlExtensions.cs
  11. +1 −1  Raven.Client.Lightweight/Connection/ReplicationInformer.cs
  12. +7 −10 Raven.Client.Lightweight/Connection/SerializationHelper.cs
  13. +1 −11 Raven.Client.Lightweight/Document/DocumentStore.cs
  14. +0 −3  Raven.Client.Lightweight/Extensions/MultiTenancyExtensions.cs
  15. +0 −3  Raven.Client.Lightweight/Indexes/AbstractIndexCreationTask.cs
  16. +0 −1,229 Raven.Client.Silverlight/Connection/Async/AsyncServerClient.cs
  17. +10 −6 Raven.Client.Silverlight/Connection/HttpJsonRequest.cs
  18. +25 −38 Raven.Client.Silverlight/Connection/HttpJsonRequestFactory.cs
  19. +0 −103 Raven.Client.Silverlight/Connection/RavenUrlExtensions.cs
  20. +61 −0 Raven.Client.Silverlight/MissingFromSilverlight/NameValueCollection.cs
  21. +22 −2 Raven.Client.Silverlight/Raven.Client.Silverlight.csproj
  22. +1 −1  Raven.Studio/Commands/ExportDatabaseCommand.cs
  23. +0 −1  Raven.Studio/Models/DatabaseModel.cs
  24. +0 −1  Raven.Studio/Models/ReplicationStatisticsModel.cs
  25. +22 −22 Raven.Studio/app.config
33 Raven.Abstractions/Extensions/MetadataExtensions.cs
View
@@ -13,6 +13,8 @@
using Raven.Json.Linq;
#if !SILVERLIGHT
using System.Collections.Specialized;
+#else
+using Raven.Client.Silverlight.MissingFromSilverlight;
#endif
namespace Raven.Abstractions.Extensions
@@ -131,6 +133,37 @@ public static RavenJObject FilterHeaders(this RavenJObject self)
}
#if SILVERLIGHT
+ public static RavenJObject FilterHeadersAttachment(this NameValueCollection self)
+ {
+ var filterHeaders = self.FilterHeaders();
+ if (self.ContainsKey("Content-Type"))
+ filterHeaders["Content-Type"] = self["Content-Type"].FirstOrDefault();
+ return filterHeaders;
+ }
+
+ /// <summary>
+ /// Filters the headers from unwanted headers
+ /// </summary>
+ /// <returns></returns>public static RavenJObject FilterHeaders(this System.Collections.Specialized.NameValueCollection self, bool isServerDocument)
+ public static RavenJObject FilterHeaders(this NameValueCollection self)
+ {
+ var metadata = new RavenJObject();
+ foreach (var header in self.Headers)
+ {
+ if (header.Key.StartsWith("Temp"))
+ continue;
+ if (headersToIgnoreClient.Contains(header.Key))
+ continue;
+ var values = header.Value;
+ var headerName = CaptureHeaderName(header.Key);
+ if (values.Count == 1)
+ metadata.Add(headerName, GetValue(values[0]));
+ else
+ metadata.Add(headerName, new RavenJArray(values.Select(GetValue)));
+ }
+ return metadata;
+ }
+
public static RavenJObject FilterHeadersAttachment(this IDictionary<string, IList<string>> self)
{
var filterHeaders = self.FilterHeaders();
27 Raven.Client.Lightweight/Connection/Async/AsyncServerClient.cs
View
@@ -11,10 +11,15 @@
using System.Text;
using System.Threading;
using System.Threading.Tasks;
+#if !SILVERLIGHT
using System.Transactions;
+#endif
using Raven.Abstractions.Json;
using Raven.Abstractions.Util;
using Raven.Client.Listeners;
+#if SILVERLIGHT
+using Raven.Client.Silverlight.Connection;
+#endif
using Raven.Imports.Newtonsoft.Json;
using Raven.Abstractions;
using Raven.Abstractions.Commands;
@@ -51,6 +56,11 @@ public class AsyncServerClient : IAsyncDatabaseCommands
private int requestCount;
private int readStripingBase;
+ public string Url
+ {
+ get { return url; }
+ }
+
/// <summary>
/// Initializes a new instance of the <see cref="AsyncServerClient"/> class.
/// </summary>
@@ -218,7 +228,7 @@ public Task<string> DirectPutIndexAsync(string name, IndexDefinition indexDef, b
.AddOperationHeaders(OperationsHeaders));
var serializeObject = JsonConvert.SerializeObject(indexDef, Default.Converters);
- return Task.Factory.FromAsync(request.BeginWrite, request.EndWrite, serializeObject, null)
+ return request.WriteAsync(serializeObject)
.ContinueWith(writeTask => request.ReadResponseJsonAsync()
.ContinueWith(readJsonTask => { return readJsonTask.Result.Value<string>("index"); })).
Unwrap();
@@ -308,7 +318,7 @@ private Task<PutResult> DirectPutAsync(string opUrl, string key, Guid? etag, Rav
new CreateHttpJsonRequestParams(this, opUrl + "/docs/" + key, method, metadata, credentials, convention)
.AddOperationHeaders(OperationsHeaders));
- return Task.Factory.FromAsync(request.BeginWrite, request.EndWrite, document.ToString(), null)
+ return request.WriteAsync(document.ToString())
.ContinueWith(task =>
{
if (task.Exception != null)
@@ -392,7 +402,7 @@ public Task<JsonDocument> GetAsync(string key)
return ExecuteWithReplication("GET", url => DirectGetAsync(url, key));
}
- private Task<JsonDocument> DirectGetAsync(string opUrl, string key)
+ public Task<JsonDocument> DirectGetAsync(string opUrl, string key)
{
var metadata = new RavenJObject();
AddTransactionInformation(metadata);
@@ -476,8 +486,7 @@ private Task<MultiLoadResult> DirectGetAsync(string opUrl, string[] keys, string
jsonRequestFactory.CreateHttpJsonRequest(new CreateHttpJsonRequestParams(this, path, "POST", credentials,
convention)
.AddOperationHeaders(OperationsHeaders));
- return Task.Factory.FromAsync(request.BeginWrite, request.EndWrite, new RavenJArray(keys).ToString(Formatting.None),
- null)
+ return request.WriteAsync(new RavenJArray(keys).ToString(Formatting.None))
.ContinueWith(writeTask => request.ReadResponseJsonAsync())
.Unwrap()
.ContinueWith(task => CompleteMultiGetAsync(opUrl, keys, includes, task))
@@ -752,7 +761,7 @@ public Task<GetResponse[]> MultiGetAsync(GetRequest[] requests)
}
- return Task.Factory.FromAsync(httpJsonRequest.BeginWrite, httpJsonRequest.EndWrite, postedData, null)
+ return httpJsonRequest.WriteAsync(postedData)
.ContinueWith(
task =>
{
@@ -895,7 +904,7 @@ public Task<BatchResult[]> BatchAsync(ICommandData[] commandDatas)
var jArray = new RavenJArray(commandDatas.Select(x => x.ToJson()));
var data = jArray.ToString(Formatting.None);
- return Task.Factory.FromAsync(req.BeginWrite, req.EndWrite, data, null)
+ return req.WriteAsync(data)
.ContinueWith(writeTask =>
{
writeTask.Wait(); // throw
@@ -947,11 +956,13 @@ private static Exception ThrowConcurrencyException(WebException e)
private static void AddTransactionInformation(RavenJObject metadata)
{
+#if !SILVERLIGHT
if (Transaction.Current == null)
return;
string txInfo = string.Format("{0}, {1}", Transaction.Current.TransactionInformation.DistributedIdentifier, TransactionManager.DefaultTimeout);
metadata["Raven-Transaction-Information"] = new RavenJValue(txInfo);
+#endif
}
private static void EnsureIsNotNullOrEmpty(string key, string argName)
@@ -1016,7 +1027,7 @@ public Task PutAttachmentAsync(string key, Guid? etag, byte[] data, RavenJObject
request.AddOperationHeaders(OperationsHeaders);
return request
- .ExecuteWriteAsync(Encoding.UTF8.GetString(data))
+ .ExecuteWriteAsync(Encoding.UTF8.GetString(data, 0, data.Length))
.ContinueWith(write =>
{
if (write.Exception != null)
5 Raven.Client.Lightweight/Connection/Async/IAsyncDatabaseCommands.cs
View
@@ -11,6 +11,9 @@
using Raven.Abstractions.Data;
using Raven.Abstractions.Indexing;
using Raven.Client.Connection.Profiling;
+#if SILVERLIGHT
+using Raven.Client.Silverlight.Connection;
+#endif
using Raven.Json.Linq;
namespace Raven.Client.Connection.Async
@@ -137,7 +140,7 @@ public interface IAsyncDatabaseCommands : IDisposable, IHoldProfilingInformation
/// <summary>
/// Create a http request to the specified relative url on the current database
/// </summary>
- Silverlight.Connection.HttpJsonRequest CreateRequest(string relativeUrl, string method);
+ HttpJsonRequest CreateRequest(string relativeUrl, string method);
#endif
/// <summary>
4 Raven.Client.Lightweight/Connection/CachedRequest.cs
View
@@ -1,5 +1,9 @@
using System;
+#if !SILVERLIGHT
using System.Collections.Specialized;
+#else
+using Raven.Client.Silverlight.MissingFromSilverlight;
+#endif
using Raven.Json.Linq;
namespace Raven.Client.Connection
4 Raven.Client.Lightweight/Connection/CreateHttpJsonRequestParams.cs
View
@@ -1,6 +1,10 @@
using System;
using System.Collections.Generic;
+#if !SILVERLIGHT
using System.Collections.Specialized;
+#else
+using Raven.Client.Silverlight.MissingFromSilverlight;
+#endif
using System.Linq;
using System.Net;
using Raven.Client.Connection.Profiling;
4 Raven.Client.Lightweight/Connection/HttpExtensions.cs
View
@@ -33,11 +33,7 @@ public static Guid GetEtagHeader(this GetResponse response)
public static Guid GetEtagHeader(this HttpJsonRequest request)
{
-#if SILVERLIGHT
- return EtagHeaderToGuid(request.ResponseHeaders["ETag"].FirstOrDefault());
-#else
return EtagHeaderToGuid(request.ResponseHeaders["ETag"]);
-#endif
}
internal static Guid EtagHeaderToGuid(string responseHeader)
9 Raven.Client.Lightweight/Connection/HttpJsonRequest.cs
View
@@ -8,7 +8,11 @@
using System.Collections.Specialized;
using System.Diagnostics;
using System.IO;
+#if !SILVERLIGHT
using System.IO.Compression;
+#else
+using Raven.Client.Silverlight.MissingFromSilverlight;
+#endif
using System.Net;
using System.Text;
using System.Threading;
@@ -729,5 +733,10 @@ public Task ExecuteWriteAsync(string data)
return new CompletedTask(e);
}
}
+
+ public Task WriteAsync(string serializeObject)
+ {
+ return Task.Factory.FromAsync(BeginWrite, EndWrite, serializeObject, null);
+ }
}
}
4 Raven.Client.Lightweight/Connection/HttpJsonRequestFactory.cs
View
@@ -1,5 +1,9 @@
using System;
+#if !SILVERLIGHT
using System.Collections.Specialized;
+#else
+using Raven.Client.Silverlight.MissingFromSilverlight;
+#endif
using System.Net;
using System.Threading;
using Raven.Abstractions.Extensions;
8 Raven.Client.Lightweight/Connection/MultiGetOperation.cs
View
@@ -1,5 +1,10 @@
using System;
+#if !SILVERLIGHT
using System.Collections.Specialized;
+#else
+using Raven.Client.Silverlight.Connection;
+using Raven.Client.Silverlight.MissingFromSilverlight;
+#endif
using System.Linq;
using System.Net;
using Raven.Imports.Newtonsoft.Json;
@@ -74,7 +79,8 @@ public bool CanFullyCache(HttpJsonRequestFactory jsonRequestFactory, HttpJsonReq
HttpResult = 0,
Status = RequestStatus.AggresivelyCached,
Result = "",
- Url = httpJsonRequest.webRequest.RequestUri.PathAndQuery,
+ Url = httpJsonRequest.webRequest.RequestUri.AbsolutePath + "?" + httpJsonRequest.webRequest.RequestUri.Query,
+ //TODO: check that is the same as: Url = httpJsonRequest.webRequest.RequestUri.PathAndQuery,
PostedData = postedData
});
return true;
3  Raven.Client.Lightweight/Connection/RavenUrlExtensions.cs
View
@@ -3,6 +3,9 @@
using System.Net;
using Raven.Client.Connection.Async;
using Raven.Client.Document;
+#if SILVERLIGHT
+using Raven.Client.Silverlight.Connection;
+#endif
namespace Raven.Client.Connection
{
2  Raven.Client.Lightweight/Connection/ReplicationInformer.cs
View
@@ -20,6 +20,7 @@
using Raven.Abstractions.Logging;
using Raven.Abstractions.Replication;
using Raven.Abstractions.Util;
+using Raven.Client.Connection.Async;
using Raven.Client.Document;
using System.Net;
using System.Net.Sockets;
@@ -27,7 +28,6 @@
using Raven.Client.Extensions;
#if SILVERLIGHT
-using Raven.Client.Silverlight.Connection.Async;
using Raven.Client.Silverlight.MissingFromSilverlight;
using Raven.Json.Linq;
#endif
17 Raven.Client.Lightweight/Connection/SerializationHelper.cs
View
@@ -5,7 +5,11 @@
//-----------------------------------------------------------------------
using System;
using System.Collections.Generic;
+#if !SILVERLIGHT
using System.Collections.Specialized;
+#else
+using Raven.Client.Silverlight.MissingFromSilverlight;
+#endif
using System.Globalization;
using System.Linq;
using System.Net;
@@ -122,23 +126,16 @@ public static QueryResult ToQueryResult(RavenJObject json, Guid etag)
/// Deserialize a request to a JsonDocument
/// </summary>
public static JsonDocument DeserializeJsonDocument(string key, RavenJToken requestJson,
-#if !SILVERLIGHT
NameValueCollection headers,
-#else
- IDictionary<string, IList<string>> headers,
-#endif
+
HttpStatusCode statusCode)
{
var jsonData = (RavenJObject)requestJson;
var meta = headers.FilterHeaders();
-
-#if !SILVERLIGHT
+
var etag = headers["ETag"];
var lastModified = headers[Constants.LastModified];
-#else
- var etag = headers["ETag"].First();
- var lastModified = headers[Constants.LastModified].First();
-#endif
+
return new JsonDocument
{
DataAsJson = jsonData,
12 Raven.Client.Lightweight/Document/DocumentStore.cs
View
@@ -23,7 +23,6 @@
#if SILVERLIGHT
using System.Net.Browser;
using Raven.Client.Silverlight.Connection;
-using Raven.Client.Silverlight.Connection.Async;
#else
using Raven.Client.Listeners;
using Raven.Client.Document.DTC;
@@ -606,19 +605,10 @@ protected virtual void InitializeInternal()
};
#endif
-#if SILVERLIGHT
- // required to ensure just a single auth dialog
- var task = jsonRequestFactory.CreateHttpJsonRequest(new CreateHttpJsonRequestParams(this, (Url + "/docs?pageSize=0").NoCache(), "GET", credentials, Conventions))
- .ExecuteRequestAsync();
-#endif
asyncDatabaseCommandsGenerator = () =>
{
-
-#if SILVERLIGHT
- var asyncServerClient = new AsyncServerClient(Url, Conventions, credentials, jsonRequestFactory, currentSessionId, task, GetReplicationInformerForDatabase, null);
-#else
var asyncServerClient = new AsyncServerClient(Url, Conventions, credentials, jsonRequestFactory, currentSessionId, GetReplicationInformerForDatabase, null, listeners.ConflictListeners);
-#endif
+
if (string.IsNullOrEmpty(DefaultDatabase))
return asyncServerClient;
return asyncServerClient.ForDatabase(DefaultDatabase);
3  Raven.Client.Lightweight/Extensions/MultiTenancyExtensions.cs
View
@@ -4,9 +4,6 @@
// </copyright>
//-----------------------------------------------------------------------
using System;
-#if SILVERLIGHT
-using Raven.Client.Silverlight.Connection.Async;
-#endif
using Raven.Abstractions.Data;
using Raven.Client.Connection;
using Raven.Imports.Newtonsoft.Json;
3  Raven.Client.Lightweight/Indexes/AbstractIndexCreationTask.cs
View
@@ -18,9 +18,6 @@
using Raven.Client.Connection.Async;
using Raven.Client.Document;
using Raven.Json.Linq;
-#if SILVERLIGHT
-using Raven.Client.Silverlight.Connection.Async;
-#endif
namespace Raven.Client.Indexes
{
1,229 Raven.Client.Silverlight/Connection/Async/AsyncServerClient.cs
View
@@ -1,1229 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="AsyncServerClient.cs" company="Hibernating Rhinos LTD">
-// Copyright (c) Hibernating Rhinos LTD. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-using System.Text;
-using System.Windows.Browser;
-using Raven.Abstractions.Exceptions;
-using Raven.Abstractions.Extensions;
-using Raven.Abstractions.Json;
-using Raven.Client.Connection.Async;
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.IO;
-using System.Linq;
-using System.Net;
-using System.Threading;
-using System.Threading.Tasks;
-using Raven.Imports.Newtonsoft.Json;
-using Raven.Imports.Newtonsoft.Json.Linq;
-using Raven.Abstractions.Data;
-using Raven.Client.Connection;
-using Raven.Client.Connection.Profiling;
-using Raven.Client.Exceptions;
-using Raven.Client.Extensions;
-using Raven.Client.Silverlight.Data;
-using Raven.Client.Document;
-using Raven.Abstractions.Commands;
-using Raven.Abstractions.Indexing;
-using Raven.Json.Linq;
-
-namespace Raven.Client.Silverlight.Connection.Async
-{
- /// <summary>
- /// Access the database commands in async fashion
- /// </summary>
- public class AsyncServerClient : IAsyncDatabaseCommands
- {
- private readonly string url;
- private readonly ICredentials credentials;
- private readonly HttpJsonRequestFactory jsonRequestFactory;
- private readonly Guid? sessionId;
- private readonly Task veryFirstRequest;
- private readonly DocumentConvention convention;
- private readonly ProfilingInformation profilingInformation;
- private readonly Func<string, Raven.Client.Connection.ReplicationInformer> replicationInformerGetter;
- private readonly string databaseName;
- private readonly ReplicationInformer replicationInformer;
- private int readStripingBase;
- private int requestCount;
-
- /// <summary>
- /// Get the current json request factory
- /// </summary>
- public HttpJsonRequestFactory JsonRequestFactory
- {
- get { return jsonRequestFactory; }
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="AsyncServerClient"/> class.
- /// </summary>
- public AsyncServerClient(string url, DocumentConvention convention, ICredentials credentials,
- HttpJsonRequestFactory jsonRequestFactory, Guid? sessionId, Task veryFirstRequest,
- Func<string, ReplicationInformer> replicationInformerGetter, string databaseName)
- {
- profilingInformation = ProfilingInformation.CreateProfilingInformation(sessionId);
- this.url = url.EndsWith("/") ? url.Substring(0, url.Length - 1) : url;
- this.convention = convention;
- this.credentials = credentials;
- this.jsonRequestFactory = jsonRequestFactory;
- this.sessionId = sessionId;
- this.veryFirstRequest = veryFirstRequest;
- this.databaseName = databaseName;
- this.replicationInformerGetter = replicationInformerGetter;
- this.replicationInformer = replicationInformerGetter(databaseName);
- this.readStripingBase = replicationInformer.GetReadStripingBase();
-
- jsonRequestFactory.ConfigureRequest += (sender, args) =>
- {
- args.JsonRequest.WaitForTask = veryFirstRequest;
- };
- }
-
- /// <summary>
- /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
- /// </summary>
- public void Dispose()
- {
- }
-
- public HttpJsonRequest CreateRequest(string relativeUrl, string method)
- {
- return jsonRequestFactory.CreateHttpJsonRequest(new CreateHttpJsonRequestParams(this, url + relativeUrl, method, credentials, convention));
- }
-
- /// <summary>
- /// Create a new instance of <see cref="IAsyncDatabaseCommands"/> that will interacts
- /// with the specified database
- /// </summary>
- public IAsyncDatabaseCommands ForDatabase(string database)
- {
- var databaseUrl = MultiDatabase.GetRootDatabaseUrl(url);
- databaseUrl = databaseUrl + "/databases/" + database + "/";
- return new AsyncServerClient(databaseUrl, convention, credentials, jsonRequestFactory, sessionId, veryFirstRequest, replicationInformerGetter, database)
- {
- operationsHeaders = operationsHeaders
- };
- }
-
- /// <summary>
- /// Create a new instance of <see cref="IAsyncDatabaseCommands"/> that will interacts
- /// with the default database. Useful if the database has works against a tenant database.
- /// </summary>
- public IAsyncDatabaseCommands ForDefaultDatabase()
- {
- var rootDatabaseUrl = MultiDatabase.GetRootDatabaseUrl(url);
- if (rootDatabaseUrl == url)
- return this;
- return new AsyncServerClient(rootDatabaseUrl, convention, credentials, jsonRequestFactory, sessionId, veryFirstRequest, replicationInformerGetter, databaseName)
- {
- operationsHeaders = operationsHeaders
- };
- }
-
- /// <summary>
- /// Returns a new <see cref="IAsyncDatabaseCommands "/> using the specified credentials
- /// </summary>
- /// <param name="credentialsForSession">The credentials for session.</param>
- public IAsyncDatabaseCommands With(ICredentials credentialsForSession)
- {
- return new AsyncServerClient(url, convention, credentialsForSession, jsonRequestFactory, sessionId, veryFirstRequest, replicationInformerGetter, databaseName);
- }
-
- private IDictionary<string, string> operationsHeaders = new Dictionary<string, string>();
-
- /// <summary>
- /// Gets or sets the operations headers.
- /// </summary>
- /// <value>The operations headers.</value>
- public IDictionary<string, string> OperationsHeaders
- {
- get { return operationsHeaders; }
- }
-
- /// <summary>
- /// Begins an async get operation
- /// </summary>
- /// <param name="key">The key.</param>
- /// <returns></returns>
- public Task<JsonDocument> GetAsync(string key)
- {
- return ExecuteWithReplication("GET", url => DirectGetAsync(url, key));
- }
-
- public Task<JsonDocument> DirectGetAsync(string url, string key)
- {
- EnsureIsNotNullOrEmpty(key, "key");
-
- key = key.Replace("\\", @"/"); //NOTE: the present of \ causes the SL networking stack to barf, even though the Uri seemingly makes this translation itself
-
- var request = url.Docs(key)
- .NoCache()
- .ToJsonRequest(this, credentials, convention);
-
- return request
- .ReadResponseJsonAsync()
- .ContinueWith(task =>
- {
- try
- {
- var token = task.Result;
- var docKey = key;
- IList<string> list;
- if (request.ResponseHeaders.TryGetValue(Constants.DocumentIdFieldName, out list))
- {
- docKey = list.FirstOrDefault() ?? key;
- docKey = Uri.UnescapeDataString(docKey);
- request.ResponseHeaders.Remove(Constants.DocumentIdFieldName);
- }
- return new JsonDocument
- {
- DataAsJson = (RavenJObject)token,
- NonAuthoritativeInformation = request.ResponseStatusCode == HttpStatusCode.NonAuthoritativeInformation,
- Key = docKey,
- LastModified = DateTime.ParseExact(request.ResponseHeaders[Constants.LastModified].First(), "r", CultureInfo.InvariantCulture).ToLocalTime(),
- Etag = request.GetEtagHeader(),
- Metadata = request.ResponseHeaders.FilterHeaders()
- };
- }
- catch (AggregateException e)
- {
- var webException = e.ExtractSingleInnerException() as WebException;
- if (webException != null)
- {
- if (HandleWebExceptionForGetAsync(key, webException))
- return null;
- }
- throw;
- }
- });
- }
-
- public Task<Guid> DirectGetLastEtagAsync(string url)
- {
-
- var request = url.Docs(0, 1, metadataOnly: true)
- .NoCache()
- .ToJsonRequest(this, credentials, convention);
-
- return request
- .ReadResponseJsonAsync()
- .ContinueWith(task =>
- {
- var results = ((RavenJArray)task.Result);
- if (results.Length == 0)
- return Guid.Empty;
- return new Guid(results[0].Value<RavenJObject>(Constants.Metadata).Value<string>("@etag"));
- });
- }
-
- private static bool HandleWebExceptionForGetAsync(string key, WebException e)
- {
- var httpWebResponse = e.Response as HttpWebResponse;
- if (httpWebResponse == null)
- {
- return false;
- }
- if (httpWebResponse.StatusCode == HttpStatusCode.NotFound)
- {
- return true;
- }
- if (httpWebResponse.StatusCode == HttpStatusCode.Conflict)
- {
- var conflicts = new StreamReader(httpWebResponse.GetResponseStream());
- var conflictsDoc = RavenJObject.Load(new JsonTextReader(conflicts));
- var conflictIds = conflictsDoc.Value<RavenJArray>("Conflicts").Select(x => x.Value<string>()).ToArray();
-
- throw new ConflictException("Conflict detected on " + key +
- ", conflict must be resolved before the document will be accessible", false)
- {
- ConflictedVersionIds = conflictIds,
- Etag = httpWebResponse.GetEtagHeader()
- };
- }
- return false;
- }
-
- private T AttemptToProcessResponse<T>(Func<T> process) where T : class
- {
- try
- {
- return process();
- }
- catch (AggregateException e)
- {
- var webException = e.ExtractSingleInnerException() as WebException;
- if (webException == null)
- throw;
-
- if (HandleException(webException))
- return null;
-
- throw;
- }
- }
-
- /// <summary>
- /// Attempts to handle an exception raised when receiving a response from the server
- /// </summary>
- /// <param name="e">The exception to handle</param>
- /// <returns>returns true if the exception is handled, false if it should be thrown</returns>
- private bool HandleException(WebException e)
- {
- var httpWebResponse = e.Response as HttpWebResponse;
- if (httpWebResponse == null)
- {
- return false;
- }
- if (httpWebResponse.StatusCode == HttpStatusCode.InternalServerError)
- {
- var content = new StreamReader(httpWebResponse.GetResponseStream());
- var jo = RavenJObject.Load(new JsonTextReader(content));
- var error = jo.Deserialize<ServerRequestError>(convention);
-
- throw new WebException(error.Error);
- }
- return false;
- }
-
- /// <summary>
- /// Perform a single POST request containing multiple nested GET requests
- /// </summary>
- public Task<GetResponse[]> MultiGetAsync(GetRequest[] requests)
- {
- return ExecuteWithReplication("GET", url =>
- {
- var postedData = JsonConvert.SerializeObject(requests);
-
- var httpJsonRequest = jsonRequestFactory.CreateHttpJsonRequest(new CreateHttpJsonRequestParams(this, url + "/multi_get/", "POST", credentials, convention));
-
- return httpJsonRequest.WriteAsync(postedData)
- .ContinueWith(
- task =>
- {
- task.Wait();// will throw if write errored
- return httpJsonRequest.ReadResponseJsonAsync()
- .ContinueWith(replyTask => convention.CreateSerializer().Deserialize<GetResponse[]>(new RavenJTokenReader(replyTask.Result)));
- })
- .Unwrap();
- });
- }
-
- /// <summary>
- /// Perform a set based update using the specified index, not allowing the operation
- /// if the index is stale
- /// </summary>
- /// <param name="indexName">Name of the index.</param>
- /// <param name="queryToUpdate">The query to update.</param>
- /// <param name="patch">The patch request to use (using JavaScript)</param>
- public Task UpdateByIndex(string indexName, IndexQuery queryToUpdate, ScriptedPatchRequest patch)
- {
- return UpdateByIndex(indexName, queryToUpdate, patch, false);
- }
-
- public Task UpdateByIndex(string indexName, IndexQuery queryToUpdate, ScriptedPatchRequest patch, bool allowStale)
- {
- var requestData = RavenJObject.FromObject(patch).ToString(Formatting.Indented);
- return UpdateByIndexImpl(indexName, queryToUpdate, allowStale, requestData, "EVAL");
- }
-
- private Task UpdateByIndexImpl(string indexName, IndexQuery queryToUpdate, bool allowStale, String requestData, String method)
- {
-
- return ExecuteWithReplication(method, operationUrl =>
- {
- string path = queryToUpdate.GetIndexQueryUrl(operationUrl, indexName, "bulk_docs") + "&allowStale=" + allowStale;
-
- var request = jsonRequestFactory.CreateHttpJsonRequest(
- new CreateHttpJsonRequestParams(this, path, method, credentials, convention));
- request.AddOperationHeaders(OperationsHeaders);
- return request.ExecuteWriteAsync(requestData);
- });
- }
-
- public Task<LogItem[]> GetLogsAsync(bool errorsOnly)
- {
- return ExecuteWithReplication("GET", operationUrl =>
- {
- var requestUri = url + "/logs";
- if (errorsOnly)
- requestUri += "?type=error";
-
- var request =
- jsonRequestFactory.CreateHttpJsonRequest(new CreateHttpJsonRequestParams(this, requestUri.NoCache(), "GET",
- credentials, convention));
- request.AddOperationHeaders(OperationsHeaders);
-
- return request.ReadResponseJsonAsync()
- .ContinueWith(task => convention.CreateSerializer().Deserialize<LogItem[]>(new RavenJTokenReader(task.Result)));
- });
- }
-
- public Task<LicensingStatus> GetLicenseStatusAsync()
- {
- var request = jsonRequestFactory.CreateHttpJsonRequest(new CreateHttpJsonRequestParams(this, (url + "/license/status").NoCache(), "GET", credentials, convention));
- request.AddOperationHeaders(OperationsHeaders);
-
- return request.ReadResponseJsonAsync()
- .ContinueWith(task => convention.CreateSerializer().Deserialize<LicensingStatus>(new RavenJTokenReader(task.Result)));
- }
-
- public Task StartBackupAsync(string backupLocation, DatabaseDocument databaseDocument)
- {
- var request = jsonRequestFactory.CreateHttpJsonRequest(new CreateHttpJsonRequestParams(this, (url + "/admin/backup").NoCache(), "POST", credentials, convention));
- request.AddOperationHeaders(OperationsHeaders);
- return request.WriteAsync(new RavenJObject
- {
- {"BackupLocation", backupLocation},
- {"DatabaseDocument", RavenJObject.FromObject(databaseDocument)}
- }.ToString(Formatting.None))
- .ContinueWith(task =>
- {
- if (task.Exception != null)
- return task;
-
- return request.ExecuteRequestAsync();
- }).Unwrap();
- }
-
- public Task StartRestoreAsync(string restoreLocation, string databaseLocation, string name = null)
- {
- var request = jsonRequestFactory.CreateHttpJsonRequest(new CreateHttpJsonRequestParams(this, (url + "/admin/restore").NoCache(), "POST", credentials, convention));
- request.AddOperationHeaders(OperationsHeaders);
- return request.WriteAsync(new RavenJObject
- {
- {"RestoreLocation", restoreLocation},
- {"DatabaseLocation", databaseLocation},
- {"DatabaseName", name}
- }.ToString(Formatting.None))
- .ContinueWith(task =>
- {
- if (task.Exception != null)
- return task;
-
- return request.ExecuteRequestAsync();
- }).Unwrap();
- }
-
- public Task StartIndexingAsync()
- {
- return ExecuteWithReplication("POST", operationUrl =>
- {
- var request =
- jsonRequestFactory.CreateHttpJsonRequest(new CreateHttpJsonRequestParams(this,
- (operationUrl + "/admin/StartIndexing").NoCache(),
- "POST", credentials, convention));
- request.AddOperationHeaders(OperationsHeaders);
-
- return request.ExecuteRequestAsync();
- });
- }
-
- public Task StopIndexingAsync()
- {
- return ExecuteWithReplication("POST", operationUrl =>
- {
- var request =
- jsonRequestFactory.CreateHttpJsonRequest(new CreateHttpJsonRequestParams(this,
- (operationUrl + "/admin/StopIndexing").NoCache(),
- "POST", credentials, convention));
- request.AddOperationHeaders(OperationsHeaders);
-
- return request.ExecuteRequestAsync();
- });
- }
-
- public Task<string> GetIndexingStatusAsync()
- {
- return ExecuteWithReplication("GET", operationUrl =>
- {
- var request =
- jsonRequestFactory.CreateHttpJsonRequest(new CreateHttpJsonRequestParams(this,
- (operationUrl + "/admin/IndexingStatus").
- NoCache(), "GET", credentials, convention));
- request.AddOperationHeaders(OperationsHeaders);
-
- return request.ReadResponseJsonAsync()
- .ContinueWith(task => task.Result.Value<string>("IndexingStatus"));
- });
- }
-
- public Task<JsonDocument[]> StartsWithAsync(string keyPrefix, int start, int pageSize, bool metadataOnly = false)
- {
- return ExecuteWithReplication("GET", operationUrl =>
- {
- var metadata = new RavenJObject();
- var actualUrl = string.Format("{0}/docs?startsWith={1}&start={2}&pageSize={3}", operationUrl, Uri.EscapeDataString(keyPrefix), start, pageSize);
- if (metadataOnly)
- actualUrl += "&metadata-only=true";
- var request = jsonRequestFactory.CreateHttpJsonRequest(new CreateHttpJsonRequestParams(this, actualUrl, "GET", metadata, credentials, convention));
- request.AddOperationHeaders(OperationsHeaders);
-
- return request.ReadResponseJsonAsync()
- .ContinueWith(task => SerializationHelper.RavenJObjectsToJsonDocuments(((RavenJArray)task.Result).OfType<RavenJObject>()).ToArray());
- });
- }
-
- public Task<BuildNumber> GetBuildNumberAsync()
- {
- var request = jsonRequestFactory.CreateHttpJsonRequest(new CreateHttpJsonRequestParams(this, (url + "/build/version").NoCache(), "GET", credentials, convention));
- request.AddOperationHeaders(OperationsHeaders);
-
- return request.ReadResponseJsonAsync()
- .ContinueWith(task => convention.CreateSerializer().Deserialize<BuildNumber>(new RavenJTokenReader(task.Result)));
- }
-
- /// <summary>
- /// Using the given Index, calculate the facets as per the specified doc
- /// </summary>
- public Task<FacetResults> GetFacetsAsync(string index, IndexQuery query, string facetSetupDoc)
- {
- return ExecuteWithReplication("GET", operationUrl =>
- {
- var requestUri = operationUrl + string.Format("/facets/{0}?facetDoc={1}&query={2}",
- Uri.EscapeUriString(index),
- Uri.EscapeDataString(facetSetupDoc),
- Uri.EscapeDataString(query.Query));
-
- var request =
- jsonRequestFactory.CreateHttpJsonRequest(new CreateHttpJsonRequestParams(this, requestUri.NoCache(), "GET",
- credentials, convention));
- request.AddOperationHeaders(OperationsHeaders);
-
- return request.ReadResponseJsonAsync()
- .ContinueWith(task =>
- {
- var json = (RavenJObject)task.Result;
- return json.JsonDeserialization<FacetResults>();
- });
- });
- }
-
- /// <summary>
- /// Begins an async multi get operation
- /// </summary>
- public Task<MultiLoadResult> GetAsync(string[] keys, string[] includes, bool metadataOnly = false)
- {
- return ExecuteWithReplication("GET", url =>
- {
- var path = url + "/queries/?";
- if (metadataOnly)
- path += "&metadata-only=true";
- if (includes != null && includes.Length > 0)
- {
- path += string.Join("&", includes.Select(x => "include=" + x).ToArray());
- }
- // if it is too big, we drop to POST (note that means that we can't use the HTTP cache any longer)
- // we are fine with that, requests to load > 128 items are going to be rare
- HttpJsonRequest request;
- if (keys.Length < 128)
- {
- path += "&" + string.Join("&", keys.Select(x => "id=" + x).ToArray());
- request = jsonRequestFactory.CreateHttpJsonRequest(new CreateHttpJsonRequestParams(this, path.NoCache(), "GET", credentials, convention));
- return request.ReadResponseJsonAsync()
- .ContinueWith(task => CompleteMultiGet(task));
- }
- request = jsonRequestFactory.CreateHttpJsonRequest(new CreateHttpJsonRequestParams(this, path, "POST", credentials, convention));
- return request.WriteAsync(new JArray(keys).ToString(Formatting.None))
- .ContinueWith(writeTask => request.ReadResponseJsonAsync())
- .ContinueWith(task => CompleteMultiGet(task.Result));
- });
- }
-
- private static MultiLoadResult CompleteMultiGet(Task<RavenJToken> task)
- {
- try
- {
- var result = (RavenJObject)task.Result;
-
- return new MultiLoadResult
- {
- Includes = result.Value<RavenJArray>("Includes").Cast<RavenJObject>().ToList(),
- Results = result.Value<RavenJArray>("Results").Cast<RavenJObject>().ToList()
- };
- }
- catch (AggregateException e)
- {
- var webException = e.ExtractSingleInnerException() as WebException;
- if (webException == null)
- throw;
-
- var httpWebResponse = webException.Response as HttpWebResponse;
- if (httpWebResponse == null ||
- httpWebResponse.StatusCode != HttpStatusCode.Conflict)
- throw;
- throw ThrowConcurrencyException(webException);
- }
- }
-
- /// <summary>
- /// Begins an async get operation for documents
- /// </summary>
- /// <param name="start">Paging start</param>
- /// <param name="pageSize">Size of the page.</param>
- /// <param name="metadataOnly">Load just the document metadata</param>
- /// <remarks>
- /// This is primarily useful for administration of a database
- /// </remarks>
- public Task<JsonDocument[]> GetDocumentsAsync(int start, int pageSize, bool metadataOnly = false)
- {
- return ExecuteWithReplication("GET", url =>
- {
- return url.Docs(start, pageSize, metadataOnly)
- .NoCache()
- .ToJsonRequest(this, credentials, convention)
- .ReadResponseJsonAsync()
- .ContinueWith(task => ((RavenJArray)task.Result)
- .Cast<RavenJObject>()
- .ToJsonDocuments()
- .ToArray());
- });
- }
-
- /// <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>
- /// <param name="metadataOnly">Load just the document metadata</param>
- /// <returns></returns>
- public Task<QueryResult> QueryAsync(string index, IndexQuery query, string[] includes, bool metadataOnly = false)
- {
- return ExecuteWithReplication("GET", url =>
- {
- EnsureIsNotNullOrEmpty(index, "index");
- var path = query.GetIndexQueryUrl(url, index, "indexes");
- if (metadataOnly)
- path += "&metadata-only=true";
- if (includes != null && includes.Length > 0)
- {
- path += "&" + string.Join("&", includes.Select(x => "include=" + x).ToArray());
- }
- var request = jsonRequestFactory.CreateHttpJsonRequest(new CreateHttpJsonRequestParams(this, path.NoCache(), "GET", credentials, convention));
-
- return request.ReadResponseJsonAsync()
- .ContinueWith(task => AttemptToProcessResponse(() => SerializationHelper.ToQueryResult((RavenJObject)task.Result, request.GetEtagHeader())));
- });
- }
-
- public Task DeleteByIndexAsync(string indexName, IndexQuery queryToDelete, bool allowStale)
- {
- return ExecuteWithReplication("DELETE", url =>
- {
- string path = queryToDelete.GetIndexQueryUrl(url, indexName, "bulk_docs") + "&allowStale=" + allowStale;
- var request = jsonRequestFactory.CreateHttpJsonRequest(new CreateHttpJsonRequestParams(this, path, "DELETE", credentials, convention));
- request.AddOperationHeaders(OperationsHeaders);
- return request.ExecuteRequestAsync()
- .ContinueWith(task =>
- {
- var aggregateException = task.Exception;
- if (aggregateException == null)
- return task;
- var e = aggregateException.ExtractSingleInnerException() as WebException;
- if (e == null)
- return task;
- var httpWebResponse = e.Response as HttpWebResponse;
- if (httpWebResponse != null && httpWebResponse.StatusCode == HttpStatusCode.NotFound)
- throw new InvalidOperationException("There is no index named: " + indexName, e);
- return task;
- }).Unwrap();
- });
- }
-
- /// <summary>
- /// Deletes the document for the specified id asynchronously
- /// </summary>
- /// <param name="id">The id.</param>
- public Task DeleteDocumentAsync(string id)
- {
- return ExecuteWithReplication("DELETE", url =>
- {
- return url.Docs(id)
- .ToJsonRequest(this, credentials, convention, OperationsHeaders, "DELETE")
- .ExecuteRequestAsync();
- });
- }
-
- /// <summary>
- /// Puts the document with the specified key in the database
- /// </summary>
- /// <param name="key">The key.</param>
- /// <param name="etag">The etag.</param>
- /// <param name="document">The document.</param>
- /// <param name="metadata">The metadata.</param>
- public Task<PutResult> PutAsync(string key, Guid? etag, RavenJObject document, RavenJObject metadata)
- {
- return ExecuteWithReplication("PUT", url =>
- {
- if (metadata == null)
- metadata = new RavenJObject();
- var method = String.IsNullOrEmpty(key) ? "POST" : "PUT";
- if (etag != null)
- metadata["ETag"] = new RavenJValue(etag.Value.ToString());
- if(key != null)
- key = Uri.EscapeUriString(key);
- var request = jsonRequestFactory.CreateHttpJsonRequest(new CreateHttpJsonRequestParams(this, url + "/docs/" + key, method, metadata, credentials, convention));
- request.AddOperationHeaders(OperationsHeaders);
-
- return request.WriteAsync(document.ToString())
- .ContinueWith(task =>
- {
- if (task.Exception != null)
- throw new InvalidOperationException("Unable to write to server", task.Exception);
-
- return request.ReadResponseJsonAsync()
- .ContinueWith(task1 =>
- {
- try
- {
- return convention.CreateSerializer().Deserialize<PutResult>(new RavenJTokenReader(task1.Result));
- }
- catch (AggregateException e)
- {
- var webexception = e.ExtractSingleInnerException() as WebException;
- if (ShouldThrowForPutAsync(webexception))
- throw;
- throw ThrowConcurrencyException(webexception);
- }
- });
- })
- .Unwrap();
- });
- }
-
- static bool ShouldThrowForPutAsync(WebException e)
- {
- if (e == null)
- return true;
- var httpWebResponse = e.Response as HttpWebResponse;
- return (httpWebResponse == null ||
- httpWebResponse.StatusCode != HttpStatusCode.Conflict);
- }
-
- /// <summary>
- /// Gets the index definition for the specified name asynchronously
- /// </summary>
- /// <param name="name">The name.</param>
- public Task<IndexDefinition> GetIndexAsync(string name)
- {
- return ExecuteWithReplication("GET", url =>
- {
- return url.IndexDefinition(name)
- .NoCache()
- .ToJsonRequest(this, credentials, convention).ReadResponseJsonAsync()
- .ContinueWith(task =>
- {
- var json = (RavenJObject)task.Result;
- //NOTE: To review, I'm not confidence this is the correct way to deserialize the index definition
- return convention.CreateSerializer().Deserialize<IndexDefinition>(new RavenJTokenReader(json["Index"]));
- });
- });
- }
-
- /// <summary>
- /// Puts the index definition for the specified name asynchronously
- /// </summary>
- /// <param name="name">The name.</param>
- /// <param name="indexDef">The index def.</param>
- /// <param name="overwrite">Should overwrite index</param>
- public Task<string> PutIndexAsync(string name, IndexDefinition indexDef, bool overwrite)
- {
- return ExecuteWithReplication("PUT", url => DirectPutIndexAsync(name, indexDef, overwrite, url));
- }
-
- /// <summary>
- /// Puts the index definition for the specified name asynchronously with url
- /// </summary>
- /// <param name="name">The name.</param>
- /// <param name="indexDef">The index def.</param>
- /// <param name="overwrite">Should overwrite index</param>
- /// <param name="url">The server's url</param>
- public Task<string> DirectPutIndexAsync(string name, IndexDefinition indexDef, bool overwrite, string url)
- {
- var requestUri = url + "/indexes/" + Uri.EscapeUriString(name) + "?definition=yes";
- var webRequest = requestUri
- .ToJsonRequest(this, credentials, convention, OperationsHeaders, "GET");
-
- return webRequest.ExecuteRequestAsync()
- .ContinueWith(task =>
- {
- try
- {
- task.Wait(); // should throw if it is bad
- if (overwrite == false)
- throw new InvalidOperationException("Cannot put index: " + name + ", index already exists");
- }
- catch (AggregateException e)
- {
- var webException = e.ExtractSingleInnerException() as WebException;
- if (ShouldThrowForPutIndexAsync(webException))
- throw;
- }
-
- var request =
- jsonRequestFactory.CreateHttpJsonRequest(new CreateHttpJsonRequestParams(this, requestUri, "PUT", credentials,
- convention));
- request.AddOperationHeaders(OperationsHeaders);
-
- var serializeObject = JsonConvert.SerializeObject(indexDef, new JsonEnumConverter());
- return request
- .WriteAsync(serializeObject)
- .ContinueWith(writeTask => AttemptToProcessResponse(() => request
- .ReadResponseJsonAsync()
- .ContinueWith(
- readStrTask => AttemptToProcessResponse(() =>
- {
- //NOTE: JsonConvert.DeserializeAnonymousType() doesn't work in Silverlight because the ctor is private!
- var obj =
- convention.CreateSerializer().Deserialize
- <IndexContainer>(
- new RavenJTokenReader(readStrTask.Result));
- return obj.Index;
- })))
- ).Unwrap();
- }).Unwrap();
- }
-
-
- /// <summary>
- /// Used for deserialization only :-P
- /// </summary>
- public class IndexContainer
- {
- public string Index { get; set; }
- }
-
- /// <summary>
- /// Deletes the index definition for the specified name asynchronously
- /// </summary>
- /// <param name="name">The name.</param>
- public Task DeleteIndexAsync(string name)
- {
- return ExecuteWithReplication("DELETE", url =>
- {
- return url.Indexes(name)
- .ToJsonRequest(this, credentials, convention, OperationsHeaders, "DELETE")
- .ExecuteRequestAsync();
- });
- }
-
- private static bool ShouldThrowForPutIndexAsync(WebException e)
- {
- if (e == null)
- return true;
- var response = e.Response as HttpWebResponse;
- return (response == null || response.StatusCode != HttpStatusCode.NotFound);
- }
-
-
- /// <summary>
- /// Gets the index names from the server asynchronously
- /// </summary>
- /// <param name="start">Paging start</param>
- /// <param name="pageSize">Size of the page.</param>
- public Task<string[]> GetIndexNamesAsync(int start, int pageSize)
- {
- return ExecuteWithReplication("GET", url =>
- {
- return url.IndexNames(start, pageSize)
- .NoCache()
- .ToJsonRequest(this, credentials, convention)
- .ReadResponseJsonAsync()
- .ContinueWith(task =>
- {
- var json = ((RavenJArray)task.Result);
- return json.Select(x => x.Value<string>()).ToArray();
- });
- });
- }
-
- /// <summary>
- /// Gets the indexes from the server asynchronously
- /// </summary>
- /// <param name="start">Paging start</param>
- /// <param name="pageSize">Size of the page.</param>
- public Task<IndexDefinition[]> GetIndexesAsync(int start, int pageSize)
- {
- return ExecuteWithReplication("GET", url =>
- {
- var url2 = (url + "/indexes/?start=" + start + "&pageSize=" + pageSize).NoCache();
- var request = jsonRequestFactory.CreateHttpJsonRequest(new CreateHttpJsonRequestParams(this, url2, "GET", credentials, convention));
-
- return request.ReadResponseJsonAsync()
- .ContinueWith(task =>
- {
- var json = ((RavenJArray)task.Result);
- //NOTE: To review, I'm not confidence this is the correct way to deserialize the index definition
- return json
- .Select(x => JsonConvert.DeserializeObject<IndexDefinition>(((RavenJObject)x)["definition"].ToString(), new JsonToJsonConverter()))
- .ToArray();
- });
- });
- }
-
- /// <summary>
- /// Resets the specified index asynchronously
- /// </summary>
- /// <param name="name">The name.</param>
- public Task ResetIndexAsync(string name)
- {
- return ExecuteWithReplication("RESET", url =>
- {
- var httpJsonRequestAsync = jsonRequestFactory.CreateHttpJsonRequest(new CreateHttpJsonRequestParams(this, url + "/indexes/" + name, "RESET", credentials, convention));
- httpJsonRequestAsync.AddOperationHeaders(OperationsHeaders);
- return httpJsonRequestAsync.ReadResponseJsonAsync();
- });
- }
-
- /// <summary>
- /// Returns a list of suggestions based on the specified suggestion query.
- /// </summary>
- /// <param name="index">The index to query for suggestions</param>
- /// <param name="suggestionQuery">The suggestion query.</param>
- public Task<SuggestionQueryResult> SuggestAsync(string index, SuggestionQuery suggestionQuery)
- {
- return ExecuteWithReplication("GET", url =>
- {
- if (suggestionQuery == null)
- throw new ArgumentNullException("suggestionQuery");
-
- var requestUri = url + string.Format("/suggest/{0}?term={1}&field={2}&max={3}&distance={4}&accuracy={5}",
- Uri.EscapeUriString(index),
- Uri.EscapeDataString(suggestionQuery.Term),
- Uri.EscapeDataString(suggestionQuery.Field),
- Uri.EscapeDataString(suggestionQuery.MaxSuggestions.ToString()),
- Uri.EscapeDataString(suggestionQuery.Distance.ToString()),
- Uri.EscapeDataString(suggestionQuery.Accuracy.ToString()));
-
- var request = jsonRequestFactory.CreateHttpJsonRequest(new CreateHttpJsonRequestParams(this, requestUri.NoCache(), "GET", credentials, convention));
- request.AddOperationHeaders(OperationsHeaders);
-
- return request.ReadResponseJsonAsync()
- .ContinueWith(task =>
- {
- var json = (RavenJObject)task.Result;
- return new SuggestionQueryResult
- {
- Suggestions = ((RavenJArray)json["Suggestions"]).Select(x => x.Value<string>()).ToArray(),
- };
- });
- });
- }
-
-
- /// <summary>
- /// Begins the async batch operation
- /// </summary>
- /// <param name="commandDatas">The command data.</param>
- /// <returns></returns>
- public Task<BatchResult[]> BatchAsync(ICommandData[] commandDatas)
- {
- return ExecuteWithReplication("POST", url =>
- {
- var metadata = new RavenJObject();
- var req = jsonRequestFactory.CreateHttpJsonRequest(new CreateHttpJsonRequestParams(this, url + "/bulk_docs", "POST", metadata, credentials, convention));
- var jArray = new RavenJArray(commandDatas.Select(x => x.ToJson()));
-
- return req.WriteAsync(jArray.ToString(Formatting.None))
- .ContinueWith(writeTask => req.ReadResponseJsonAsync())
- .Unwrap()
- .ContinueWith(task =>
- {
- RavenJToken response;
- try
- {
- response = task.Result;
- }
- catch (AggregateException e)
- {
- var webException = e.ExtractSingleInnerException() as WebException;
- if (webException == null)
- throw;
-
- var httpWebResponse = webException.Response as HttpWebResponse;
- if (httpWebResponse == null ||
- httpWebResponse.StatusCode != HttpStatusCode.Conflict)
- throw;
- throw ThrowConcurrencyException(webException);
- }
- return convention.CreateSerializer().Deserialize<BatchResult[]>(new RavenJTokenReader(response));
- });
- });
- }
-
- public class ConcurrencyExceptionResult
- {
- private readonly string url1;
- private readonly Guid actualETag1;
- private readonly Guid expectedETag1;
- private readonly string error1;
-
- public string url
- {
- get { return url1; }
- }
-
- public Guid actualETag
- {
- get { return actualETag1; }
- }
-
- public Guid expectedETag
- {
- get { return expectedETag1; }
- }
-
- public string error
- {
- get { return error1; }
- }
-
- public ConcurrencyExceptionResult(string url, Guid actualETag, Guid expectedETag, string error)
- {
- url1 = url;
- actualETag1 = actualETag;
- expectedETag1 = expectedETag;
- error1 = error;
- }
- }
-
- private static Exception ThrowConcurrencyException(WebException e)
- {
- using (var sr = new StreamReader(e.Response.GetResponseStream()))
- {
- var text = sr.ReadToEnd();
- var errorResults = JsonConvert.DeserializeAnonymousType(text, new ConcurrencyExceptionResult((string)null, Guid.Empty, Guid.Empty, (string)null));
- return new ConcurrencyException(errorResults.error)
- {
- ActualETag = errorResults.actualETag,
- ExpectedETag = errorResults.expectedETag
- };
- }
- }
-
- private static void EnsureIsNotNullOrEmpty(string key, string argName)
- {
- if (string.IsNullOrEmpty(key))
- throw new ArgumentException("Key cannot be null or empty", argName);
- }
-
- /// <summary>
- /// Begins retrieving the statistics for the database
- /// </summary>
- /// <returns></returns>
- public Task<DatabaseStatistics> GetStatisticsAsync()
- {
- return url.Stats()
- .NoCache()
- .ToJsonRequest(this, credentials, convention)
- .ReadResponseJsonAsync()
- .ContinueWith(task =>
- {
- var jo = ((RavenJObject)task.Result);
- return jo.Deserialize<DatabaseStatistics>(convention);
- });
- }
-
- /// <summary>
- /// Gets the list of databases from the server asynchronously
- /// </summary>
- public Task<string[]> GetDatabaseNamesAsync(int pageSize, int start = 0)
- {
- return ExecuteWithReplication("GET", url =>
- {
- return url.Databases(pageSize, start)
- .NoCache()
- .ToJsonRequest(this, credentials, convention)
- .ReadResponseJsonAsync()
- .ContinueWith(task =>
- {
- var json = ((RavenJArray)task.Result);
- return json
- .Select(x => x.Value<RavenJObject>("@metadata").Value<string>("@id").Replace("Raven/Databases/", string.Empty))
- .ToArray();
- });
- });
- }
-
- /// <summary>
- /// Puts the attachment with the specified key asynchronously
- /// </summary>
- /// <param name="key">The key.</param>
- /// <param name="etag">The etag.</param>
- /// <param name="data">The data.</param>
- /// <param name="metadata">The metadata.</param>
- public Task PutAttachmentAsync(string key, Guid? etag, byte[] data, RavenJObject metadata)
- {
- return ExecuteWithReplication("PUT", url =>
- {
- if (metadata == null)
- metadata = new RavenJObject();
-
- if (etag != null)
- metadata["ETag"] = new RavenJValue(etag.Value.ToString());
-
- var request = jsonRequestFactory.CreateHttpJsonRequest(new CreateHttpJsonRequestParams(this, url.Static(key), "PUT", metadata, credentials, convention));
- request.AddOperationHeaders(OperationsHeaders);
-
- return request
- .WriteAsync(data)
- .ContinueWith(write =>
- {
- if (write.Exception != null)
- throw new InvalidOperationException("Unable to write to server");
-
- return request.ExecuteRequestAsync();
- }).Unwrap();
- });
- }
-
- /// <summary>
- /// Gets the attachment by the specified key asynchronously
- /// </summary>
- /// <param name="key">The key.</param>
- /// <returns></returns>
- public Task<Attachment> GetAttachmentAsync(string key)
- {
- EnsureIsNotNullOrEmpty(key, "key");
-
- return ExecuteWithReplication("GET", url =>
- {
- var request = url.Static(key)
- .ToJsonRequest(this, credentials, convention);
-
- return request
- .ReadResponseBytesAsync()
- .ContinueWith(task =>
- {
- try
- {
- var buffer = task.Result;
- return new Attachment
- {
- Data = () => new MemoryStream(buffer),
- Etag = request.GetEtagHeader(),
- Metadata = request.ResponseHeaders.FilterHeaders()
- };
- }
- catch (AggregateException e)
- {
- var webException = e.ExtractSingleInnerException() as WebException;
- if (webException != null)
- {
- if (HandleWebExceptionForGetAsync(key, webException))
- return null;
- }
- throw;
- }
- });
- });
- }
-
- /// <summary>
- /// Deletes the attachment with the specified key asynchronously
- /// </summary>
- /// <param name="key">The key.</param>
- /// <param name="etag">The etag.</param>
- public Task DeleteAttachmentAsync(string key, Guid? etag)
- {
- return ExecuteWithReplication("DELETE", url =>
- {
- var metadata = new RavenJObject();
-
- if (etag != null)
- metadata["ETag"] = new RavenJValue(etag.Value.ToString());
-
- var request = jsonRequestFactory.CreateHttpJsonRequest(new CreateHttpJsonRequestParams(this, url.Static(key), "DELETE", metadata, credentials, convention));
- request.AddOperationHeaders(OperationsHeaders);
-
- return request.ExecuteRequestAsync();
- });
- }
-
- /// <summary>
- /// Ensures that the silverlight startup tasks have run
- /// </summary>
- public Task EnsureSilverlightStartUpAsync()
- {
- return ExecuteWithReplication("GET", url =>
- {
- return url
- .SilverlightEnsuresStartup()
- .NoCache()
- .ToJsonRequest(this, credentials, convention)
- .ReadResponseBytesAsync();
- });
- }
-
- ///<summary>
- /// Get the possible terms for the specified field in the index asynchronously
- /// You can page through the results by use fromValue parameter as the
- /// starting point for the next query
- ///</summary>
- ///<returns></returns>
- public Task<string[]> GetTermsAsync(string index, string field, string fromValue, int pageSize)
- {
- return ExecuteWithReplication("GET", url =>
- {
- return url.Terms(index, field, fromValue, pageSize)
- .NoCache()
- .ToJsonRequest(this, credentials, convention)
- .ReadResponseJsonAsync()
- .ContinueWith(task =>
- {
- var json = ((RavenJArray)task.Result);
- return json.Select(x => x.Value<string>()).ToArray();
- });
- });
- }
-
- /// <summary>
- /// Disable all caching within the given scope
- /// </summary>
- public IDisposable DisableAllCaching()
- {
- return null; // we don't implement this
- }
-
- /// <summary>
- /// The profiling information
- /// </summary>
- public ProfilingInformation ProfilingInformation
- {
- get { return profilingInformation; }
- }
-
- public string Url
- {
- get { return url; }
- }
-
- /// <summary>
- /// Force the database commands to read directly from the master, unless there has been a failover.
- /// </summary>
- public void ForceReadFromMaster()
- {
- readStripingBase = -1;// this means that will have to use the master url first
- }
-
- private Task ExecuteWithReplication(string method, Func<string, Task> operation)
- {
- // Convert the Func<string, Task> to a Func<string, Task<object>>
- return ExecuteWithReplication(method, u => operation(u).ContinueWith<object>(t =>
- {
- t.Wait();
- return null;
- }));
- }
-
- private Task<T> ExecuteWithReplication<T>(string method, Func<string, Task<T>> operation)
- {
- var currentRequest = Interlocked.Increment(ref requestCount);
- return replicationInformer.ExecuteWithReplicationAsync(method, url, currentRequest, readStripingBase, operation);
- }
- }
-}
16 Raven.Client.Silverlight/Connection/HttpJsonRequest.cs
View
@@ -14,6 +14,7 @@
using System.Text;
using System.Threading.Tasks;
using Ionic.Zlib;
+using Raven.Client.Silverlight.MissingFromSilverlight;
using Raven.Imports.Newtonsoft.Json;
using Raven.Imports.Newtonsoft.Json.Linq;
using Raven.Abstractions.Data;
@@ -68,7 +69,7 @@ private Task RecreateWebRequest(Action<HttpWebRequest> result)
/// Gets or sets the response headers.
/// </summary>
/// <value>The response headers.</value>
- public IDictionary<string, IList<string>> ResponseHeaders { get; set; }
+ public NameValueCollection ResponseHeaders { get; set; }
internal HttpJsonRequest(string url, string method, RavenJObject metadata, DocumentConvention conventions, HttpJsonRequestFactory factory)
{
@@ -231,14 +232,12 @@ private T ReadResponse<T>(Func<WebResponse> getResponse, Func<Stream, T> handleR
}
}
- ResponseHeaders = new Dictionary<string, IList<string>>(StringComparer.InvariantCultureIgnoreCase);
+ ResponseHeaders = new NameValueCollection();
foreach (var key in response.Headers.AllKeys)
{
- ResponseHeaders[key] = new List<string>
- {
- response.Headers[key]
- };
+ ResponseHeaders[key] = response.Headers[key];
}
+
ResponseStatusCode = ((HttpWebResponse)response).StatusCode;
using (var responseStream = response.GetResponseStream())
@@ -429,5 +428,10 @@ public Task ExecuteWriteAsync(string data)
})
.Unwrap();
}
+
+ public double CalculateDuration()
+ {
+ return 0;
+ }
}
}
63 Raven.Client.Silverlight/Connection/HttpJsonRequestFactory.cs
View
@@ -1,8 +1,7 @@
using System;
-using System.Net;
using Raven.Client.Connection;
using Raven.Client.Connection.Profiling;
-using Raven.Client.Document;
+using Raven.Client.Silverlight.MissingFromSilverlight;
using Raven.Json.Linq;
namespace Raven.Client.Silverlight.Connection
@@ -35,62 +34,50 @@ public class HttpJsonRequestFactory : IDisposable
/// <summary>
/// Invoke the LogRequest event
/// </summary>
- internal void InvokeLogRequest(IHoldProfilingInformation sender, RequestResultArgs e)
+ internal void InvokeLogRequest(IHoldProfilingInformation sender, Func<RequestResultArgs> generateRequentResult)
{
var handler = LogRequest;
if (handler != null)
- handler(sender, e);
+ handler(sender, generateRequentResult.Invoke());
}
-
/// <summary>
- /// Creates the HTTP json request.
+ /// Determine whether to use compression or not
/// </summary>
+ public bool DisableRequestCompression { get; set; }
+ public bool DisableHttpCaching
+ {
+ get { return false; }
+ }
+
+ public void Dispose()
+ {
+ }
+
public HttpJsonRequest CreateHttpJsonRequest(CreateHttpJsonRequestParams createHttpJsonRequestParams)
{
var request = new HttpJsonRequest(createHttpJsonRequestParams.Url, createHttpJsonRequestParams.Method, createHttpJsonRequestParams.Metadata, createHttpJsonRequestParams.Convention, this);
- ConfigureRequest(createHttpJsonRequestParams.Self, new WebRequestEventArgs { Request = request.webRequest, JsonRequest = request });
+ ConfigureRequest(createHttpJsonRequestParams.Owner, new WebRequestEventArgs { Request = request.webRequest, JsonRequest = request });
return request;
}
- /// <summary>
- /// Determine whether to use compression or not
- /// </summary>
- public bool DisableRequestCompression { get; set; }
-
- public void Dispose()
+ public IDisposable DisableAllCaching()
{
+ return null;
}
- }
- public class CreateHttpJsonRequestParams
- {
- public CreateHttpJsonRequestParams(object self, string url, string method, ICredentials credentials, DocumentConvention convention)
+ internal CachedRequestOp ConfigureCaching(string url, Action<string, string> setHeader)
{
- Self = self;
- Url = url;
- Method = method;
- Credentials = credentials;
- Convention = convention;
+ return new CachedRequestOp();
}
- public CreateHttpJsonRequestParams(object self, string url, string method, RavenJObject metadata, ICredentials credentials, DocumentConvention convention)
+ public void IncrementCachedRequests()
{
- Self = self;
- Url = url;
- Method = method;
- Metadata = metadata;
- Credentials = credentials;
- Convention = convention;
}
- public object Self { get; private set; }
- public string Url { get; private set; }
- public string Method { get; private set; }
- public RavenJObject Metadata { get; private set; }
- public ICredentials Credentials { get; private set; }
- public DocumentConvention Convention { get; private set; }
- public bool AvoidCachingRequest { get; set; }
+ public void CacheResponse(string s, RavenJToken result, NameValueCollection nameValueCollection)
+ {
+
+ }
}
-
-}
+}
103 Raven.Client.Silverlight/Connection/RavenUrlExtensions.cs
View
@@ -1,103 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Net;
-using System.Net.Browser;
-using System.Windows.Browser;
-using Raven.Client.Document;
-using Raven.Client.Silverlight.Connection.Async;
-
-namespace Raven.Client.Silverlight.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/" + Uri.EscapeUriString(key);
- }
-
- public static string Databases(this string url, int pageSize, int start)
- {
- string databases = url + "/databases/?pageSize=" + pageSize;
- if(start > 0)
- return databases + "&start=" + start;
- return databases;
- }
-
- 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/" + Uri.EscapeUriString(key);
- }
-
- public static string Docs(this string url, int start, int pageSize, bool metadataOnly)
- {
- var docs = url + "/docs/?start=" + start + "&pageSize=" + pageSize;
- if (metadataOnly)
- docs += "&metadata-only=true";
- return docs;
- }
-
- public static string DocsStartingWith(this string url, string prefix, int start, int pageSize, bool metadataOnly)
- {
- return Docs(url, start, pageSize, metadataOnly) + "&startsWith=" + Uri.EscapeUriString(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);
- }
-
- public static HttpJsonRequest ToJsonRequest(this string url, AsyncServerClient requestor, ICredentials credentials, Document.DocumentConvention convention)
- {
- return requestor.JsonRequestFactory.CreateHttpJsonRequest(new CreateHttpJsonRequestParams(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(new CreateHttpJsonRequestParams(requestor, url, method, credentials, convention));
- httpJsonRequest.AddOperationHeaders(operationsHeaders);
- return httpJsonRequest;
- }
- }
-}
61 Raven.Client.Silverlight/MissingFromSilverlight/NameValueCollection.cs
View
@@ -0,0 +1,61 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using Raven.Json.Linq;
+using System.Linq;
+
+namespace Raven.Client.Silverlight.MissingFromSilverlight
+{
+ public class NameValueCollection : IEnumerable
+ {
+ private Dictionary<string, List<string>> inner =
+ new Dictionary<string, List<string>>(StringComparer.InvariantCultureIgnoreCase);
+
+ public NameValueCollection()
+ {
+ inner = new Dictionary<string, List<string>>(StringComparer.InvariantCultureIgnoreCase);
+ }
+
+ public Dictionary<string, List<string>> Headers { get { return inner; } }
+
+ public IEnumerator GetEnumerator()
+ {
+ return inner.Keys.GetEnumerator();
+ }
+
+ public string[] GetValues(string header)
+ {
+ var result = new string[inner.Count];
+ var counter = 0;
+ foreach (var list in inner)
+ {
+ result[counter] = string.Join(";", list);
+ counter++;
+ }
+
+ return result;
+ }
+
+ public string this[string key]
+ {
+ get { return inner[key].FirstOrDefault(); }
+ set
+ {
+ if(inner.ContainsKey(key))
+ inner[key].Add(value);
+ else
+ inner.Add(key, new List<string>{value});
+ }
+ }
+
+ public void Remove(string key)
+ {
+ inner.Remove(key);
+ }
+
+ public bool ContainsKey(string key)
+ {
+ return inner.ContainsKey(key);
+ }
+ }
+}
24 Raven.Client.Silverlight/Raven.Client.Silverlight.csproj
View
@@ -822,12 +822,24 @@
<Compile Include="..\Raven.Client.Lightweight\Connection\Async\AsyncDatabaseCommandsExtensions.cs">
<Link>Connection\Async\AsyncDatabaseCommandsExtensions.cs</Link>
</Compile>
+ <Compile Include="..\Raven.Client.Lightweight\Connection\Async\AsyncServerClient.cs">
+ <Link>Connection\Async\AsyncServerClient.cs</Link>
+ </Compile>
+ <Compile Include="..\Raven.Client.Lightweight\Connection\CachedRequest.cs">
+ <Link>Connection\CachedRequest.cs</Link>
+ </Compile>
+ <Compile Include="..\Raven.Client.Lightweight\Connection\CreateHttpJsonRequestParams.cs">
+ <Link>Connection\CreateHttpJsonRequestParams.cs</Link>
+ </Compile>
<Compile Include="..\Raven.Client.Lightweight\Connection\DocumentConventionJsonExtensions.cs">
<Link>Imports\Connection\DocumentConventionJsonExtensions.cs</Link>
</Compile>
<Compile Include="..\Raven.Client.Lightweight\Connection\HttpExtensions.cs">
<Link>Connection\HttpExtensions.cs</Link>
</Compile>
+ <Compile Include="..\Raven.Client.Lightweight\Connection\MultiGetOperation.cs">
+ <Link>Connection\MultiGetOperation.cs</Link>
+ </Compile>
<Compile Include="..\Raven.Client.Lightweight\Connection\ObservableLineStream.cs">
<Link>Imports\Connection\ObservableLineStream.cs</Link>
</Compile>
@@ -849,6 +861,9 @@
<Compile Include="..\Raven.Client.Lightweight\Connection\Profiling\RequestStatus.cs">
<Link>Imports\Connection\Profiling\RequestStatus.cs</Link>
</Compile>
+ <Compile Include="..\Raven.Client.Lightweight\Connection\RavenUrlExtensions.cs">
+ <Link>Connection\RavenUrlExtensions.cs</Link>
+ </Compile>
<Compile Include="..\Raven.Client.Lightweight\DocumentStoreBase.cs">
<Link>Imports\DocumentStoreBase.cs</Link>
</Compile>
@@ -930,6 +945,9 @@
<Compile Include="..\Raven.Client.Lightweight\Extensions\ParallelExtensions.cs">
<Link>Imports\Extensions\ParallelExtensions.cs</Link>
</Compile>
+ <Compile Include="..\Raven.Client.Lightweight\Extensions\StringExtensions.cs">
+ <Link>Extensions\StringExtensions.cs</Link>
+ </Compile>
<Compile Include="..\Raven.Client.Lightweight\Extensions\TaskExtensions.cs">
<Link>Imports\Extensions\TaskExtensions.cs</Link>
</Compile>
@@ -1005,17 +1023,18 @@
<Compile Include="..\Raven.Client.Lightweight\Util\LastEtagHolder.cs">
<Link>Imports\Util\LastEtagHolder.cs</Link>
</Compile>
+ <Compile Include="..\Raven.Client.Lightweight\Util\SimpleCache.cs">
+ <Link>Connection\SimpleCache.cs</Link>
+ </Compile>
<Compile Include="..\Raven.Client.Lightweight\Util\Types.cs">
<Link>Imports\Util\Types.cs</Link>
</Compile>
<Compile Include="..\Raven.Client.Lightweight\WhereEqualsParams.cs">
<Link>Imports\WhereEqualsParams.cs</Link>
</Compile>
- <Compile Include="Connection\Async\AsyncServerClient.cs" />
<Compile Include="Connection\HttpJsonRequest.cs" />
<Compile Include="Connection\HttpJsonRequestFactory.cs" />
<Compile Include="Connection\HttpJsonRequestHelper.cs" />
- <Compile Include="Connection\RavenUrlExtensions.cs" />
<Compile Include="Data\ServerRequestError.cs" />
<Compile Include="MissingFromSilverlight\CD.cs" />
<Compile Include="MissingFromSilverlight\MD5.cs" />
@@ -1048,6 +1067,7 @@
<Compile Include="DotNetZip\ZlibException.cs" />
<Compile Include="DotNetZip\ZlibStream.cs" />
<Compile Include="DotNetZip\ZlibStreamFlavor.cs" />
+ <Compile Include="MissingFromSilverlight\NameValueCollection.cs" />
<Compile Include="MissingFromSilverlight\SpinWait.cs" />
<Compile Include="MissingFromSilverlight\SplitOrderedList.cs" />
<Compile Include="MissingFromSilverlight\Stopwatch.cs" />
2  Raven.Studio/Commands/ExportDatabaseCommand.cs
View
@@ -5,8 +5,8 @@
using System.Threading.Tasks;
using System.Windows.Controls;
using Ionic.Zlib;
+using Raven.Client.Connection;
using Raven.Imports.Newtonsoft.Json;
-using Raven.Client.Silverlight.Connection;
using Raven.Json.Linq;
using Raven.Studio.Infrastructure;
using Raven.Studio.Models;
1  Raven.Studio/Models/DatabaseModel.cs
View
@@ -9,7 +9,6 @@
using Raven.Client.Changes;
using Raven.Client.Connection.Async;
using Raven.Client.Document;
-using Raven.Client.Silverlight.Connection.Async;
using Raven.Json.Linq;
using Raven.Studio.Features.Tasks;
using Raven.Studio.Infrastructure;
1  Raven.Studio/Models/ReplicationStatisticsModel.cs
View
@@ -4,7 +4,6 @@
using Raven.Abstractions.Replication;
using Raven.Client;
using Raven.Client.Connection.Async;
-using Raven.Client.Silverlight.Connection.Async;
using Raven.Database.Bundles.Replication;
using Raven.Imports.Newtonsoft.Json;
using Raven.Json.Linq;
44 Raven.Studio/app.config
View
@@ -1,23 +1,23 @@
-<?xml version="1.0" encoding="utf-8"?>
-<configuration>
- <runtime>
- <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
- <dependentAssembly>
- <assemblyIdentity name="System.Windows.Controls" publicKeyToken="31bf3856ad364e35" culture="neutral" />
- <bindingRedirect oldVersion="0.0.0.0-5.0.5.0" newVersion="5.0.5.0" />
- </dependentAssembly>
- <dependentAssembly>
- <assemblyIdentity name="System.Windows.Controls.Data.Input" publicKeyToken="31bf3856ad364e35" culture="neutral" />
- <bindingRedirect oldVersion="0.0.0.0-5.0.5.0" newVersion="5.0.5.0" />
- </dependentAssembly>
- <dependentAssembly>
- <assemblyIdentity name="System.Windows.Controls.Data" publicKeyToken="31bf3856ad364e35" culture="neutral" />
- <bindingRedirect oldVersion="0.0.0.0-5.0.5.0" newVersion="5.0.5.0" />
- </dependentAssembly>
- <dependentAssembly>
- <assemblyIdentity name="System.Xml.Linq" publicKeyToken="31bf3856ad364e35" culture="neutral" />
- <bindingRedirect oldVersion="0.0.0.0-5.0.5.0" newVersion="5.0.5.0" />
- </dependentAssembly>
- </assemblyBinding>
- </runtime>
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Windows.Controls" publicKeyToken="31bf3856ad364e35" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-5.0.5.0" newVersion="5.0.5.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Windows.Controls.Data.Input" publicKeyToken="31bf3856ad364e35" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-5.0.5.0" newVersion="5.0.5.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Windows.Controls.Data" publicKeyToken="31bf3856ad364e35" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-5.0.5.0" newVersion="5.0.5.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Xml.Linq" publicKeyToken="31bf3856ad364e35" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-5.0.5.0" newVersion="5.0.5.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
</configuration>
Please sign in to comment.
Something went wrong with that request. Please try again.