• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# DefaultDependencyResolver类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中DefaultDependencyResolver的典型用法代码示例。如果您正苦于以下问题:C# DefaultDependencyResolver类的具体用法?C# DefaultDependencyResolver怎么用?C# DefaultDependencyResolver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DefaultDependencyResolver类属于命名空间,在下文中一共展示了DefaultDependencyResolver类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: EnsureHubThrowsWhenCantResolve

        public void EnsureHubThrowsWhenCantResolve()
        {
            var resolver = new DefaultDependencyResolver();
            var hubManager = new DefaultHubManager(resolver);

            Assert.Throws<InvalidOperationException>(() => hubManager.EnsureHub("__ELLO__"));
        }
开发者ID:Choulla-Naresh8264,项目名称:SignalR,代码行数:7,代码来源:HubManagerExtensionsFacts.cs


示例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();
            }
        }
开发者ID:Choulla-Naresh8264,项目名称:SignalR,代码行数:30,代码来源:MessageBusFacts.cs


示例3: GetInValidHub

        public void GetInValidHub()
        {
            var resolver = new DefaultDependencyResolver();
            var hubManager = new DefaultHubManager(resolver);
            var hubDescriptor = hubManager.GetHub("__ELLO__");

            Assert.Null(hubDescriptor);
        }
开发者ID:GaneshBachhao,项目名称:SignalR,代码行数:8,代码来源:DefaultHubManagerFacts.cs


示例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");
        }
开发者ID:GaneshBachhao,项目名称:SignalR,代码行数:9,代码来源:DefaultHubManagerFacts.cs


示例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);
        }
开发者ID:GaneshBachhao,项目名称:SignalR,代码行数:9,代码来源:DefaultHubManagerFacts.cs


示例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);
        }
开发者ID:Choulla-Naresh8264,项目名称:SignalR,代码行数:9,代码来源:DefaultDependencyResolverFacts.cs


示例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");
        }
开发者ID:nightbob3,项目名称:SignalR,代码行数:9,代码来源:DefaultHubResolverTest.cs


示例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);
        }
开发者ID:nightbob3,项目名称:SignalR,代码行数:9,代码来源:DefaultHubResolverTest.cs


示例9: ShouldNotResolveHubByTypeNameIfAttributeExists

        public void ShouldNotResolveHubByTypeNameIfAttributeExists()
        {
            var resolver = new DefaultDependencyResolver();
            var hubResolver = new ReflectedHubDescriptorProvider(resolver);
            HubDescriptor hub;
            hubResolver.TryGetHub("HubWithAttribute", out hub);

            Assert.Null(hub);
        }
开发者ID:nightbob3,项目名称:SignalR,代码行数:9,代码来源:DefaultHubResolverTest.cs


示例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);
        }
开发者ID:rustd,项目名称:SignalR,代码行数:9,代码来源:DefaultHubManagerFacts.cs


示例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);
        }
开发者ID:rustd,项目名称:SignalR,代码行数:9,代码来源:DefaultHubManagerFacts.cs


示例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();
                    }
                }
            }
        }
开发者ID:hallco978,项目名称:SignalR,代码行数:56,代码来源:ScaleOutMessageBusFacts.cs


示例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");
        }
开发者ID:nightbob3,项目名称:SignalR,代码行数:10,代码来源:DefaultHubResolverTest.cs


示例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");
        }
开发者ID:nightbob3,项目名称:SignalR,代码行数:10,代码来源:DefaultHubResolverTest.cs


示例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();
                }
            }
        }
开发者ID:Louis2870,项目名称:SignalR,代码行数:55,代码来源:ScaleOutMessageBusFacts.cs


示例16: GetValidHubMethodsWithInvalidPredicate

        public void GetValidHubMethodsWithInvalidPredicate()
        {
            var resolver = new DefaultDependencyResolver();
            var hubManager = new DefaultHubManager(resolver);
            var methodDescriptors = hubManager.GetHubMethods("CoreTestHubWithMethod", descriptor => descriptor.Name == "______AddNumbers______");

            // Still have an ienumerable sequence
            Assert.NotNull(methodDescriptors);
            // But there's nothing in the ienumerable
            Assert.Empty(methodDescriptors);
        }
