/// <summary> /// /// </summary> protected override void Init() { if (FacilityConfig == null) { throw new ConfigurationException( "The MVCFacility requires an 'assembyView' child tag."); } IConfiguration factoriesConfig = FacilityConfig.Children["assembyView"]; if (factoriesConfig != null && factoriesConfig.Value != null && factoriesConfig.Value != string.Empty) { _assembly = Assembly.Load(factoriesConfig.Value); } // Added TypedFactory to have a IState factory TypedFactoryFacility facility = new TypedFactoryFacility(); Kernel.AddFacility("typedfactory", facility); facility.AddTypedFactoryEntry(new FactoryEntry("stateFactory", typeof(IStateFactory), "Create", "Release")); // Added a ControlerTree component to track controller by view Kernel.AddComponent("mvc.controllerTree", typeof(ControllerTree)); Kernel.ComponentModelCreated += new ComponentModelDelegate(OnComponentModelCreated); Initialize(); }
/// <summary> /// Initializes this instance. Must be called, before you can work with the instance. /// </summary> public void Initialize() { Kernel.AddSubSystem(SubSystemConstants.NamingKey, new AutoMockingNamingSubSystem(this)); Kernel.AddFacility("AutoMockingFacility", new AutoMockingFacility(this)); Kernel.ComponentModelBuilder.AddContributor(new NonPublicConstructorDependenciesModelInspector()); Kernel.ComponentModelCreated += Kernel_ComponentModelCreated; }
private void AssertFacility <T>(Func <IFacility> createFacility) where T : IFacility { if (Kernel.GetFacilities().Any(fac => fac.GetType() == typeof(T))) { return; } Kernel.AddFacility(typeof(T).Name, createFacility()); }
public void AssertFacility <T>() where T : IFacility, new() { if (Kernel.GetFacilities().Any(fac => fac.GetType() == typeof(T))) { return; } Kernel.AddFacility <T>(); }
protected override void Init() { Kernel.AddFacility <StartableFacility>(); Kernel.Register( Component.For <IMessageHandler>().ImplementedBy <MessageHandler>().Start(), Component.For <InvocationInterceptor>().LifeStyle.Transient, Component.For <ISerializer>().ImplementedBy <BinarySerializer>(), Component.For <TimeoutManager>(), Component.For <ITransport>().ImplementedBy <MsmqTransport>().OnCreate(initTransport)); }
public void AddComponent_StartableWithInterface_StartsComponent() { Kernel.AddFacility <StartableFacility>() .Register(Component.For <StartableComponent>()); var component = Kernel.Resolve <StartableComponent>(); Assert.IsNotNull(component); Assert.IsTrue(component.Started); Assert.IsFalse(component.Stopped); Kernel.ReleaseComponent(component); Assert.IsTrue(component.Stopped); }
// even though this is O(3n), n ~= 3, so we don't mind it private void AddFacility <T>() where T : IFacility, new() { var facilities = Kernel.GetFacilities(); Contract.Assume(facilities != null, "GetFacilities shouldn't return null"); if (!facilities.Select(x => x.ToString()).Contains(typeof(T).ToString())) { _Logger.InfoFormat("facility '{0}' wasn't found in kernel, adding it, because it's a requirement for NHibernateFacility", typeof(T)); Kernel.AddFacility <T>(); } }
public void Late_bound_factory_properly_applies_lifetime_concerns() { Kernel.AddFacility <FactorySupportFacility>(); Kernel.Register(Component.For(typeof(DisposableComponentFactory)).Named("a")); var componentModel = AddComponent("foo", typeof(IComponent), "Create"); componentModel.LifestyleType = LifestyleType.Transient; var component = Kernel.Resolve <IComponent>("foo") as ComponentWithDispose; Assert.IsNotNull(component); Assert.IsFalse(component.Disposed); Kernel.ReleaseComponent(component); Assert.IsTrue(component.Disposed); }
public void AddComponent_StartableWithoutInterface_StartsComponent_via_expression() { Kernel.AddFacility <StartableFacility>() .Register(Component.For <NoInterfaceStartableComponent>() .StartUsingMethod(x => x.Start) .StopUsingMethod(x => x.Stop) ); var component = Kernel.Resolve <NoInterfaceStartableComponent>(); Assert.IsNotNull(component); Assert.IsTrue(component.Started); Assert.IsFalse(component.Stopped); Kernel.ReleaseComponent(component); Assert.IsTrue(component.Stopped); }
private void AddFacility(IConfiguration config) { String id = config.Attributes["id"]; String type = config.Attributes["type"]; if (type == null || type.Length == 0) { throw new ConfigurationException("The addFacility node must have a 'type' " + " attribute with the Type's name"); } if (id == null || id.Length == 0) { throw new ConfigurationException("The addFacility node must have a 'id' " + " attribute with facility's key"); } Kernel.AddFacility(id, InstatiateFacility(type)); }
protected override void Init() { if (!Kernel.GetFacilities() .Any(z => z.GetType().Equals(typeof(TypedFactoryFacility)))) { Kernel.AddFacility <TypedFactoryFacility>(); } var filter = new AssemblyFilter(AppDomain.CurrentDomain.BaseDirectory, "QuadAuto.Server.*.dll"); Kernel.Register( Classes.FromAssemblyInDirectory(filter).BasedOn <IConsumer>().WithService.Self().WithService. FromInterface( typeof(IConsumer)).Configure(c => c.Properties(PropertyFilter.RequireBase))); Kernel.Register( Classes.FromThisAssembly().BasedOn <IConsumer>().WithService.Self().WithService.FromInterface( typeof(IConsumer)).Configure(c => c.Properties(PropertyFilter.RequireBase))); Kernel.Register(Component.For <IServiceBus>().UsingFactoryMethod(ConfigureServiceBus)); }
protected override void AfterContainerCreated() { facility = new FactorySupportFacility(); Kernel.AddFacility(facility); }
protected override void AfterContainerCreated() { Kernel.AddFacility <FactorySupportFacility>(); }
public MockingContainer(MockRepository mocks) { Kernel.AddFacility("MockingFacility", this); this.mocks = mocks; }