User: xtoff
Date: 2010/01/21 11:23 AM

Added:
 
/InversionOfControl/trunk/src/Castle.Windsor.Tests/Facilities/TypedFactory/Components/
  ComponentWithOptionalParameter.cs
 
/InversionOfControl/trunk/src/Castle.Windsor.Tests/Facilities/TypedFactory/Factories/
  IFactoryWithParameters.cs

Modified:
 /InversionOfControl/trunk/src/Castle.MicroKernel/Facilities/Startable/
  StartableFacility.cs
 /InversionOfControl/trunk/src/Castle.MicroKernel/Facilities/TypedFactory/
  DefaultTypedFactoryComponentSelector.cs
 /InversionOfControl/trunk/src/Castle.Windsor.Tests/
  Castle.Windsor.Tests-vs2008.csproj
 /InversionOfControl/trunk/src/Castle.Windsor.Tests/Facilities/TypedFactory/
  TypedFactoryFacilityTake2TestCase.cs

Log:
 - changed DefaultTypedFactoryComponentSelector to match arguments in a 
case-insensitive way
 - changed DefaultTypedFactoryComponentSelector's to be protected virtual

File Changes:

Directory: /InversionOfControl/trunk/src/Castle.Windsor.Tests/
==============================================================

File [modified]: Castle.Windsor.Tests-vs2008.csproj
Delta lines: +21 -0
===================================================================

--- 
InversionOfControl/trunk/src/Castle.Windsor.Tests/Facilities/TypedFactory/Components/ComponentWithOptionalParameter.cs
                              (rev 0)
+++ 
InversionOfControl/trunk/src/Castle.Windsor.Tests/Facilities/TypedFactory/Components/ComponentWithOptionalParameter.cs
      2010-01-21 18:23:32 UTC (rev 6706)
@@ -0,0 +1,21 @@
+// Copyright 2004-2009 Castle Project - http://www.castleproject.org/
+// 
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// 
+//     http://www.apache.org/licenses/LICENSE-2.0
+// 
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// 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.
+
+namespace Castle.Windsor.Tests.Facilities.TypedFactory.Components
+{
+       public class ComponentWithOptionalParameter
+       {
+               public string Parameter { get; set; }
+       }
+}

Directory: 
/InversionOfControl/trunk/src/Castle.Windsor.Tests/Facilities/TypedFactory/Components/
=================================================================================================

File [added]: ComponentWithOptionalParameter.cs
Delta lines: +23 -0
===================================================================

--- 
InversionOfControl/trunk/src/Castle.Windsor.Tests/Facilities/TypedFactory/Factories/IFactoryWithParameters.cs
                               (rev 0)
+++ 
InversionOfControl/trunk/src/Castle.Windsor.Tests/Facilities/TypedFactory/Factories/IFactoryWithParameters.cs
       2010-01-21 18:23:32 UTC (rev 6706)
@@ -0,0 +1,23 @@
+// Copyright 2004-2009 Castle Project - http://www.castleproject.org/
+// 
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// 
+//     http://www.apache.org/licenses/LICENSE-2.0
+// 
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// 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.
+
+namespace Castle.Windsor.Tests.Facilities.TypedFactory.Factories
+{
+       using Castle.Windsor.Tests.Facilities.TypedFactory.Components;
+
+       public interface IFactoryWithParameters
+       {
+               ComponentWithOptionalParameter BuildComponent(string parameter);
+       }
+}

Directory: 
/InversionOfControl/trunk/src/Castle.Windsor.Tests/Facilities/TypedFactory/Factories/
================================================================================================

File [added]: IFactoryWithParameters.cs
Delta lines: +14 -1
===================================================================

--- 
InversionOfControl/trunk/src/Castle.Windsor.Tests/Facilities/TypedFactory/TypedFactoryFacilityTake2TestCase.cs
      2010-01-20 17:32:30 UTC (rev 6705)
+++ 
InversionOfControl/trunk/src/Castle.Windsor.Tests/Facilities/TypedFactory/TypedFactoryFacilityTake2TestCase.cs
      2010-01-21 18:23:32 UTC (rev 6706)
@@ -22,8 +22,8 @@
        using Castle.Facilities.TypedFactory.Tests.Factories;
        using Castle.MicroKernel.Facilities.TypedFactory;
        using Castle.MicroKernel.Registration;
