本文整理汇总了C#中RavenConnectionStringOptions类的典型用法代码示例。如果您正苦于以下问题:C# RavenConnectionStringOptions类的具体用法?C# RavenConnectionStringOptions怎么用?C# RavenConnectionStringOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RavenConnectionStringOptions类属于命名空间,在下文中一共展示了RavenConnectionStringOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExportAttachments
protected override Task<Etag> ExportAttachments(RavenConnectionStringOptions src, JsonTextWriter jsonWriter, Etag lastEtag, Etag maxEtag)
{
if (maxEtag != null)
throw new ArgumentException("We don't support maxEtag in SmugglerDatabaseApi", maxEtag);
return base.ExportAttachments(src, jsonWriter, lastEtag, null);
}
示例2: GetIndexes
protected async override Task<RavenJArray> GetIndexes(RavenConnectionStringOptions src, int totalCount)
{
RavenJArray indexes = null;
var request = CreateRequest(src, "/indexes?pageSize=" + SmugglerOptions.BatchSize + "&start=" + totalCount);
request.ExecuteRequest(reader => indexes = RavenJArray.Load(new JsonTextReader(reader)));
return indexes;
}
示例3: CopyAttachmentsToFileSystem
public CopyAttachmentsToFileSystem(RavenConnectionStringOptions databaseConnectionOptions, RavenConnectionStringOptions fileSystemConnectionOptions, string fileSystemName, bool deleteCopiedAttachments)
{
this.databaseConnectionOptions = databaseConnectionOptions;
this.fileSystemConnectionOptions = fileSystemConnectionOptions;
this.fileSystemName = fileSystemName;
this.deleteCopiedAttachments = deleteCopiedAttachments;
}
示例4: ConfigureRequest
public void ConfigureRequest(RavenConnectionStringOptions options, HttpWebRequest request)
{
if (RequestTimeoutInMs.HasValue)
request.Timeout = RequestTimeoutInMs.Value;
if (AllowWriteStreamBuffering.HasValue)
{
request.AllowWriteStreamBuffering = AllowWriteStreamBuffering.Value;
if(AllowWriteStreamBuffering.Value == false)
request.SendChunked = true;
}
if (options.ApiKey == null)
{
request.Credentials = options.Credentials ?? CredentialCache.DefaultNetworkCredentials;
return;
}
var webRequestEventArgs = new WebRequestEventArgs { Request = request, Credentials = new OperationCredentials(options.ApiKey, options.Credentials)};
AbstractAuthenticator existingAuthenticator;
if (authenticators.TryGetValue(GetCacheKey(options), out existingAuthenticator))
{
existingAuthenticator.ConfigureRequest(this, webRequestEventArgs);
}
else
{
var basicAuthenticator = new BasicAuthenticator(enableBasicAuthenticationOverUnsecuredHttp: false);
var securedAuthenticator = new SecuredAuthenticator();
basicAuthenticator.ConfigureRequest(this, webRequestEventArgs);
securedAuthenticator.ConfigureRequest(this, webRequestEventArgs);
}
}
示例5: SmugglerShouldThrowIfDatabaseDoesNotExist
public async Task SmugglerShouldThrowIfDatabaseDoesNotExist()
{
var path = Path.GetTempFileName();
try
{
using (var store = NewRemoteDocumentStore())
{
var connectionStringOptions =
new RavenConnectionStringOptions
{
Url = store.Url,
DefaultDatabase = "DoesNotExist"
};
var smuggler = new SmugglerDatabaseApi();
var e = await AssertAsync.Throws<SmugglerException>(() => smuggler.ImportData(
new SmugglerImportOptions<RavenConnectionStringOptions> { FromFile = path, To = connectionStringOptions }));
Assert.Equal(string.Format("Smuggler does not support database creation (database 'DoesNotExist' on server '{0}' must exist before running Smuggler).", store.Url), e.Message);
e = await AssertAsync.Throws<SmugglerException>(() => smuggler.ExportData(
new SmugglerExportOptions<RavenConnectionStringOptions> { ToFile = path, From = connectionStringOptions }));
Assert.Equal(string.Format("Smuggler does not support database creation (database 'DoesNotExist' on server '{0}' must exist before running Smuggler).", store.Url), e.Message);
}
}
finally
{
IOExtensions.DeleteFile(path);
}
}
示例6: should_respect_defaultdb_properly
public void should_respect_defaultdb_properly()
{
var connectionStringOptions = new RavenConnectionStringOptions {Url = "http://localhost:8080", DefaultDatabase = "test"};
var rootDatabaseUrl = GetRootDatabaseUrl(connectionStringOptions.Url);
var docUrl = rootDatabaseUrl + "/docs/Raven/Databases/" + connectionStringOptions.DefaultDatabase;
Console.WriteLine(docUrl);
}
示例7: TrafficToolConfiguration
public TrafficToolConfiguration()
{
ConnectionString = new RavenConnectionStringOptions();
IsCompressed = false;
Timeout = TimeSpan.MinValue;
PrintOutput = true;
}
示例8: ConfigureRequest
public void ConfigureRequest(RavenConnectionStringOptions options, WebRequest request)
{
if (RequestTimeoutInMs.HasValue)
request.Timeout = RequestTimeoutInMs.Value;
if (options.ApiKey == null)
{
request.Credentials = options.Credentials ?? CredentialCache.DefaultNetworkCredentials;
return;
}
var webRequestEventArgs = new WebRequestEventArgs { Request = request };
AbstractAuthenticator existingAuthenticator;
if (authenticators.TryGetValue(GetCacheKey(options), out existingAuthenticator))
{
existingAuthenticator.ConfigureRequest(this, webRequestEventArgs);
}
else
{
var basicAuthenticator = new BasicAuthenticator(options.ApiKey, enableBasicAuthenticationOverUnsecuredHttp: false);
var securedAuthenticator = new SecuredAuthenticator(options.ApiKey);
basicAuthenticator.ConfigureRequest(this, webRequestEventArgs);
securedAuthenticator.ConfigureRequest(this, webRequestEventArgs);
}
}
示例9: HandleUnauthorizedResponse
private Action<HttpWebRequest> HandleUnauthorizedResponse(RavenConnectionStringOptions options, WebResponse webResponse)
{
if (options.ApiKey == null)
return null;
var oauthSource = webResponse.Headers["OAuth-Source"];
var useBasicAuthenticator =
string.IsNullOrEmpty(oauthSource) == false &&
oauthSource.EndsWith("/OAuth/API-Key", StringComparison.CurrentCultureIgnoreCase) == false;
if (string.IsNullOrEmpty(oauthSource))
oauthSource = options.Url + "/OAuth/API-Key";
var authenticator = authenticators.GetOrAdd(
GetCacheKey(options),
_ =>
{
if (useBasicAuthenticator)
{
return new BasicAuthenticator(enableBasicAuthenticationOverUnsecuredHttp: false);
}
return new SecuredAuthenticator();
});
return authenticator.DoOAuthRequest(oauthSource, options.ApiKey);
}
示例10: CreateFileSystemClient
protected AsyncFilesServerClient CreateFileSystemClient(RavenConnectionStringOptions options, string fileSystemName)
{
var fsClient = new AsyncFilesServerClient(options.Url, fileSystemName, apiKey: options.ApiKey, credentials: options.Credentials);
ValidateThatServerIsUpAndFileSystemExists(fsClient);
return fsClient;
}
示例11: GetCredentials
private static NetworkCredential GetCredentials(RavenConnectionStringOptions connectionStringOptions)
{
var cred = connectionStringOptions.Credentials as NetworkCredential;
if (cred != null)
return cred;
cred = new NetworkCredential();
connectionStringOptions.Credentials = cred;
return cred;
}
示例12: GetDocuments
public Task<IAsyncEnumerator<RavenJObject>> GetDocuments(RavenConnectionStringOptions src, Etag lastEtag, int take)
{
const int dummy = 0;
var enumerator = database.Documents.GetDocumentsAsJson(dummy, Math.Min(Options.BatchSize, take), lastEtag, CancellationToken.None)
.ToList()
.Cast<RavenJObject>()
.GetEnumerator();
return new CompletedTask<IAsyncEnumerator<RavenJObject>>(new AsyncEnumeratorBridge<RavenJObject>(enumerator));
}
示例13: ConfigureRequest
public void ConfigureRequest(RavenConnectionStringOptions options, WebRequest request)
{
request.Credentials = options.Credentials ?? CredentialCache.DefaultNetworkCredentials;
if (RequestTimeoutInMs.HasValue)
request.Timeout = RequestTimeoutInMs.Value;
if (string.IsNullOrEmpty(options.CurrentOAuthToken) == false)
request.Headers["Authorization"] = options.CurrentOAuthToken;
}
示例14: should_respect_defaultdb_properly
public void should_respect_defaultdb_properly()
{
var connectionStringOptions = new RavenConnectionStringOptions();
//SmugglerAction action = SmugglerAction.Import;
connectionStringOptions.Url = "http://localhost:8080";
connectionStringOptions.DefaultDatabase = "test";
var api = new SmugglerTester(connectionStringOptions);
var rootDatabaseUrl = GetRootDatabaseUrl(connectionStringOptions.Url);
var docUrl = rootDatabaseUrl + "/docs/Raven/Databases/" + connectionStringOptions.DefaultDatabase;
Console.WriteLine(docUrl);
}
示例15: HandleUnauthorizedResponse
private bool HandleUnauthorizedResponse(RavenConnectionStringOptions options, WebResponse webResponse)
{
if (options.ApiKey == null)
return false;
var value = authenticators.GetOrAdd(options.ApiKey, s => new SecuredAuthenticator(s));
var oauthSource = options.Url + "/OAuth/API-Key";
var result = value.DoOAuthRequest(oauthSource);
return result != null;
}