User: xtoff
Date: 2010/01/07 09:57 AM

Modified:
 /InversionOfControl/trunk/src/Castle.MicroKernel.Tests/Lifecycle/
  LifecycleTestCase.cs
 /InversionOfControl/trunk/src/Castle.MicroKernel/Facilities/Startable/
  StartConcern.cs, StopConcern.cs

Log:
 - fixed IOC-ISSUE-188 - startable facility fails to choose start or stop 
methods if method overload exists.

File Changes:

Directory: /InversionOfControl/trunk/src/Castle.MicroKernel.Tests/Lifecycle/
============================================================================

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

Directory: 
/InversionOfControl/trunk/src/Castle.MicroKernel/Facilities/Startable/
=================================================================================

File [modified]: StartConcern.cs
Delta lines: +3 -3
===================================================================

--- 
InversionOfControl/trunk/src/Castle.MicroKernel/Facilities/Startable/StopConcern.cs
 2010-01-07 04:55:46 UTC (rev 6591)
+++ 
InversionOfControl/trunk/src/Castle.MicroKernel/Facilities/Startable/StopConcern.cs
 2010-01-07 16:57:37 UTC (rev 6592)
@@ -24,7 +24,7 @@
 
        public class StopConcern : ILifecycleConcern
        {
-               private static readonly StopConcern _instance = new 
StopConcern();
+               private static readonly StopConcern instance = new 
StopConcern();
 
                protected StopConcern()
                {
@@ -32,7 +32,7 @@
 
                public static StopConcern Instance
                {
-                       get { return _instance; }
+                       get { return instance; }
                }
 
                public void Apply(ComponentModel model, object component)
@@ -47,7 +47,7 @@
 
                                if (stopMethod != null)
                                {
-                                       MethodInfo method = 
model.Implementation.GetMethod(stopMethod);
+                                       MethodInfo method = 
model.Implementation.GetMethod(stopMethod, Type.EmptyTypes);
                                        method.Invoke(component, null);
                                }

File [modified]: StopConcern.cs
Delta lines: +46 -0
===================================================================

--- 
InversionOfControl/trunk/src/Castle.MicroKernel.Tests/Lifecycle/LifecycleTestCase.cs
        2010-01-07 04:55:46 UTC (rev 6591)
+++ 
InversionOfControl/trunk/src/Castle.MicroKernel.Tests/Lifecycle/LifecycleTestCase.cs
        2010-01-07 16:57:37 UTC (rev 6592)
@@ -14,6 +14,11 @@
 
 namespace Castle.MicroKernel.Tests.Lifecycle
 {
+       using System;
+
+       using Castle.Core;
+       using Castle.Facilities.Startable;
+       using Castle.MicroKernel.Registration;
        using Castle.MicroKernel.Tests.Lifecycle.Components;
        using NUnit.Framework;
 
@@ -57,5 +62,46 @@
 
                        Assert.IsTrue(server.IsDisposed);
                }
+
+               [Test]
+               public void Works_when_method_has_overloads()
+               {
+                       kernel.AddFacility<StartableFacility>();
+                       kernel.Register(Component.For<WithOverloads>()
+                                               .StartUsingMethod("Start")
+                                               .StopUsingMethod("Stop"));
+                       var c = kernel.Resolve<WithOverloads>();
+                       Assert.IsTrue(c.StartCalled);
+                       kernel.ReleaseComponent(c);
+                       Assert.IsTrue(c.StopCalled);
+               }
+
        }
+
+       [Transient]
+       public class WithOverloads
+       {
+               public void Start()
+               {
+                       StartCalled = true;
+               }
+
+               public bool StartCalled { get; set; }
+
+               public void Start(int fake)
+               {
+                       
+               }
+               public void Stop()
+               {
+                       StopCalled = true;
+               }
+
+               public bool StopCalled { get; set; }
+
+               public void Stop(string fake)
+               {
+                       
+               }
+       }
 }

-- 
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