From 15c6aa539c57a0de4aeadefb72d99b6c3bb031ff Mon Sep 17 00:00:00 2001 From: cneuwirt Date: Sat, 1 Mar 2008 18:28:28 +0000 Subject: [PATCH] Fixed some formatting issues. git-svn-id: https://svn.castleproject.org/svn/castle/trunk@4864 73e77b4c-caa6-f847-a29a-24ab75ae54b6 --- .../Registration/AllTypesOfTestCase.cs | 16 ++++++++-------- .../Registration/ComponentRegistration.cs | 9 ++++++++- .../Registration/Strategies/AllTypesOf.cs | 8 ++++---- .../Registration/Strategies/TypesDescriptor.cs | 2 +- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/InversionOfControl/Castle.MicroKernel.Tests/Registration/AllTypesOfTestCase.cs b/InversionOfControl/Castle.MicroKernel.Tests/Registration/AllTypesOfTestCase.cs index c06806065..b26ad89c6 100644 --- a/InversionOfControl/Castle.MicroKernel.Tests/Registration/AllTypesOfTestCase.cs +++ b/InversionOfControl/Castle.MicroKernel.Tests/Registration/AllTypesOfTestCase.cs @@ -139,7 +139,7 @@ namespace Castle.MicroKernel.Tests.Registration .Pick(from type in Assembly.GetExecutingAssembly().GetExportedTypes() where type.IsDefined(typeof(SerializableAttribute), true) select type - )); + )); IHandler[] handlers = kernel.GetAssignableHandlers(typeof(CustomerChain1)); Assert.AreEqual(2, handlers.Length); @@ -148,17 +148,17 @@ namespace Castle.MicroKernel.Tests.Registration [Test] public void RegisterAssemblyTypes_WithKLinqConfiguration_RegisteredInContainer() { - kernel.Register( AllTypesOf - .FromAssembly( Assembly.GetExecutingAssembly() ) - .Configure( component => component.LifeStyle.Transient - .Named( component.Implementation.FullName + "XYZ" ) + kernel.Register(AllTypesOf + .FromAssembly(Assembly.GetExecutingAssembly()) + .Configure(component => component.LifeStyle.Transient + .Named(component.Implementation.FullName + "XYZ") ) ); - foreach ( IHandler handler in kernel.GetAssignableHandlers( typeof( ICommon ) ) ) + foreach (IHandler handler in kernel.GetAssignableHandlers(typeof(ICommon))) { - Assert.AreEqual( LifestyleType.Transient, handler.ComponentModel.LifestyleType ); - Assert.AreEqual( handler.ComponentModel.Implementation.FullName + "XYZ", handler.ComponentModel.Name ); + Assert.AreEqual(LifestyleType.Transient, handler.ComponentModel.LifestyleType); + Assert.AreEqual(handler.ComponentModel.Implementation.FullName + "XYZ", handler.ComponentModel.Name); } } diff --git a/InversionOfControl/Castle.MicroKernel/Registration/ComponentRegistration.cs b/InversionOfControl/Castle.MicroKernel/Registration/ComponentRegistration.cs index 4af6b3d5b..df9fd31da 100644 --- a/InversionOfControl/Castle.MicroKernel/Registration/ComponentRegistration.cs +++ b/InversionOfControl/Castle.MicroKernel/Registration/ComponentRegistration.cs @@ -386,12 +386,19 @@ namespace Castle.MicroKernel.Registration } public ComponentRegistration(Type serviceType) - : base( serviceType ) + : base(serviceType) { } public ComponentRegistration For(Type serviceType) { + if (ServiceType != null) + { + String message = String.Format("This component has " + + "already been assigned service type {0}", ServiceType.FullName); + throw new ComponentRegistrationException(message); + } + ServiceType = serviceType; return this; } diff --git a/InversionOfControl/Castle.MicroKernel/Registration/Strategies/AllTypesOf.cs b/InversionOfControl/Castle.MicroKernel/Registration/Strategies/AllTypesOf.cs index 8a06e65a6..a157472d6 100644 --- a/InversionOfControl/Castle.MicroKernel/Registration/Strategies/AllTypesOf.cs +++ b/InversionOfControl/Castle.MicroKernel/Registration/Strategies/AllTypesOf.cs @@ -83,9 +83,9 @@ namespace Castle.MicroKernel.Registration /// /// The list of types. /// The corresponding - public static TypesDescriptor Pick( IEnumerable types ) + public static TypesDescriptor Pick(IEnumerable types) { - return new TypesDescriptor( types ); + return new TypesDescriptor(types); } /// @@ -93,9 +93,9 @@ namespace Castle.MicroKernel.Registration /// /// The list of types. /// The corresponding - public static TypesDescriptor From( params Type[] types ) + public static TypesDescriptor From(params Type[] types) { - return new TypesDescriptor( types ); + return new TypesDescriptor(types); } } } diff --git a/InversionOfControl/Castle.MicroKernel/Registration/Strategies/TypesDescriptor.cs b/InversionOfControl/Castle.MicroKernel/Registration/Strategies/TypesDescriptor.cs index 2146e1306..39cb285d8 100644 --- a/InversionOfControl/Castle.MicroKernel/Registration/Strategies/TypesDescriptor.cs +++ b/InversionOfControl/Castle.MicroKernel/Registration/Strategies/TypesDescriptor.cs @@ -94,7 +94,7 @@ namespace Castle.MicroKernel.Registration ComponentRegistration registration = Component.For(serviceType); registration.ImplementedBy(type); - if ( configurer != null ) + if (configurer != null) { configurer(registration); } -- 2.11.4.GIT