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


C# IKernel.Rebind方法代码示例

本文整理汇总了C#中IKernel.Rebind方法的典型用法代码示例。如果您正苦于以下问题:C# IKernel.Rebind方法的具体用法?C# IKernel.Rebind怎么用?C# IKernel.Rebind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IKernel的用法示例。


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

示例1: RegisterComponents

        public void RegisterComponents(IKernel container) {
            container.Rebind<IEventManager>().ToConstant(eventManager);
            container.Rebind<ILogger>().ToConstant(logger);

            container.Bind<QcConfiguration>().ToConstant(configuration);
            container.Bind<StartupChecker>().To<StartupChecker>();

            startupChecker = container.Get<StartupChecker>();
        }
开发者ID:versionone,项目名称:VersionOne.Integration.HPALM,代码行数:9,代码来源:QualityCenterHostedService.cs

示例2: RegisterServices

        protected override void RegisterServices(IKernel kernel)
        {
            kernel.Rebind<CartModel>().ToMethod(context => context.Kernel.Get<ICartBuilder>().BuildCart()).InRequestScope();
            kernel.Rebind<SECVPN>().ToMethod(context =>
            {
                var service = new SECVPNClient(new BasicHttpBinding(BasicHttpSecurityMode.Transport),
                    new EndpointAddress("https://www.secpay.com/java-bin/services/SECCardService"));

                return service;
            });
        }
开发者ID:neozhu,项目名称:Ecommerce,代码行数:11,代码来源:EcommerceApp.cs

示例3: RegisterComponents

        public void RegisterComponents(IKernel container) {
            container.Rebind<IEventManager>().ToConstant(eventManager);
            container.Bind<IVersionOneProcessor>().ToConstant(v1Processor);
            container.Rebind<ILogger>().To<Logger>();
            container.Bind<WorkitemWriterServiceConfiguration>().ToConstant(configuration);
            container.Bind<IWorkitemWriter>().To<WorkitemWriter>();
            container.Bind<IWorkitemReader>().To<WorkitemReader>();

            workitemWriter = container.Get<IWorkitemWriter>();
            workitemReader = container.Get<IWorkitemReader>();
            externalWorkitemQuerier = container.Get<ClosedExternalWorkitemQuerier>();
            startupChecker = container.Get<StartupChecker>();
        }
开发者ID:versionone,项目名称:VersionOne.ServiceHost.WorkitemServices,代码行数:13,代码来源:WorkitemWriterHostedService.cs

示例4: OnLoad

        public void OnLoad(IKernel kernel)
        {
            kernel.Bind(x => x.FromThisAssembly().SelectAllClasses().BindAllInterfaces());
            kernel.Bind(x => x.FromAssemblyContaining<SonosPlayer>().SelectAllClasses().BindAllInterfaces());
            kernel.Bind(x => x.FromAssemblyContaining<IFileSystem>().SelectAllClasses().BindAllInterfaces());

            kernel.Rebind<ServerConfiguration>().ToMethod(x => ServerConfigurationFactory.LoadConfiguration()).InSingletonScope();
            kernel.Rebind<IIdentityProvider>().To<IdentityProvider>().InSingletonScope();
            kernel.Rebind<ISearchProvider>().To<TopLevelDirectorySearchProvider>().InSingletonScope(); 
            kernel.Rebind<SmapiSoapControllerDependencies>().To<SmapiSoapControllerDependencies>().InSingletonScope();

            SmapiSoapController.Dependencies = () => kernel.Get<SmapiSoapControllerDependencies>();

            kernel.Bind<LocalMusicServerFactory>().ToMethod(context => new LocalMusicServerFactory(typeof(SmapiSoapController)));
        }
开发者ID:Ulriksen,项目名称:OpenSonos,代码行数:15,代码来源:Bindings.cs

示例5: RegisterServices

 /// <summary>
 /// Load your modules or register your services here!
 /// </summary>
 /// <param name="kernel">The kernel.</param>
 private static void RegisterServices(IKernel kernel)
 {
     //kernel.Bind<Cart.Common.ICartInterceptor>().To<GreedyInterceptor>();
     //Note: This isn't a good way to obtain the Cart Service implementation type. This is Ninject limitation.
     var cartService = kernel.Get<Cart.Service.Common.ICartService>();
     kernel.Rebind<Cart.Service.Common.ICartService>().To(cartService.GetType()).Intercept().With<GreedyInterceptor>();
 }
