protected IPicoContainer BuildContainer(ScriptedContainerBuilder builder, IPicoContainer parentContainer, IList assemblies)
		{
			SimpleReference sr = new SimpleReference();
			SimpleReference pr = new SimpleReference();
			pr.Set(parentContainer);
			builder.BuildContainer(sr, pr, assemblies);
			return (IPicoContainer) sr.Get();
		}
		public IMutablePicoContainer Build(IMutablePicoContainer parent, IList assemblies)
		{
			SimpleReference simpleReference = new SimpleReference();
			SimpleReference parentReference = new SimpleReference();
			parentReference.Set(parent);

			containerBuilder.BuildContainer(simpleReference, parentReference, assemblies);
			return simpleReference.Get() as IMutablePicoContainer;
		}
		public void KillContainer()
		{
			Mock mockPicoContainer = new DynamicMock(typeof(IMutablePicoContainer));
			IMutablePicoContainer picoContainer = mockPicoContainer.MockInstance as IMutablePicoContainer;
			mockPicoContainer.Expect("Stop");
			mockPicoContainer.Expect("Dispose");
			mockPicoContainer.ExpectAndReturn("Parent", new DefaultPicoContainer(picoContainer));
			mockPicoContainer.Strict = true;

			LifeCycleContainerBuilder lifeCycleContainerBuilder = new StubLifeCycleContainerBuilder();
			SimpleReference reference = new SimpleReference();
			reference.Set(mockPicoContainer.MockInstance);

			lifeCycleContainerBuilder.KillContainer(reference);
			mockPicoContainer.Verify();
		}
Beispiel #4
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="theDelegate">The component adapter to decorate</param>
 /// <param name="reference">Object to store the instance in. See <see cref="IObjectReference"/> for an explanation.</param>
 public CachingComponentAdapter(IComponentAdapter theDelegate, SimpleReference reference) : base(theDelegate)
 {
     instanceReference = reference;
 }
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="theDelegate">The component adapter to decorate</param>
		/// <param name="reference">Object to store the instance in. See <see cref="IObjectReference"/> for an explanation.</param>
		public CachingComponentAdapter(IComponentAdapter theDelegate, SimpleReference reference) : base(theDelegate)
		{
			instanceReference = reference;
		}
 public void RES_failingVerificationWithCyclicDependencyException()
 {
     if ((GetComponentAdapterNature() & RESOLVING) > 0)
     {
         Hashtable cycleInstances = new Hashtable();
         IObjectReference cycleCheck = new SimpleReference();
         object[] wrapperDependencies = new Object[] {cycleInstances, cycleCheck};
         IMutablePicoContainer picoContainer = new DefaultPicoContainer(CreateDefaultComponentAdapterFactory());
         IComponentAdapter componentAdapter =
             prepRES_failingVerificationWithCyclicDependencyException(picoContainer);
         Assert.AreSame(GetComponentAdapterType(), componentAdapter.GetType());
         Assert.IsTrue(picoContainer.ComponentAdapters.Contains(componentAdapter));
         IPicoContainer wrappedPicoContainer =
             WrapComponentInstances(typeof (CycleDetectorComponentAdapter), picoContainer, wrapperDependencies);
         try
         {
             componentAdapter.Verify(wrappedPicoContainer);
             Assert.Fail("Thrown PicoVerificationException excpected");
         }
         catch (CyclicDependencyException cycle)
         {
             object[] dependencies = cycle.Dependencies;
             Assert.AreSame(dependencies[0], dependencies[dependencies.Length - 1]);
         }
     }
 }