Skip to content

Commit

Permalink
Minor
Browse files Browse the repository at this point in the history
  • Loading branch information
ayende committed Jul 9, 2012
1 parent 87cc9d4 commit 53c1137
Show file tree
Hide file tree
Showing 38 changed files with 4,750 additions and 4,750 deletions.
6 changes: 3 additions & 3 deletions Bundles/Raven.Bundles.IndexedProperties/packages.config
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NLog" version="2.0.0.2000" />
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NLog" version="2.0.0.2000" />
</packages>
262 changes: 131 additions & 131 deletions Raven.Client.Lightweight/Connection/CreateHttpJsonRequestParams.cs
@@ -1,132 +1,132 @@
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Net;
using Raven.Client.Connection.Profiling;
using Raven.Client.Document;
using Raven.Json.Linq;

namespace Raven.Client.Connection
{
public class CreateHttpJsonRequestParams
{
public CreateHttpJsonRequestParams(IHoldProfilingInformation self, string url, string method, RavenJObject metadata, ICredentials credentials, DocumentConvention convention)
{
Owner = self;
Url = url;
Method = method;
Metadata = metadata;
Credentials = credentials;
Convention = convention;
operationsHeadersColletion = new NameValueCollection();
}

/// <summary>
/// Adds the operation headers.
/// </summary>
/// <param name="operationsHeaders">The operations headers.</param>
public CreateHttpJsonRequestParams AddOperationHeaders(IDictionary<string, string> operationsHeaders)
{
urlCached = null;
operationsHeadersDictionary = operationsHeaders;
foreach (var operationsHeader in operationsHeaders)
{
operationHeadersHash = (operationHeadersHash*397) ^ operationsHeader.Key.GetHashCode();
if (operationsHeader.Value != null)
{
operationHeadersHash = (operationHeadersHash * 397) ^ operationsHeader.Value.GetHashCode();
}
}
return this;
}

/// <summary>
/// Adds the operation headers.
/// </summary>
/// <param name="operationsHeaders">The operations headers.</param>
public CreateHttpJsonRequestParams AddOperationHeaders(NameValueCollection operationsHeaders)
{
urlCached = null;
operationsHeadersColletion = operationsHeaders;
foreach (string operationsHeader in operationsHeadersColletion)
{
operationHeadersHash = (operationHeadersHash * 397) ^ operationsHeader.GetHashCode();
var values = operationsHeaders.GetValues(operationsHeader);
if (values == null)
continue;

foreach (var header in values.Where(header => header != null))
{
operationHeadersHash = (operationHeadersHash * 397) ^ header.GetHashCode();
}
}
return this;
}

public void UpdateHeaders(WebRequest webRequest)
{
if (operationsHeadersDictionary != null)
{
foreach (var kvp in operationsHeadersDictionary)
{
webRequest.Headers[kvp.Key] = kvp.Value;
}
}
if(operationsHeadersColletion != null)
{
foreach (string header in operationsHeadersColletion)
{
try
{
webRequest.Headers[header] = operationsHeadersColletion[header];
}
catch (Exception e)
{
throw new InvalidOperationException(
"Failed to set header '" + header + "' to the value: " + operationsHeadersColletion[header], e);
}
}
}
}

public CreateHttpJsonRequestParams(IHoldProfilingInformation self, string url, string method, ICredentials credentials, DocumentConvention convention)
: this(self, url, method, new RavenJObject(), credentials, convention)
{

}

private int operationHeadersHash;
private NameValueCollection operationsHeadersColletion;
private IDictionary<string, string> operationsHeadersDictionary;
public IHoldProfilingInformation Owner { get; set; }
private string url;
private string urlCached;

public string Url
{
get
{
if (urlCached != null)
return urlCached;
urlCached = GenerateUrl();
return urlCached;
}
set { url = value; }
}

private string GenerateUrl()
{
if (operationHeadersHash == 0)
return url;
if (url.Contains("?"))
return url + "&operationHeadersHash=" + operationHeadersHash;
return url + "?operationHeadersHash=" + operationHeadersHash;
}

public string Method { get; set; }
public RavenJObject Metadata { get; set; }
public ICredentials Credentials { get; set; }
public DocumentConvention Convention { get; set; }
}
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Net;
using Raven.Client.Connection.Profiling;
using Raven.Client.Document;
using Raven.Json.Linq;

namespace Raven.Client.Connection
{
public class CreateHttpJsonRequestParams
{
public CreateHttpJsonRequestParams(IHoldProfilingInformation self, string url, string method, RavenJObject metadata, ICredentials credentials, DocumentConvention convention)
{
Owner = self;
Url = url;
Method = method;
Metadata = metadata;
Credentials = credentials;
Convention = convention;
operationsHeadersColletion = new NameValueCollection();
}

/// <summary>
/// Adds the operation headers.
/// </summary>
/// <param name="operationsHeaders">The operations headers.</param>
public CreateHttpJsonRequestParams AddOperationHeaders(IDictionary<string, string> operationsHeaders)
{
urlCached = null;
operationsHeadersDictionary = operationsHeaders;
foreach (var operationsHeader in operationsHeaders)
{
operationHeadersHash = (operationHeadersHash*397) ^ operationsHeader.Key.GetHashCode();
if (operationsHeader.Value != null)
{
operationHeadersHash = (operationHeadersHash * 397) ^ operationsHeader.Value.GetHashCode();
}
}
return this;
}

/// <summary>
/// Adds the operation headers.
/// </summary>
/// <param name="operationsHeaders">The operations headers.</param>
public CreateHttpJsonRequestParams AddOperationHeaders(NameValueCollection operationsHeaders)
{
urlCached = null;
operationsHeadersColletion = operationsHeaders;
foreach (string operationsHeader in operationsHeadersColletion)
{
operationHeadersHash = (operationHeadersHash * 397) ^ operationsHeader.GetHashCode();
var values = operationsHeaders.GetValues(operationsHeader);
if (values == null)
continue;

foreach (var header in values.Where(header => header != null))
{
operationHeadersHash = (operationHeadersHash * 397) ^ header.GetHashCode();
}
}
return this;
}

public void UpdateHeaders(WebRequest webRequest)
{
if (operationsHeadersDictionary != null)
{
foreach (var kvp in operationsHeadersDictionary)
{
webRequest.Headers[kvp.Key] = kvp.Value;
}
}
if(operationsHeadersColletion != null)
{
foreach (string header in operationsHeadersColletion)
{
try
{
webRequest.Headers[header] = operationsHeadersColletion[header];
}
catch (Exception e)
{
throw new InvalidOperationException(
"Failed to set header '" + header + "' to the value: " + operationsHeadersColletion[header], e);
}
}
}
}

public CreateHttpJsonRequestParams(IHoldProfilingInformation self, string url, string method, ICredentials credentials, DocumentConvention convention)
: this(self, url, method, new RavenJObject(), credentials, convention)
{

}

private int operationHeadersHash;
private NameValueCollection operationsHeadersColletion;
private IDictionary<string, string> operationsHeadersDictionary;
public IHoldProfilingInformation Owner { get; set; }
private string url;
private string urlCached;

public string Url
{
get
{
if (urlCached != null)
return urlCached;
urlCached = GenerateUrl();
return urlCached;
}
set { url = value; }
}

private string GenerateUrl()
{
if (operationHeadersHash == 0)
return url;
if (url.Contains("?"))
return url + "&operationHeadersHash=" + operationHeadersHash;
return url + "?operationHeadersHash=" + operationHeadersHash;
}

public string Method { get; set; }
public RavenJObject Metadata { get; set; }
public ICredentials Credentials { get; set; }
public DocumentConvention Convention { get; set; }
}
}
68 changes: 34 additions & 34 deletions Raven.Client.Lightweight/Indexes/IClientSideDatabase.cs
@@ -1,35 +1,35 @@
//-----------------------------------------------------------------------
// <copyright file="IClientSideDatabase.cs" company="Hibernating Rhinos LTD">
// Copyright (c) Hibernating Rhinos LTD. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
using System.Collections.Generic;

namespace Raven.Client.Indexes
{
/// <summary>
/// DatabaseAccessor for loading documents in the translator
/// </summary>
public interface IClientSideDatabase
{
/// <summary>
/// Loading a document during result transformers
/// </summary>
T Load<T>(string docId);

/// <summary>
/// Loading documents during result transformers
/// </summary>
T[] Load<T>(IEnumerable<string> docIds);

/// <summary>
/// Will ask RavenDB to include this document in the query results
/// </summary>
object Include(string docId);

/// <summary>
/// Will ask RavenDB to include these documents in the query results
/// </summary>
object Include(IEnumerable<string> docId);
}
//-----------------------------------------------------------------------
// <copyright file="IClientSideDatabase.cs" company="Hibernating Rhinos LTD">
// Copyright (c) Hibernating Rhinos LTD. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
using System.Collections.Generic;

namespace Raven.Client.Indexes
{
/// <summary>
/// DatabaseAccessor for loading documents in the translator
/// </summary>
public interface IClientSideDatabase
{
/// <summary>
/// Loading a document during result transformers
/// </summary>
T Load<T>(string docId);

/// <summary>
/// Loading documents during result transformers
/// </summary>
T[] Load<T>(IEnumerable<string> docIds);

/// <summary>
/// Will ask RavenDB to include this document in the query results
/// </summary>
object Include(string docId);

/// <summary>
/// Will ask RavenDB to include these documents in the query results
/// </summary>
object Include(IEnumerable<string> docId);
}
}
28 changes: 14 additions & 14 deletions Raven.Database/Data/QueryResultWithIncludes.cs
@@ -1,15 +1,15 @@
// -----------------------------------------------------------------------
// <copyright file="QueryResultWithIncludes.cs" company="Hibernating Rhinos LTD">
// Copyright (c) Hibernating Rhinos LTD. All rights reserved.
// </copyright>
// -----------------------------------------------------------------------
using System.Collections.Generic;
using Raven.Abstractions.Data;

namespace Raven.Database.Data
{
public class QueryResultWithIncludes : QueryResult
{
public HashSet<string> IdsToInclude { get; set; }
}
// -----------------------------------------------------------------------
// <copyright file="QueryResultWithIncludes.cs" company="Hibernating Rhinos LTD">
// Copyright (c) Hibernating Rhinos LTD. All rights reserved.
// </copyright>
// -----------------------------------------------------------------------
using System.Collections.Generic;
using Raven.Abstractions.Data;

namespace Raven.Database.Data
{
public class QueryResultWithIncludes : QueryResult
{
public HashSet<string> IdsToInclude { get; set; }
}
}

0 comments on commit 53c1137

Please sign in to comment.