开发者ID:sokac237,项目名称:DIPracticeLayeredArchitecture,代码行数:11,代码来源:NinjectWebCommon.cs

示例6: NhBlogServiceTests

 public NhBlogServiceTests()
 {
     _kernel = new StandardKernel();
     _kernel.Load(new NinjectModules());
     _kernel.Load(new NhNinjectModule());
     _kernel.Rebind<IBlogRepository>().To<NhBlogRepository>();
 }
开发者ID:ThomasSchmidt,项目名称:MixedStuff,代码行数:7,代码来源:NhBlogServiceTests.cs

示例7: Process

        public void Process(Type type, Func<IContext, object> scopeCallback, IKernel kernel)
        {
            if (NoBindingsIn(kernel))
            {
                kernel.Rebind(_service).To(type).InScope(scopeCallback).WithMetadata("assembly", Assembly(type));
                return;
            }

            if (DefaultBindingIn(kernel) && Assembly(type) != _serviceAssembly)
            {
                kernel.Rebind(_service).To(type).InScope(scopeCallback).WithMetadata("assembly", Assembly(type));
                return;
            }

            kernel.Bind(_service).To(type).InScope(scopeCallback).WithMetadata("assembly", Assembly(type));
        }
开发者ID:afifmohammed,项目名称:efsession,代码行数:16,代码来源:OverridableBindingGenerator.cs

示例8: SetUp

        public void SetUp()
        {
            _view = MockRepository.GenerateMock<ICradiatorView>();
            _configSettings = MockRepository.GenerateMock<IConfigSettings>();
            _configSettings.Expect(c => c.ProjectNameRegEx).Return(".*").Repeat.Any();
            _configSettings.Expect(c => c.CategoryRegEx).Return(".*").Repeat.Any();

            _skinLoader = MockRepository.GenerateMock<ISkinLoader>();
            _screenUpdater = MockRepository.GenerateMock<IScreenUpdater>();
            _configFileWatcher = MockRepository.GenerateMock<IConfigFileWatcher>();

            var bootstrapper = new Bootstrapper(_configSettings, _view);
            _kernel = bootstrapper.CreateKernel();
            _kernel.Rebind<ISkinLoader>().ToConstant(_skinLoader);
            _kernel.Rebind<IScreenUpdater>().ToConstant(_screenUpdater);
            _kernel.Rebind<IConfigFileWatcher>().ToConstant(_configFileWatcher);
        }
开发者ID:xerxesb,项目名称:cradiator,代码行数:17,代码来源:Presenter_Tests.cs

示例9: SetupBindings

 public override void SetupBindings(IKernel kernel, Func<string, Type> lookupType, Func<IContext, object> currentGameScope)
 {
     if (!string.IsNullOrEmpty(this.MovementControllerImplementation))
     {
         kernel.Rebind<IMovementController>()
             .To(lookupType(this.MovementControllerImplementation))
             .InTransientScope();
     }
 }
开发者ID:RedpointGames,项目名称:Unity-DI,代码行数:9,代码来源:SceneConfiguration.cs

示例10: RegisterServices

        /// <summary>
        /// Load your modules or register your services here!
        /// </summary>
        /// <param name="kernel">The kernel.</param>
        private static void RegisterServices(IKernel kernel)
        {
            var namespaces = new string[] {
                "HappyPath.*"
            };

            kernel.Bind(x => x
                .FromAssembliesMatching(namespaces)
                .SelectAllClasses()
                .BindAllInterfaces()
            );

            kernel.Rebind<IMappingEngine>().ToMethod(x => Mapper.Engine);

            kernel.Rebind<IHappyPathSession>().To<HappyPathSession>()
                .InRequestScope();

            AutoMapperConfiguration.Configure(kernel);
        }
开发者ID:kindohm,项目名称:HappyPath,代码行数:23,代码来源:NinjectWebCommon.cs

