User: cneuwirt
Date: 2008/09/08 01:18 PM

Modified:
 /trunk/InversionOfControl/
  Changes.txt
 /trunk/InversionOfControl/Castle.MicroKernel.Tests/Registration/
  AllTypesTestCase.cs
 /trunk/InversionOfControl/Castle.MicroKernel/Registration/Strategies/
  BasedOnDescriptor.cs, FromDescriptor.cs

Log:
 Added ability to specify a general purpose where condition for AllTypes

File Changes:

Directory: /trunk/InversionOfControl/
=====================================

File [modified]: Changes.txt
Delta lines: +0 -0
===================================================================

Directory: /trunk/InversionOfControl/Castle.MicroKernel.Tests/Registration/
===========================================================================

File [modified]: AllTypesTestCase.cs
Delta lines: +2 -0
===================================================================

--- trunk/InversionOfControl/Changes.txt        2008-09-08 20:06:53 UTC (rev 
5309)
+++ trunk/InversionOfControl/Changes.txt        2008-09-08 20:18:56 UTC (rev 
5310)
@@ -1,6 +1,8 @@
 RC 4
 ====
 
+- Added shortcut to AllTypes to accept a where.
+
 - Added ability to include non-public types in registration.
 

Directory: /trunk/InversionOfControl/Castle.MicroKernel/Registration/Strategies/
================================================================================

File [modified]: BasedOnDescriptor.cs
Delta lines: +14 -1
===================================================================

--- 
trunk/InversionOfControl/Castle.MicroKernel/Registration/Strategies/FromDescriptor.cs
       2008-09-08 20:06:53 UTC (rev 5309)
+++ 
trunk/InversionOfControl/Castle.MicroKernel/Registration/Strategies/FromDescriptor.cs
       2008-09-08 20:18:56 UTC (rev 5310)
@@ -62,6 +62,19 @@
                        return descriptor;
                }
 
+               /// <summary>
+               /// Returns the descriptor for accepting a type based on a 
condition.
+               /// </summary>
+               /// <param name="accepted">The accepting condition.</param>
+               /// <returns>The descriptor for the type.</returns>
+               public BasedOnDescriptor Where(Predicate<Type> accepted)
+               {
+                       BasedOnDescriptor descriptor = new 
BasedOnDescriptor(typeof(object), this)
+                               .If(accepted);
+                       criterias.Add(descriptor);
+                       return descriptor;
+               }
+
                #region IRegistration Members
 
                void IRegistration.Register(IKernel kernel)
@@ -72,7 +85,7 @@
                                {
                                        if (criteria.TryRegister(type, kernel) 
&& !allowMultipleMatches)
                                        {
-                                               continue;
+                                               break;
                                        }
                                }

File [modified]: FromDescriptor.cs
Delta lines: +15 -0
===================================================================

--- 
trunk/InversionOfControl/Castle.MicroKernel.Tests/Registration/AllTypesTestCase.cs
  2008-09-08 20:06:53 UTC (rev 5309)
+++ 
trunk/InversionOfControl/Castle.MicroKernel.Tests/Registration/AllTypesTestCase.cs
  2008-09-08 20:18:56 UTC (rev 5310)
@@ -11,6 +11,7 @@
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 // See the License for the specific language governing permissions and
 // limitations under the License.
+using System.Threading;
 
 namespace Castle.MicroKernel.Tests.Registration
 {
@@ -251,6 +252,20 @@
                        handlers = 
kernel.GetAssignableHandlers(typeof(DefaultSpamServiceWithConstructor));
                        Assert.AreEqual(1, handlers.Length);            
                }
+
+
+               [Test]
+               public void 
RegisterAssemblyTypes_WhereConditionSatisifed_RegisteredInContainer()
+               {
+                       kernel.Register(
+                               
AllTypes.FromAssembly(Assembly.GetExecutingAssembly())
+                                       .Where(t => t.Name == "CustomerImpl")
+                                       .WithService.FirstInterface()
+                                       );
+
+                       IHandler[] handlers = 
kernel.GetHandlers(typeof(ICustomer));
+                       Assert.AreEqual(1, handlers.Length);
+               }
 #endif 
 


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Commits" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/castle-project-commits?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to