-       using Castle.MicroKernel.Resolvers.SpecializedResolvers;
        using Castle.Windsor;
+       using Castle.Windsor.Tests.Facilities.TypedFactory.Components;
        using Castle.Windsor.Tests.Facilities.TypedFactory.Factories;
 
        using NUnit.Framework;
@@ -146,6 +146,19 @@
                }
 
                [Test]
+               public void Should_match_arguments_ignoring_case()
+               {
+                       container.Register(
+                               
Component.For<IFactoryWithParameters>().AsFactory(),
+                               
Component.For<ComponentWithOptionalParameter>());
+
+                       var factory = 
container.Resolve<IFactoryWithParameters>();
+                       var component = factory.BuildComponent("foo");
+
+                       Assert.AreEqual("foo", component.Parameter);
+               }
+
+               [Test]
                public void 
Disposing_factory_does_not_destroy_singleton_components()
                {

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

File [modified]: StartableFacility.cs
Delta lines: +4 -4
===================================================================

--- 
InversionOfControl/trunk/src/Castle.MicroKernel/Facilities/TypedFactory/DefaultTypedFactoryComponentSelector.cs
     2010-01-20 17:32:30 UTC (rev 6705)
+++ 
InversionOfControl/trunk/src/Castle.MicroKernel/Facilities/TypedFactory/DefaultTypedFactoryComponentSelector.cs
     2010-01-21 18:23:32 UTC (rev 6706)
@@ -28,12 +28,12 @@
                        return new TypedFactoryComponent(componentName, 
componentType, additionalArguments);
                }
 
-               private Type GetComponentType(MethodInfo method)
+               protected virtual Type GetComponentType(MethodInfo method)
                {
                        return method.ReturnType;
                }
 
-               private string GetComponentName(MethodInfo method)
+               protected virtual string GetComponentName(MethodInfo method)
                {
                        string componentName = null;
                        if (method.Name.StartsWith("Get"))
@@ -43,9 +43,9 @@
                        return componentName;
                }
 
-               private Dictionary<string, object> GetArguments(MethodInfo 
method, object[] arguments)
+               protected virtual Dictionary<string, object> 
GetArguments(MethodInfo method, object[] arguments)
                {
-                       var argumentMap = new Dictionary<string, object>();
+                       var argumentMap = new Dictionary<string, 
object>(StringComparer.OrdinalIgnoreCase);
                        var parameters = method.GetParameters();
                        for (int i = 0; i < parameters.Length; i++)

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

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

--- 
InversionOfControl/trunk/src/Castle.Windsor.Tests/Castle.Windsor.Tests-vs2008.csproj
        2010-01-20 17:32:30 UTC (rev 6705)
+++ 
InversionOfControl/trunk/src/Castle.Windsor.Tests/Castle.Windsor.Tests-vs2008.csproj
        2010-01-21 18:23:32 UTC (rev 6706)
@@ -276,6 +276,7 @@
     <Compile Include="Facilities\Remoting\ServerClientContainerTestCase.cs" />
     <Compile Include="Facilities\TypedFactory\Components\Component1.cs" />
     <Compile Include="Facilities\TypedFactory\Components\Component2.cs" />
+    <Compile 
Include="Facilities\TypedFactory\Components\ComponentWithOptionalParameter.cs" 
/>
     <Compile 
Include="Facilities\TypedFactory\Components\DisposableComponent.cs" />
     <Compile Include="Facilities\TypedFactory\Components\GenericComponent.cs" 
/>
     <Compile 
Include="Facilities\TypedFactory\Components\GenericComponentWithIntArg.cs" />
@@ -287,6 +288,7 @@
     <Compile Include="Facilities\TypedFactory\Factories\IDisposableFactory.cs" 
/>
     <Compile 
Include="Facilities\TypedFactory\Factories\DummyComponentFactory.cs" />
     <Compile Include="Facilities\TypedFactory\Factories\IComponentFactory.cs" 
/>
+    <Compile 
Include="Facilities\TypedFactory\Factories\IFactoryWithParameters.cs" />
     <Compile 
Include="Facilities\TypedFactory\Factories\IGenericComponentsFactory.cs" />
     <Compile 
Include="Facilities\TypedFactory\Factories\IProtocolHandlerFactory.cs" />

Directory: 
/InversionOfControl/trunk/src/Castle.Windsor.Tests/Facilities/TypedFactory/
======================================================================================

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

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