Skip to content
Browse files

Do one first request instead of multiple times

  • Loading branch information...
1 parent 2dd2a58 commit 0611d289561329ab99878803349bcc2bfb9fcace @fitzchak fitzchak committed Mar 12, 2012
View
10 Raven.Client.Lightweight/Document/DocumentStore.cs
@@ -502,9 +502,19 @@ protected virtual void InitializeInternal()
};
#endif
#if !NET_3_5
+#if SILVERLIGHT
+ // required to ensure just a single auth dialog
+ var task = jsonRequestFactory.CreateHttpJsonRequest(this, (Url + "/docs?pageSize=0").NoCache(), "GET", credentials, Conventions)
+ .ExecuteRequest();
+#endif
asyncDatabaseCommandsGenerator = () =>
{
+
+#if SILVERLIGHT
+ var asyncServerClient = new AsyncServerClient(Url, Conventions, credentials, jsonRequestFactory, currentSessionId, task);
+#else
var asyncServerClient = new AsyncServerClient(Url, Conventions, credentials, jsonRequestFactory, currentSessionId);
+#endif
if (string.IsNullOrEmpty(DefaultDatabase))
return asyncServerClient;
return asyncServerClient.ForDatabase(DefaultDatabase);
View
17 Raven.Client.Silverlight/Connection/Async/AsyncServerClient.cs
@@ -41,6 +41,7 @@ public class AsyncServerClient : IAsyncDatabaseCommands
private readonly ICredentials credentials;
private readonly HttpJsonRequestFactory jsonRequestFactory;
private readonly Guid? sessionId;
+ private readonly Task veryFirstRequest;
private readonly DocumentConvention convention;
private readonly ProfilingInformation profilingInformation;
@@ -55,21 +56,19 @@ public HttpJsonRequestFactory 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)
+ public AsyncServerClient(string url, DocumentConvention convention, ICredentials credentials, HttpJsonRequestFactory jsonRequestFactory, Guid? sessionId, Task veryFirstRequest)
{
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;
- // required to ensure just a single auth dialog
- Task task = jsonRequestFactory.CreateHttpJsonRequest(this, (url + "/docs?pageSize=0").NoCache(), "GET", credentials, convention)
- .ExecuteRequest();
jsonRequestFactory.ConfigureRequest += (sender, args) =>
{
- args.JsonRequest.WaitForTask = task;
+ args.JsonRequest.WaitForTask = veryFirstRequest;
};
}
@@ -93,7 +92,7 @@ public IAsyncDatabaseCommands ForDatabase(string database)
{
var databaseUrl = RootDatabaseUrl;
databaseUrl = databaseUrl + "databases/" + database + "/";
- return new AsyncServerClient(databaseUrl, convention, credentials, jsonRequestFactory, sessionId)
+ return new AsyncServerClient(databaseUrl, convention, credentials, jsonRequestFactory, sessionId, veryFirstRequest)
{
operationsHeaders = operationsHeaders
};
@@ -108,7 +107,7 @@ public IAsyncDatabaseCommands ForDefaultDatabase()
var rootDatabaseUrl = RootDatabaseUrl;
if (rootDatabaseUrl == url)
return this;
- return new AsyncServerClient(rootDatabaseUrl, convention, credentials, jsonRequestFactory, sessionId)
+ return new AsyncServerClient(rootDatabaseUrl, convention, credentials, jsonRequestFactory, sessionId, veryFirstRequest)
{
operationsHeaders = operationsHeaders
};
@@ -134,7 +133,7 @@ private string RootDatabaseUrl
/// <param name="credentialsForSession">The credentials for session.</param>
public IAsyncDatabaseCommands With(ICredentials credentialsForSession)
{
- return new AsyncServerClient(url, convention, credentialsForSession, jsonRequestFactory, sessionId);
+ return new AsyncServerClient(url, convention, credentialsForSession, jsonRequestFactory, sessionId, veryFirstRequest);
}
/// <summary>
@@ -147,7 +146,7 @@ public IAsyncDatabaseCommands GetRootDatabase()
if (indexOfDatabases == -1)
return this;
- return new AsyncServerClient(url.Substring(0, indexOfDatabases), convention, credentials, jsonRequestFactory, sessionId);
+ return new AsyncServerClient(url.Substring(0, indexOfDatabases), convention, credentials, jsonRequestFactory, sessionId, veryFirstRequest);
}
private IDictionary<string, string> operationsHeaders = new Dictionary<string, string>();
View
4 Raven.Studio/Controls/Editors/JsonEditor.cs
@@ -23,10 +23,6 @@ public JsonEditor()
public class CustomSyntaxLanguage : SyntaxLanguage
{
- /////////////////////////////////////////////////////////////////////////////////////////////////////
- // OBJECT
- /////////////////////////////////////////////////////////////////////////////////////////////////////
-
/// <summary>
/// Initializes a new instance of the <c>CustomSyntaxLanguage</c> class.
/// </summary>
View
2 Raven.Studio/Models/ServerModel.cs
@@ -119,7 +119,7 @@ private static string DetermineUri()
{
if (HtmlPage.Document.DocumentUri.Scheme == "file")
{
- return "http://ravenhq.com:8080";
+ return "http://localhost:8080";
}
var localPath = HtmlPage.Document.DocumentUri.LocalPath;
var lastIndexOfRaven = localPath.LastIndexOf("/raven/", StringComparison.Ordinal);
View
1 Raven.Studio/Raven.Studio.csproj
@@ -136,6 +136,7 @@
</Reference>
<Reference Include="System.Xml" />
<Reference Include="System.Windows.Browser" />
+ <Reference Include="System.Xml.Linq, Version=5.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="TiledBG">
<HintPath>..\SharedLibs\Silverlight\TiledBG.dll</HintPath>
</Reference>
View
4 Raven.Studio/app.config
@@ -14,6 +14,10 @@
<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>

0 comments on commit 0611d28

Please sign in to comment.
Something went wrong with that request. Please try again.