public void AddComponentInstance()
        {
            CustomerImpl customer = new CustomerImpl();

            kernel.AddComponentInstance("key", typeof(ICustomer), customer);
            Assert.IsTrue(kernel.HasComponent("key"));

            CustomerImpl customer2 = kernel["key"] as CustomerImpl;

            Assert.AreSame(customer, customer2);

            customer2 = kernel[typeof(ICustomer)] as CustomerImpl;
            Assert.AreSame(customer, customer2);
        }
Example #2
0
 public void RegisterInstance(Type type, object instance)
 {
     if (!kernel.HasComponent(type.ToString()))
     {
         kernel.AddComponentInstance(type.ToString(), type, instance);
     }
 }
		private static void RegisterWindowsFormsSynchronizationContext(IKernel kernel)
		{
			WindowsFormsSynchronizationContext winFormsSyncCtx =
				WindowsFormsSynchronizationContext.Current as WindowsFormsSynchronizationContext;

			if (winFormsSyncCtx != null)
			{
				kernel.AddComponentInstance(Constants.WinFormsSyncContext, winFormsSyncCtx);
			}
		}
 private void RegisterServices(IKernel kernel)
 {
     kernel.AddComponentInstance<IApplicationShell>(this);
     kernel.AddComponentInstance<DockPanel>(dockPanel1);
     kernel.AddComponentInstance(CoreModule.MainMenuToolStripKey, topMenu);
 }
Example #5
0
 private void RegisterServices(IKernel kernel)
 {
     kernel.AddComponentInstance <IApplicationShell>(this);
     kernel.AddComponentInstance <DockPanel>(dockPanel1);
     kernel.AddComponentInstance(CoreModule.MainMenuToolStripKey, topMenu);
 }
 public ServiceLocatorStub AddInstance <TService>(TService instance)
 {
     kernel.AddComponentInstance(typeof(TService).Name, typeof(TService), instance);
     return(this);
 }