本文整理汇总了C#中DefaultDependencyResolver类的典型用法代码示例。如果您正苦于以下问题:C# DefaultDependencyResolver类的具体用法?C# DefaultDependencyResolver怎么用?C# DefaultDependencyResolver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DefaultDependencyResolver类属于命名空间,在下文中一共展示了DefaultDependencyResolver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EnsureHubThrowsWhenCantResolve
public void EnsureHubThrowsWhenCantResolve()
{
var resolver = new DefaultDependencyResolver();
var hubManager = new DefaultHubManager(resolver);
Assert.Throws<InvalidOperationException>(() => hubManager.EnsureHub("__ELLO__"));
}
示例2: SubscriptionWithCancelledTaskCanBeDisposed
public void SubscriptionWithCancelledTaskCanBeDisposed()
{
var dr = new DefaultDependencyResolver();
using (var bus = new MessageBus(dr))
{
var subscriber = new TestSubscriber(new[] { "key" });
var wh = new ManualResetEventSlim();
IDisposable subscription = bus.Subscribe(subscriber, null, async (result, state) =>
{
if (result.Terminal)
{
return false;
}
await Task.Delay(50);
var tcs = new TaskCompletionSource<bool>();
tcs.SetCanceled();
wh.Set();
return await tcs.Task;
}, 10, null);
bus.Publish("me", "key", "hello");
wh.Wait();
subscription.Dispose();
}
}
示例3: GetInValidHub
public void GetInValidHub()
{
var resolver = new DefaultDependencyResolver();
var hubManager = new DefaultHubManager(resolver);
var hubDescriptor = hubManager.GetHub("__ELLO__");
Assert.Null(hubDescriptor);
}
示例4: GetValidHubsWithValidPredicate
public void GetValidHubsWithValidPredicate()
{
var resolver = new DefaultDependencyResolver();
var hubManager = new DefaultHubManager(resolver);
var hubDescriptors = hubManager.GetHubs(descriptor => descriptor.Name == "CoreTestHub");
Assert.NotNull(hubDescriptors);
Assert.Equal(hubDescriptors.First().Name, "CoreTestHub");
}
示例5: GetValidHub
public void GetValidHub()
{
var resolver = new DefaultDependencyResolver();
var hubManager = new DefaultHubManager(resolver);
var hubDescriptor = hubManager.GetHub("CoreTestHub");
Assert.NotNull(hubDescriptor);
Assert.False(hubDescriptor.NameSpecified);
}
示例6: DisposablesAreTrackedAndDisposed
public void DisposablesAreTrackedAndDisposed()
{
var resolver = new DefaultDependencyResolver();
resolver.Register(typeof(MyDisposable), () => new MyDisposable());
var disposable = resolver.Resolve<MyDisposable>();
resolver.Dispose();
Assert.True(disposable.Disposed);
}
示例7: ShouldIgnoreCaseWhenDiscoveringHubsUsingManager
public void ShouldIgnoreCaseWhenDiscoveringHubsUsingManager()
{
var resolver = new DefaultDependencyResolver();
var manager = new DefaultHubManager(resolver);
var hub = manager.GetHub("hubwithoutattribute");
Assert.NotNull(hub);
Assert.Equal(hub.Name, "HubWithoutAttribute");
}
示例8: ShouldNotResolveHubByFullTypeName
public void ShouldNotResolveHubByFullTypeName()
{
var resolver = new DefaultDependencyResolver();
var hubResolver = new ReflectedHubDescriptorProvider(resolver);
HubDescriptor hub;
hubResolver.TryGetHub("SignalR.Tests.HubWithoutAttribute", out hub);
Assert.Null(hub);
}
示例9: ShouldNotResolveHubByTypeNameIfAttributeExists
public void ShouldNotResolveHubByTypeNameIfAttributeExists()
{
var resolver = new DefaultDependencyResolver();
var hubResolver = new ReflectedHubDescriptorProvider(resolver);
HubDescriptor hub;
hubResolver.TryGetHub("HubWithAttribute", out hub);
Assert.Null(hub);
}
示例10: GetInvalidHubMethod
public void GetInvalidHubMethod()
{
var resolver = new DefaultDependencyResolver();
var hubManager = new DefaultHubManager(resolver);
// The AddNumbers method has 2 parameters, so should not find the method
var methodDescriptor = hubManager.GetHubMethod("CoreTestHubWithMethod", "AddNumbers", null);
Assert.Null(methodDescriptor);
}
示例11: GetHubMethodFromInvalidHub
public void GetHubMethodFromInvalidHub()
{
var resolver = new DefaultDependencyResolver();
var hubManager = new DefaultHubManager(resolver);
// There is no ________________CoreTestHubWithMethod________________ name
var methodDescriptor = hubManager.GetHubMethod("________________CoreTestHubWithMethod________________", "AddNumbers", null, null);
Assert.Null(methodDescriptor);
}
示例12: SubscriptionDoesNotGetNewMessagesWhenTopicStoreOverrunByOtherStream
public void SubscriptionDoesNotGetNewMessagesWhenTopicStoreOverrunByOtherStream()
{
var dr = new DefaultDependencyResolver();
dr.Resolve<IConfigurationManager>().DefaultMessageBufferSize = 10;
using (var bus = new TestScaleoutBus(dr, streams: 2))
{
var subscriber = new TestSubscriber(new[] { "key" });
IDisposable subscription = null;
// The min fragment size is 8 and min fragments is 5
var expectedValues = Enumerable.Range(171, 8);
var cd = new OrderedCountDownRange<int>(expectedValues);
// This will overwrite the buffer ending up with (40 - 79) for stream 2
for (int i = 0; i < 80; i++)
{
bus.Publish(0, (ulong)i, new[] {
new Message("test", "key", i.ToString())
});
}
// This will overwrite the buffer with (140 - 179) for stream 1
for (int i = 100; i < 180; i++)
{
bus.Publish(1, (ulong)i, new[] {
new Message("test", "key", i.ToString())
});
}
try
{
subscription = bus.Subscribe(subscriber, "0,27|1,AA", (result, state) =>
{
foreach (var m in result.GetMessages())
{
int n = Int32.Parse(m.GetString());
cd.Expect(n);
}
return TaskAsyncHelper.True;
}, 100, null);
Assert.True(cd.Wait(TimeSpan.FromSeconds(10)));
}
finally
{
if (subscription != null)
{
subscription.Dispose();
}
}
}
}
示例13: ShouldIgnoreCaseWhenDiscoveringHubs
public void ShouldIgnoreCaseWhenDiscoveringHubs()
{
var resolver = new DefaultDependencyResolver();
var hubResolver = new ReflectedHubDescriptorProvider(resolver);
HubDescriptor hub;
hubResolver.TryGetHub("hubwithoutattribute", out hub);
Assert.NotNull(hub);
Assert.Equal(hub.Name, "HubWithoutAttribute");
}
示例14: ShouldResolveHubByTypeName
public void ShouldResolveHubByTypeName()
{
var resolver = new DefaultDependencyResolver();
var hubResolver = new ReflectedHubDescriptorProvider(resolver);
HubDescriptor hub;
hubResolver.TryGetHub("HubWithoutAttribute", out hub);
Assert.NotNull(hub);
Assert.Equal(hub.Name, "HubWithoutAttribute");
}
示例15: SubscriptionWithExistingCursor
public void SubscriptionWithExistingCursor()
{
var dr = new DefaultDependencyResolver();
var bus = new TestScaleoutBus(dr, topicCount: 2);
var subscriber = new TestSubscriber(new[] { "key" });
var cd = new CountDownRange<int>(Enumerable.Range(2, 4));
IDisposable subscription = null;
// test, test2 = 1
// test1, test3 = 0
//
// Cursor 1, 1
bus.SendMany(new[] {
new Message("test", "key", "1"),
new Message("test", "key", "50")
});
// Cursor 0,1|1,1
bus.SendMany(new[] {
new Message("test1", "key", "51")
});
bus.SendMany(new[]{
new Message("test2", "key", "2"),
new Message("test3", "key", "3"),
new Message("test2", "key", "4"),
});
try
{
subscription = bus.Subscribe(subscriber, "0,00000001|1,00000001", result =>
{
foreach (var m in result.GetMessages())
{
int n = Int32.Parse(m.Value);
Assert.True(cd.Mark(n));
}
return TaskAsyncHelper.True;
}, 10);
bus.SendMany(new[] { new Message("test", "key", "5") });
Assert.True(cd.Wait(TimeSpan.FromSeconds(10)));
}
finally
{
if (subscription != null)
{
subscription.Dispose();
}
}
}