public void ShouldThrowExceptionWhenAccessingNonInterfaceKeyedComponentInStrictMode() 
		{
			IComponentAdapter ca = new ConstructorInjectionComponentAdapter("ww", typeof(FooBar));
			ImplementationHidingComponentAdapter ihca = new ImplementationHidingComponentAdapter(ca, true);
			ihca.GetComponentInstance(null);
			Assert.Fail("Oh no.");
		} 
		public void NonInterfaceInArrayCantBeHidden()
		{
			IComponentAdapter ca = new ConstructorInjectionComponentAdapter(new Type[] {typeof (string)}, typeof (FooBar));
			ImplementationHidingComponentAdapter ihca = new ImplementationHidingComponentAdapter(ca, true);
			ihca.GetComponentInstance(null);
			Assert.Fail("Oh no.");
		}
        public void ShouldThrowExceptionWhenAccessingNonInterfaceKeyedComponentInStrictMode()
        {
            IComponentAdapter ca = new ConstructorInjectionComponentAdapter("ww", typeof(FooBar));
            ImplementationHidingComponentAdapter ihca = new ImplementationHidingComponentAdapter(ca, true);

            ihca.GetComponentInstance(null);
            Assert.Fail("Oh no.");
        }
        public void NonInterfaceInArrayCantBeHidden()
        {
            IComponentAdapter ca =
                new ConstructorInjectionComponentAdapter(new Type[] { typeof(string) }, typeof(FooBar));
            ImplementationHidingComponentAdapter ihca = new ImplementationHidingComponentAdapter(ca, true);

            ihca.GetComponentInstance(null);
            Assert.Fail("Oh no.");
        }
		public override IComponentAdapter RegisterComponentImplementation(Object componentKey, Type componentImplementation, IParameter[] parameters)
		{
			if (componentKey is Type)
			{
				Type clazz = (Type) componentKey;
				if (clazz.IsInterface)
				{
					IComponentAdapter caDelegate = caf.CreateComponentAdapter(componentKey, componentImplementation, parameters);
					ImplementationHidingComponentAdapter ihDelegate = new ImplementationHidingComponentAdapter(caDelegate, true);
					return DelegateContainer.RegisterComponent(new CachingComponentAdapter(ihDelegate));
				}
			}
			return DelegateContainer.RegisterComponentImplementation(componentKey, componentImplementation, parameters);
		}
 public override IComponentAdapter RegisterComponentImplementation(Object componentKey,
                                                                   Type componentImplementation,
                                                                   IParameter[] parameters)
 {
     if (componentKey is Type)
     {
         Type clazz = (Type)componentKey;
         if (clazz.IsInterface)
         {
             IComponentAdapter caDelegate =
                 caf.CreateComponentAdapter(componentKey, componentImplementation, parameters);
             ImplementationHidingComponentAdapter ihDelegate =
                 new ImplementationHidingComponentAdapter(caDelegate, true);
             return(DelegateContainer.RegisterComponent(new CachingComponentAdapter(ihDelegate)));
         }
     }
     return(DelegateContainer.RegisterComponentImplementation(componentKey, componentImplementation, parameters));
 }
		public void MultipleInterfacesCanBeHidden()
		{
			Type[] interfaces = new Type[] {typeof (InterfaceOne), typeof (InterfaceTwo)};
			Type implementation = typeof (FooBar);

			IComponentAdapter componentAdapter = new ConstructorInjectionComponentAdapter(
				interfaces,
				implementation);

			ImplementationHidingComponentAdapter ihca = new ImplementationHidingComponentAdapter(componentAdapter, true);
			Object comp = ihca.GetComponentInstance(null);
			Assert.IsNotNull(comp);
			Assert.IsTrue(comp is InterfaceOne);
			Assert.IsTrue(comp is InterfaceTwo);

			// Lets makes sure the actual object is invoked through the proxy
			Assert.IsTrue(((InterfaceOne)comp).MethodOne());
			Assert.IsFalse(((InterfaceTwo)comp).MethodTwo());
		}
        public void MultipleInterfacesCanBeHidden()
        {
            Type[] interfaces     = new Type[] { typeof(InterfaceOne), typeof(InterfaceTwo) };
            Type   implementation = typeof(FooBar);

            IComponentAdapter componentAdapter = new ConstructorInjectionComponentAdapter(
                interfaces,
                implementation);

            ImplementationHidingComponentAdapter ihca = new ImplementationHidingComponentAdapter(componentAdapter, true);
            Object comp = ihca.GetComponentInstance(null);

            Assert.IsNotNull(comp);
            Assert.IsTrue(comp is InterfaceOne);
            Assert.IsTrue(comp is InterfaceTwo);

            // Lets makes sure the actual object is invoked through the proxy
            Assert.IsTrue(((InterfaceOne)comp).MethodOne());
            Assert.IsFalse(((InterfaceTwo)comp).MethodTwo());
        }