示例11: FlowForm

        public FlowForm(
            IKernel kernel,
            IFormFactory formFactory,
            IStorageAccess storageAccess,
            Lazy<FlowProcessingPipeline> flowProcessingPipeline)
        {
            // TODO: Expose this in the UI.
            this.Seed = 0xDEADBEEF;

            this.InitializeComponent();
            kernel.Rebind<IRenderingLocationProvider>().ToMethod(context => this);
            kernel.Rebind<ICurrentWorldSeedProvider>().ToMethod(context => this);
            this.m_FlowProcessingPipeline = flowProcessingPipeline.Value;
            this.m_FormFactory = formFactory;
            this.m_StorageAccess = storageAccess;
            if (this.m_FlowProcessingPipeline == null)
                throw new Exception("IFlowProcessingPipeline is not of type FlowProcessingPipeline.");
            this.m_FlowProcessingPipeline.FormConnect(this);
            this.CreateAnalysisActions();
            this.UpdateStatusArea();
        }
开发者ID:TreeSeed,项目名称:Tychaia,代码行数:21,代码来源:FlowForm.cs

示例12: RegisterServices

        /// <summary>
        /// Load your modules or register your services here!
        /// </summary>
        /// <param name="kernel">The kernel.</param>
        private static void RegisterServices(IKernel kernel)
        {
            kernel.Bind(x =>
                x.FromAssemblyContaining(
                    typeof(IEventLogController),
                    typeof(ITriageDbContext),
                    typeof(NinjectWebCommon))
                    .SelectAllClasses()
                    .BindDefaultInterfaces()
                );

            kernel.Rebind<ITriageDbContextFactory>().To<TriageDbContextFactory>().InSingletonScope();
        }        
开发者ID:Kewlo,项目名称:Triage.Net,代码行数:17,代码来源:NinjectWebCommon.cs

示例13: ConfigureApplicationContainer

        protected override void ConfigureApplicationContainer(IKernel existingContainer)
        {
            ContainerBootstrapper
                .Bootstrap(existingContainer)
                .Analyze(x => x.AssembiesContaining(new[]
                                                        {
                                                            typeof(CoreAssemblyMarker),
                                                            typeof(DroneAssemblyMarker),
                                                            typeof(IRestClient),
                                                            typeof(IDocumentStore)
                                                        }))
                .BindInterfaceToDefaultImplementation()
                .Configure(x => x.InTransientScope())
                .NoDatabase()
                .Settings(x => x.UseJsonFiles())
                .Done();

            existingContainer.Rebind<IScheduler>().ToConstant(_scheduler);

            var settings =typeof(CoreAssemblyMarker).Assembly.GetExportedTypes().Where(type => type.Name.EndsWith("Settings")).ToList();

            settings.ForEach(x=> existingContainer.Rebind(x).ToConstant(_kernel.Get(x)));
        }
开发者ID:mamluka,项目名称:SpeedyMailer,代码行数:23,代码来源:NinjectBootstrapperForTesting.cs

示例14: Init

        public void Init()
        {
            fixture = new Fixture().Customize(new AutoMoqCustomization());
            ninject = new StandardKernel(new BindingsModule());

            mockChanceDeck = fixture.Create<Mock<Deck>>();
            mockChestDeck = fixture.Create<Mock<Deck>>();

            mockDeckFactory = fixture.Create<Mock<DeckFactory>>();
            mockDeckFactory.Setup(x => x.BuildChanceDeck()).Returns(mockChanceDeck.Object);
            mockDeckFactory.Setup(x => x.BuildCommunitiyChestDeck()).Returns(mockChestDeck.Object);

            ninject.Rebind<IDeckFactory>().ToConstant(mockDeckFactory.Object).InSingletonScope();

            cardHandler = ninject.Get<CardHandler>();
        }
开发者ID:jonsavage,项目名称:Monopoly-Kata,代码行数:16,代码来源:CardHandlerUnitTests.cs

示例15: Init

        public void Init()
        {
            fixture = new Fixture().Customize(new AutoMoqCustomization());

            mockDice = fixture.Create<Mock<Dice>>();

            ninject = new StandardKernel(new BindingsModule());

            ninject.Rebind<IDice>().ToConstant(mockDice.Object);

            turnHandler = ninject.Get<TurnHandler>();
            player1 = ninject.Get<IPlayer>();
            player2 = ninject.Get<IPlayer>();
            realtor = ninject.Get<IRealtor>();
            jailer = ninject.Get<IJailer>();
        }
开发者ID:jonsavage,项目名称:Monopoly-Kata,代码行数:16,代码来源:TurnHandlerIntegrationTests.cs


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