本文整理汇总了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>();
}
示例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;
});
}
示例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)));
}
示例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>();
}
示例6: NhBlogServiceTests
public NhBlogServiceTests()
{
_kernel = new StandardKernel();
_kernel.Load(new NinjectModules());
_kernel.Load(new NhNinjectModule());
_kernel.Rebind<IBlogRepository>().To<NhBlogRepository>();
}
示例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));
}
示例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);
}
示例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();
}
}
示例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);
}
示例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();
}
示例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();
}
示例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)));
}
示例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>();
}
示例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>();
}