开发者ID:rustd,项目名称:SignalR,代码行数:11,代码来源:DefaultHubManagerFacts.cs


示例17: ShouldResolveHubByHubNameAttribute

        public void ShouldResolveHubByHubNameAttribute()
        {
            var resolver = new DefaultDependencyResolver();
            var hubResolver = new ReflectedHubDescriptorProvider(resolver);
            HubDescriptor hub;
            hubResolver.TryGetHub("NameFromAttribute", out hub);

            Assert.NotNull(hub);
            Assert.Equal(hub.Name, "NameFromAttribute");
            Assert.Equal(hub.NameSpecified, true);
        }
开发者ID:GaneshBachhao,项目名称:SignalR,代码行数:11,代码来源:DefaultHubResolverFacts.cs


示例18: start

        public void start()
        {
            var dependencies = new Dictionary<Type, ItemResolver>();
            var resolver = new DefaultDependencyResolver(dependencies);

            DependencyContainer.resolver = () => resolver;

            typeof (DefaultFrontController).Assembly.GetTypes()
                .Where(x => x.has_attribute<RegisterAttribute>())
                .each(type_to_register => dependencies.Add(type_to_register, new AutoWiringResolver(type_to_register, resolver, new GreediestConstructor())));
        }
开发者ID:alexisatkinson,项目名称:nbdn,代码行数:11,代码来源:AppStartup.cs


示例19: GetValidHubsWithInvalidPredicate

        public void GetValidHubsWithInvalidPredicate()
        {
            var resolver = new DefaultDependencyResolver();
            var hubManager = new DefaultHubManager(resolver);
            var hubDescriptors = hubManager.GetHubs(descriptor => descriptor.Name == "CoreTestHub_INVALIDHUB_____");

            // Still have an ienumerable sequence
            Assert.NotNull(hubDescriptors);
            // But there's nothing in the ienumerable
            Assert.Empty(hubDescriptors);
        }
开发者ID:GaneshBachhao,项目名称:SignalR,代码行数:11,代码来源:DefaultHubManagerFacts.cs


示例20: NewSubscriptionGetsAllMessages

        public void NewSubscriptionGetsAllMessages()
        {
            var dr = new DefaultDependencyResolver();
            using (var bus = new TestScaleoutBus(dr))
            {
                var subscriber = new TestSubscriber(new[] { "key" });
                var wh = new ManualResetEventSlim(initialState: false);
                IDisposable subscription = null;

                try
                {
                    var firstMessages = new[] { new Message("test1", "key", "1"),
                                                new Message("test2", "key", "2") };

                    bus.Publish(0, 0, firstMessages);

                    subscription = bus.Subscribe(subscriber, null, (result, state) =>
                    {
                        if (!result.Terminal)
                        {
                            var ms = result.GetMessages().ToList();

                            Assert.Equal(2, ms.Count);
                            Assert.Equal("key", ms[0].Key);
                            Assert.Equal("x", ms[0].GetString());
                            Assert.Equal("key", ms[1].Key);
                            Assert.Equal("y", ms[1].GetString());

                            wh.Set();

                            return TaskAsyncHelper.True;
                        }

                        return TaskAsyncHelper.False;

                    }, 10, null);

                    var messages = new[] { new Message("test1", "key", "x"), 
                                           new Message("test1", "key", "y") 
                                         };
                    bus.Publish(0, 1, messages);

                    Assert.True(wh.Wait(TimeSpan.FromSeconds(10)));
                }
                finally
                {
                    if (subscription != null)
                    {
                        subscription.Dispose();
                    }
                }
            }
        }
开发者ID:GaneshBachhao,项目名称:SignalR,代码行数:53,代码来源:ScaleOutMessageBusFacts.cs



注:本文中的DefaultDependencyResolver类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# DefaultIntellisenseProvider类代码示例发布时间:2022-05-24
下一篇:
C# DecoratedScrolledWindow类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap