当前位置: 首页>>代码示例>>C#>>正文


C# StandardKernel类代码示例

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


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

示例1: TransientBindingsWork

        public void TransientBindingsWork()
        {
            var kernel = new StandardKernel();

            kernel.Get(
                typeof (IInput),
                null,
                null,
                null,
                null,
                null,
                new Dictionary<Type, List<IMapping>>
                {
                    {
                        typeof (IInput), new List<IMapping>
                        {
                            new DefaultMapping(
                                typeof(DefaultInput),
                                null,
                                false,
                                null,
                                null,
                                false,
                                false,
                                null)
                        }
                    }
                });
        }
开发者ID:hach-que,项目名称:Protoinject,代码行数:29,代码来源:TransientBindingsTests.cs

示例2: IsNotOverlappingWhenNoBoundingBoxes

 public void IsNotOverlappingWhenNoBoundingBoxes()
 {
     var kernel = new StandardKernel();
     kernel.Load<ProtogameCoreModule>();
     var boundingBoxUtilities = kernel.Get<IBoundingBoxUtilities>();
     _assert.False(boundingBoxUtilities.Overlaps());
 }
开发者ID:RedpointGames,项目名称:Protogame,代码行数:7,代码来源:BoundingBoxTests.cs

示例3: IsNotOverlappingWhenOneBoundingBox

 public void IsNotOverlappingWhenOneBoundingBox()
 {
     var kernel = new StandardKernel();
     kernel.Load<ProtogameCoreModule>();
     var boundingBoxUtilities = kernel.Get<IBoundingBoxUtilities>();
     _assert.False(boundingBoxUtilities.Overlaps(this.CreateBoundingBox(200, 200, 16, 16)));
 }
开发者ID:RedpointGames,项目名称:Protogame,代码行数:7,代码来源:BoundingBoxTests.cs

示例4: Run

 public void Run(IConfiguration configuration, IWebEnvironment environment)
 {
     var module = CreateModules().ToArray();
     if (module.Length == 0) return;
     var kernel = new StandardKernel(module);
     configuration.Container = new NinjectContainer(kernel);
 }
开发者ID:muratbeyaztas,项目名称:Simple.Web,代码行数:7,代码来源:NinjectStartupBase.cs

示例5: FactoryTests

        public FactoryTests()
        {
            this.kernel = new StandardKernel();
#if NO_ASSEMBLY_SCANNING
            this.kernel.Load(new FuncModule());
#endif        
        }
开发者ID:hach-que,项目名称:Ninject.Extensions.Factory,代码行数:7,代码来源:FactoryTests.cs

示例6: ReplaceMapper

 public void ReplaceMapper() {
     var c = new StandardKernel();
     var mapper = new global::SolrNet.Tests.Mocks.MReadOnlyMappingManager();
     c.Load(new SolrNetModule("http://localhost:8983/solr") {Mapper = mapper});
     var m = c.Get<IReadOnlyMappingManager>();
     Assert.AreSame(mapper, m);
 }
开发者ID:FilipVV,项目名称:SolrNet,代码行数:7,代码来源:NinjectFixture.cs

示例7: Container

 static Container()
 {
     if (Kernel == null)
     {
         Kernel = new StandardKernel(new ClientModule());
     }
 }
开发者ID:joakes,项目名称:Hello-Agatha,代码行数:7,代码来源:ClientModule.cs

示例8: GetBindingInformations

        public List<FeatureInfo> GetBindingInformations(INinjectModule module)
        {
            List<FeatureInfo> bindingsFeatureInfoList = new List<FeatureInfo>();

            IKernel kernel = new StandardKernel();
            module.OnLoad(kernel);

            List<KeyValuePair<Type, ICollection<IBinding>>> typeBindingInfo = GetBindings(kernel, module.Name);

            foreach (KeyValuePair<Type, ICollection<IBinding>> typeBinding in typeBindingInfo)
            {
                FeatureInfo bindingInterface = new FeatureInfo(typeBinding.Key, null, null, FeatureType.BindingInterface);

                foreach (IBinding binding in typeBinding.Value)
                {
                    ContextMock contextMock = new ContextMock(kernel);

                    IProvider provider = binding.ProviderCallback(contextMock);

                    FeatureInfo bindingInterfaceImpl = new FeatureInfo(provider.Type, null, null, FeatureType.BindingImpl);
                    bindingInterfaceImpl.SetBindingType(binding.Target);

                    bindingInterface.AddDependency(bindingInterfaceImpl);
                }

                bindingsFeatureInfoList.Add(bindingInterface);
            }

            return bindingsFeatureInfoList;
        }
开发者ID:DominikLindemann,项目名称:ninject.features,代码行数:30,代码来源:BindingReader.cs

示例9: FactoryProviderContext

        public FactoryProviderContext()
        {
            contextMock = new Mock<IContext>();
            kernel = new StandardKernel();

            contextMock.SetupGet(c => c.Kernel).Returns(kernel);
        }
开发者ID:fschwiet,项目名称:ninject,代码行数:7,代码来源:FactoryProviderTests.cs

示例10: InstanceIsDeactivatedWhenItLeavesScope

        public void InstanceIsDeactivatedWhenItLeavesScope()
        {
            Barracks barracks;
            using ( var kernel = new StandardKernel() )
            {
                kernel.Bind<Barracks>()
                    .ToSelf()
                    .InSingletonScope()
                    .OnActivation(instance =>
                                    {
                                        instance.Warrior = new FootSoldier();
                                        instance.Weapon = new Shuriken();
                                    })
                    .OnDeactivation(instance =>
                                    {
                                        instance.Warrior = null;
                                        instance.Weapon = null;
                                    });

                barracks = kernel.Get<Barracks>();
                barracks.Warrior.ShouldNotBeNull();
                barracks.Warrior.ShouldBeInstanceOf<FootSoldier>();
                barracks.Weapon.ShouldNotBeNull();
                barracks.Weapon.ShouldBeInstanceOf<Shuriken>();
            }
            barracks.Warrior.ShouldBeNull();
            barracks.Weapon.ShouldBeNull();
        }
开发者ID:Haacked,项目名称:ninject,代码行数:28,代码来源:ActivationStrategyTests.cs

示例11: ManyPublishersManySubscribers

        public void ManyPublishersManySubscribers()
        {
            using ( var kernel = new StandardKernel() )
            {
                var pub1 = kernel.Get<PublisherMock>();
                var pub2 = kernel.Get<PublisherMock>();
                Assert.NotNull( pub1 );
                Assert.NotNull( pub2 );

                var sub1 = kernel.Get<SubscriberMock>();
                var sub2 = kernel.Get<SubscriberMock>();
                Assert.NotNull( sub1 );
                Assert.NotNull( sub2 );

                Assert.True( pub1.HasListeners );
                Assert.True( pub2.HasListeners );
                Assert.Null( sub1.LastMessage );
                Assert.Null( sub2.LastMessage );

                pub1.SendMessage( "Hello, world!" );
                Assert.Equal( sub1.LastMessage, "Hello, world!" );
                Assert.Equal( sub2.LastMessage, "Hello, world!" );

                sub1.LastMessage = null;
                sub2.LastMessage = null;
                Assert.Null( sub1.LastMessage );
                Assert.Null( sub2.LastMessage );

                pub2.SendMessage( "Hello, world!" );
                Assert.Equal( sub1.LastMessage, "Hello, world!" );
                Assert.Equal( sub2.LastMessage, "Hello, world!" );
            }
        }
开发者ID:larsw,项目名称:ninject.extensions.weakeventmessagebroker,代码行数:33,代码来源:MessageBrokerFixture.cs

示例12: Ping_And_Query

 public void Ping_And_Query()
 {
     var c = new StandardKernel();
     c.Load(new SolrNetModule("http://localhost:8983/solr"));
     var solr = c.Get<ISolrOperations<Entity>>();
     solr.Ping();
     Console.WriteLine(solr.Query(SolrQuery.All).Count);
 }
开发者ID:Cort01,项目名称:SolrNet,代码行数:8,代码来源:Tests.cs

示例13: IsNotOverlappingWhenSameBoundingBoxAndNoOtherBoxes

 public void IsNotOverlappingWhenSameBoundingBoxAndNoOtherBoxes()
 {
     var kernel = new StandardKernel();
     kernel.Load<ProtogameCoreModule>();
     var boundingBoxUtilities = kernel.Get<IBoundingBoxUtilities>();
     var entity = this.CreateBoundingBox(200, 200, 16, 16);
     _assert.False(boundingBoxUtilities.Overlaps(entity, entity));
 }
开发者ID:RedpointGames,项目名称:Protogame,代码行数:8,代码来源:BoundingBoxTests.cs

示例14: NinjectTraceLogger

        /// <summary>
        /// Initializes a new instance of the <see cref="NinjectTraceLogger" /> class.
        /// </summary>
        public NinjectTraceLogger()
        {
            var kernel = new StandardKernel();

            this.logger = kernel.Get<ILoggerFactory>().GetCurrentClassLogger();

            this.beginTraces = new List<TraceRecord>();
        }
开发者ID:azzlack,项目名称:Ninject.Extensions.WebApi.TraceLogger,代码行数:11,代码来源:NinjectTraceLogger.cs

示例15: UsageHandler

        /// <summary>
        /// Initializes a new instance of the <see cref="UsageHandler" /> class.
        /// </summary>
        public UsageHandler()
        {
            var kernel = new StandardKernel();

            var logfactory = kernel.Get<ILoggerFactory>();

            this.Log = logfactory.GetCurrentClassLogger();
        }
开发者ID:azzlack,项目名称:Ninject.Extensions.WebApi.UsageLogger,代码行数:11,代码来源:UsageHandler.cs


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