Esempio n. 1
0
        /*============================================================================*/
        /* Public Functions                                                           */
        /*============================================================================*/

        public void AddContainer(object container)
        {
            if (!ValidContainer(container))
            {
                return;
            }

            _containers.Add(container);

            ContainerBinding containerBinding = _registry.AddContainer(container);

            AddHandlers(containerBinding);

            if (_containerAdded != null)
            {
                _containerAdded(container);
            }
        }
		public void Context_Inherits_Parent_Injector()
		{
			AddRootToStage();

			parentContext
				.Install (typeof(SupportParentFinderExtension))
				.Install(typeof(TestSupportViewStateWatcherExtension))
				.Install (typeof(ModularityExtension))
				.Configure(new ContextView(parentView));

			childContext
				.Install (typeof(ModularityExtension))
				.Install (typeof(SupportParentFinderExtension))
				.Install (typeof(TestSupportViewStateWatcherExtension))
				.Configure (new ContextView (childView));

			ContainerRegistry cr = new ContainerRegistry();
			cr.SetParentFinder (new SupportParentFinder ());

			parentContext.injector.Map(typeof(ContainerRegistry)).ToValue(cr);
			childContext.injector.Map(typeof(ContainerRegistry)).ToValue(cr);

			cr.AddContainer(parentView);
			cr.AddContainer(childView);

			root.AddChild(parentView);
			parentView.AddChild (childView);

			Assert.That (childContext.injector.parent, Is.EqualTo (parentContext.injector));
		}
		public void Multiple_Depths_Of_Children_Only_Inherit_The_First_Parents_Injector()
		{
			AddRootToStage();

			parentContext
				.Install (typeof(SupportParentFinderExtension))
				.Install(typeof(TestSupportViewStateWatcherExtension))
				.Install (typeof(ModularityExtension))
				.Configure(new ContextView(parentView));

			childContext
				.Install (typeof(ModularityExtension))
				.Install (typeof(SupportParentFinderExtension))
				.Install (typeof(TestSupportViewStateWatcherExtension))
				.Configure (new ContextView (childView));


			SupportView anotherChildView = new SupportView ();
			IContext anotherChildContext = new Context()
				.Install (typeof(StageSyncExtension))
				.Install (typeof(ContextViewExtension))
				.Install (typeof(ModularityExtension))
				.Install (typeof(SupportParentFinderExtension))
				.Install (typeof(TestSupportViewStateWatcherExtension))
				.Configure (new ContextView (anotherChildView));


			ContainerRegistry cr = new ContainerRegistry();
			parentContext.injector.Map(typeof(ContainerRegistry)).ToValue(cr);
			childContext.injector.Map(typeof(ContainerRegistry)).ToValue(cr);
			anotherChildContext.injector.Map(typeof(ContainerRegistry)).ToValue(cr);

			cr.AddContainer(parentView);
			cr.AddContainer(childView);
			cr.AddContainer(anotherChildView);

			root.AddChild (parentView);
			parentView.AddChild (childView);
			childView.AddChild (anotherChildView);

			Assert.That (childContext.injector.parent, Is.EqualTo (parentContext.injector));
			Assert.That (anotherChildContext.injector.parent, Is.EqualTo (childContext.injector));
			Assert.That (anotherChildContext.injector.parent, Is.Not.EqualTo (parentContext.injector));
		}
 public void addContainer()
 {
     registry.AddContainer(container);
 }