本文整理汇总了C#中ConnectionConfiguration类的典型用法代码示例。如果您正苦于以下问题:C# ConnectionConfiguration类的具体用法?C# ConnectionConfiguration怎么用?C# ConnectionConfiguration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConnectionConfiguration类属于命名空间,在下文中一共展示了ConnectionConfiguration类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: InstantiatingAConnectionPoolClient
/**
* This however is still a non-failover connection. Meaning if that `node` goes down the operation will not be retried on any other nodes in the cluster.
*
* To get a failover connection we have to pass an `IConnectionPool` instance instead of a `Uri`.
*/
public void InstantiatingAConnectionPoolClient()
{
var node = new Uri("http://mynode.example.com:8082/apiKey");
var connectionPool = new SniffingConnectionPool(new[] { node });
var config = new ConnectionConfiguration(connectionPool);
var client = new ElasticsearchClient(config);
}
开发者ID:matteus6007,项目名称:elasticsearch-net,代码行数:13,代码来源:Connecting.doc.cs
示例2: SetUp
public void SetUp()
{
persistentConnection = MockRepository.GenerateStub<IPersistentConnection>();
channel = MockRepository.GenerateStub<IModel>();
var eventBus = new EventBus();
var configuration = new ConnectionConfiguration();
var shutdownArgs = new ShutdownEventArgs(
ShutdownInitiator.Peer,
AmqpException.ConnectionClosed,
"connection closed by peer");
var exception = new OperationInterruptedException(shutdownArgs);
var first = true;
persistentConnection.Stub(x => x.CreateModel()).WhenCalled(x =>
{
if (first)
{
first = false;
throw exception;
}
x.ReturnValue = channel;
});
var logger = MockRepository.GenerateStub<IEasyNetQLogger>();
persistentChannel = new PersistentChannel(persistentConnection, logger, configuration, eventBus);
new Timer(_ => eventBus.Publish(new ConnectionCreatedEvent())).Change(10, Timeout.Infinite);
persistentChannel.InvokeChannelAction(x => x.ExchangeDeclare("MyExchange", "direct"));
}
开发者ID:akzhigitov,项目名称:EasyNetQ,代码行数:32,代码来源:When_an_action_is_performed_on_a_closed_channel_that_then_opens.cs
示例3: PersistentConnectionHandler
public PersistentConnectionHandler(AppFunc next, string path, Type connectionType, ConnectionConfiguration configuration)
{
_next = next;
_path = path;
_connectionType = connectionType;
_configuration = configuration;
}
开发者ID:Djohnnie,项目名称:Sonarr,代码行数:7,代码来源:PersistentConnectionHandler.cs
示例4: SetUp
public void SetUp()
{
persistentConnection = MockRepository.GenerateStub<IPersistentConnection>();
var eventBus = MockRepository.GenerateStub<IEventBus>();
var configuration = new ConnectionConfiguration
{
Timeout = 1
};
var shutdownArgs = new ShutdownEventArgs(
ShutdownInitiator.Peer,
AmqpException.ConnectionClosed,
"connection closed by peer");
var exception = new OperationInterruptedException(shutdownArgs);
persistentConnection.Stub(x => x.CreateModel()).WhenCalled(x =>
{
throw exception;
});
var logger = MockRepository.GenerateStub<IEasyNetQLogger>();
persistentChannel = new PersistentChannel(persistentConnection, logger, configuration, eventBus);
}
开发者ID:hippasus,项目名称:EasyNetQ,代码行数:26,代码来源:When_an_action_is_performed_on_a_closed_channel_that_doesnt_open_again.cs
示例5: ProfiledElasticsearchClient
/// <summary>
/// Provides base <see cref="ElasticsearchClient"/> with profiling features to current <see cref="MiniProfiler"/> session.
/// </summary>
/// <param name="configuration">Instance of <see cref="ConnectionConfiguration"/>. Its responses will be handled and pushed to <see cref="MiniProfiler"/></param>
public ProfiledElasticsearchClient(ConnectionConfiguration configuration)
: base(configuration)
{
ProfilerUtils.ExcludeElasticsearchAssemblies();
ProfilerUtils.ApplyConfigurationSettings(configuration);
configuration.SetConnectionStatusHandler(response => MiniProfilerElasticsearch.HandleResponse(response, _profiler));
}
开发者ID:bigerock,项目名称:MiniProfiler.Elasticsearch,代码行数:11,代码来源:ProfiledElasticsearchClient.cs
示例6: ConsumerDispatcherFactory
public ConsumerDispatcherFactory(ConnectionConfiguration configuration, IEasyNetQLogger logger)
{
Preconditions.CheckNotNull(configuration, "configuration");
Preconditions.CheckNotNull(logger, "logger");
dispatcher = new Lazy<IConsumerDispatcher>(() => new ConsumerDispatcher(configuration, logger));
}
开发者ID:hippasus,项目名称:EasyNetQ,代码行数:7,代码来源:ConsumerDispatcherFactory.cs
示例7: Parse
public IConnectionConfiguration Parse(string connectionString)
{
ConnectionString = connectionString;
try
{
connectionConfiguration = new ConnectionConfiguration();
foreach(var pair in
(from property in typeof(ConnectionConfiguration).GetProperties()
let match = Regex.Match(connectionString, string.Format("[^\\w]*{0}=(?<{0}>[^;]+)", property.Name), RegexOptions.IgnoreCase)
where match.Success
select new { Property = property, match.Groups[property.Name].Value }))
pair.Property.SetValue(connectionConfiguration, TypeDescriptor.GetConverter(pair.Property.PropertyType).ConvertFromString(pair.Value),null);
if (ContainsKey("host"))
connectionConfiguration.ParseHosts(this["host"] as string);
connectionConfiguration.Validate();
return connectionConfiguration;
}
catch (Exception parseException)
{
throw new Exception(string.Format("Connection String parsing exception {0}", parseException.Message));
}
}
开发者ID:afyles,项目名称:NServiceBus,代码行数:26,代码来源:ConnectionStringParser.cs
示例8: IfResponseIsKnowError_DoNotRetry_ThrowServerException_Async
public void IfResponseIsKnowError_DoNotRetry_ThrowServerException_Async(int status, string exceptionType, string exceptionMessage)
{
var response = CreateServerExceptionResponse(status, exceptionType, exceptionMessage);
using (var fake = new AutoFake(callsDoNothing: true))
{
var connectionPool = new StaticConnectionPool(new[]
{
new Uri("http://localhost:9200"),
new Uri("http://localhost:9201"),
});
var connectionConfiguration = new ConnectionConfiguration(connectionPool)
.ThrowOnElasticsearchServerExceptions()
.ExposeRawResponse(false);
fake.Provide<IConnectionConfigurationValues>(connectionConfiguration);
FakeCalls.ProvideDefaultTransport(fake);
var pingCall = FakeCalls.PingAtConnectionLevelAsync(fake);
pingCall.Returns(FakeResponse.OkAsync(connectionConfiguration));
var getCall = FakeCalls.GetCall(fake);
getCall.Returns(FakeResponse.AnyAsync(connectionConfiguration, status, response: response));
var client = fake.Resolve<ElasticsearchClient>();
var e = Assert.Throws<ElasticsearchServerException>(async ()=>await client.InfoAsync());
AssertServerErrorsOnResponse(e, status, exceptionType, exceptionMessage);
//make sure a know ElasticsearchServerException does not cause a retry
//In this case we want to fail early
getCall.MustHaveHappened(Repeated.Exactly.Once);
}
}
开发者ID:strongant,项目名称:elasticsearch-net,代码行数:35,代码来源:ServerExceptionRetryHandlingTests.cs
示例9: Ping_should_work
public void Ping_should_work()
{
var settings = new ConnectionConfiguration(new Uri(TestConfig.Endpoint));
var client = new ElasticsearchClient(settings, new AwsHttpConnection(settings, TestConfig.AwsSettings));
var response = client.Ping();
Assert.AreEqual(200, response.HttpStatusCode.GetValueOrDefault(-1));
}
开发者ID:emmekappa,项目名称:elasticsearch-net-aws,代码行数:7,代码来源:PingTests.cs
示例10: ClientCommandDispatcherFactory
public ClientCommandDispatcherFactory(ConnectionConfiguration configuration, IPersistentChannelFactory persistentChannelFactory)
{
Preconditions.CheckNotNull(configuration, "configuration");
Preconditions.CheckNotNull(persistentChannelFactory, "persistentChannelFactory");
this.configuration = configuration;
this.persistentChannelFactory = persistentChannelFactory;
}
开发者ID:hippasus,项目名称:EasyNetQ,代码行数:7,代码来源:IClientCommandDispatcherFactory.cs
示例11: The_AuthMechanisms_property_should_default_to_PlainMechanism
public void The_AuthMechanisms_property_should_default_to_PlainMechanism()
{
ConnectionConfiguration connectionConfiguration = new ConnectionConfiguration();
connectionConfiguration.AuthMechanisms.Count.ShouldEqual(1);
connectionConfiguration.AuthMechanisms.Single().ShouldBeOfType<PlainMechanismFactory>();
}
开发者ID:EasyNetQ,项目名称:EasyNetQ,代码行数:7,代码来源:ConnectionConfigurationTests.cs
示例12: ServerExceptionIsCaught_KeepResponse
public void ServerExceptionIsCaught_KeepResponse(int status, string exceptionType, string exceptionMessage)
{
var response = CreateServerExceptionResponse(status, exceptionType, exceptionMessage);
using (var fake = new AutoFake(callsDoNothing: true))
{
var connectionConfiguration = new ConnectionConfiguration()
.ExposeRawResponse(true);
fake.Provide<IConnectionConfigurationValues>(connectionConfiguration);
FakeCalls.ProvideDefaultTransport(fake);
var getCall = FakeCalls.GetSyncCall(fake);
getCall.Returns(FakeResponse.Bad(connectionConfiguration, response: response));
var client = fake.Resolve<ElasticsearchClient>();
var result = client.Info();
result.Success.Should().BeFalse();
AssertServerErrorsOnResponse(result, status, exceptionType, exceptionMessage);
result.ResponseRaw.Should().NotBeNull();
getCall.MustHaveHappened(Repeated.Exactly.Once);
}
}
开发者ID:herqueles3,项目名称:elasticsearch-net,代码行数:26,代码来源:ElasticsearchServerExceptions.cs
示例13: SetUp
public void SetUp()
{
var configuration = new ConnectionConfiguration
{
Hosts = new List<IHostConfiguration>
{
new HostConfiguration { Host = "localhost", Port = 5672 }
},
UserName = "guest",
Password = "guest"
};
configuration.Validate();
var typeNameSerializer = new TypeNameSerializer();
connectionFactory = new ConnectionFactoryWrapper(configuration, new DefaultClusterHostSelectionStrategy<ConnectionFactoryInfo>());
serializer = new JsonSerializer(typeNameSerializer);
conventions = new Conventions(typeNameSerializer);
consumerErrorStrategy = new DefaultConsumerErrorStrategy(
connectionFactory,
serializer,
new ConsoleLogger(),
conventions,
typeNameSerializer);
}
开发者ID:autotagamerica,项目名称:EasyNetQ,代码行数:26,代码来源:DefaultConsumerErrorStrategyTests.cs
示例14: TestWindow
/// <summary>
/// The test window.
/// </summary>
public void TestWindow()
{
var mocks = new MockRepository();
var mockHttpReq = mocks.Stub<IHttpSonarConnector>();
var mockVsHelpers = mocks.Stub<IVsEnvironmentHelper>();
var config = new ConnectionConfiguration("serveraddr", "login", "password");
// set expectations
using (mocks.Record())
{
SetupResult.For(mockHttpReq.HttpSonarGetRequest(config, "/api/issues/search?components=resource"))
.Return(File.ReadAllText("TestData/issuessearchbycomponent.txt"));
SetupResult.For(mockHttpReq.HttpSonarGetRequest(config, "/api/users/search")).Return(File.ReadAllText("TestData/userList.txt"));
}
ISonarRestService service = new SonarRestService(mockHttpReq);
service.GetIssuesInResource(config, "resource");
var associatedProject = new Resource { Key = "core:Common" };
this.model = new ExtensionDataModel(service, mockVsHelpers, associatedProject, null);
var t = new Thread(this.Threadprc);
t.SetApartmentState(ApartmentState.STA);
t.Start();
t.Join();
}
开发者ID:kanchanachalla,项目名称:VSSonarQubeExtension,代码行数:28,代码来源:TestMainWindow.cs
示例15: ConnectionsWithTheSameConnectionIdLongPollingCloseGracefully
public void ConnectionsWithTheSameConnectionIdLongPollingCloseGracefully()
{
using (var host = new MemoryHost())
{
host.Configure(app =>
{
var config = new ConnectionConfiguration
{
Resolver = new DefaultDependencyResolver()
};
app.MapSignalR<MyGroupEchoConnection>("/echo", config);
config.Resolver.Register(typeof(IProtectedData), () => new EmptyProtectedData());
});
string id = Guid.NewGuid().ToString("d");
var tasks = new List<Task>();
for (int i = 0; i < 1000; i++)
{
tasks.Add(ProcessRequest(host, "longPolling", id));
}
ProcessRequest(host, "longPolling", id);
Task.WaitAll(tasks.ToArray());
Assert.True(tasks.All(t => !t.IsFaulted));
}
}
开发者ID:nirmana,项目名称:SignalR,代码行数:32,代码来源:PersistentConnectionFacts.cs
示例16: StaticConnectionPoolTests
public StaticConnectionPoolTests()
{
_connectionPool = new StaticConnectionPool(_uris);
_config = new ConnectionConfiguration(_connectionPool);
_ok = FakeResponse.Ok(_config);
_bad = FakeResponse.Bad(_config);
}
开发者ID:strongant,项目名称:elasticsearch-net,代码行数:8,代码来源:StaticConnectionPoolTests.cs
示例17: PersistentConnectionMiddleware
public PersistentConnectionMiddleware(OwinMiddleware next,
Type connectionType,
ConnectionConfiguration configuration)
: base(next)
{
_connectionType = connectionType;
_configuration = configuration;
}
开发者ID:Choulla-Naresh8264,项目名称:SignalR,代码行数:8,代码来源:PersistentConnectionMiddleware.cs
示例18: ConcurrencyTests
public ConcurrencyTests()
{
_connectionPool = new SniffingConnectionPool(_uris);
_config = new ConnectionConfiguration(_connectionPool)
.SniffOnConnectionFault()
.SniffOnStartup()
.MaximumRetries(5);
}
开发者ID:herqueles3,项目名称:elasticsearch-net,代码行数:8,代码来源:ConcurrencyTests.cs
示例19: Asterisk_encoded_url_should_work
public void Asterisk_encoded_url_should_work()
{
var httpConnection = new AwsHttpConnection(TestConfig.AwsSettings);
var pool = new SingleNodeConnectionPool(new Uri(TestConfig.Endpoint));
var config = new ConnectionConfiguration(pool, httpConnection);
var client = new ElasticLowLevelClient(config);
var response = client.Get<Stream>("index*", "type", "id");
Assert.AreEqual(404, response.HttpStatusCode.GetValueOrDefault(-1));
}
开发者ID:bcuff,项目名称:elasticsearch-net-aws,代码行数:9,代码来源:PingTests.cs
示例20: Ping_should_work
public void Ping_should_work()
{
var httpConnection = new AwsHttpConnection(TestConfig.AwsSettings);
var pool = new SingleNodeConnectionPool(new Uri(TestConfig.Endpoint));
var config = new ConnectionConfiguration(pool, httpConnection);
var client = new ElasticLowLevelClient(config);
var response = client.Ping<object>();
Assert.AreEqual(200, response.HttpStatusCode.GetValueOrDefault(-1));
}
开发者ID:bcuff,项目名称:elasticsearch-net-aws,代码行数:9,代码来源:PingTests.cs
注:本文中的ConnectionConfiguration类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论