From: <jer...@us...> - 2008-06-02 03:02:31
|
Revision: 115 http://structuremap.svn.sourceforge.net/structuremap/?rev=115&view=rev Author: jeremydmiller Date: 2008-06-01 20:02:16 -0700 (Sun, 01 Jun 2008) Log Message: ----------- mild refactoring of DefaultConventionScanner Modified Paths: -------------- trunk/Source/StructureMap/Configuration/DSL/Expressions/ScanAssembliesExpression.cs trunk/Source/StructureMap/Graph/ITypeScanner.cs trunk/Source/StructureMap.Testing/Graph/DefaultConventionScanningTester.cs Modified: trunk/Source/StructureMap/Configuration/DSL/Expressions/ScanAssembliesExpression.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/Expressions/ScanAssembliesExpression.cs 2008-06-01 23:59:11 UTC (rev 114) +++ trunk/Source/StructureMap/Configuration/DSL/Expressions/ScanAssembliesExpression.cs 2008-06-02 03:02:16 UTC (rev 115) @@ -96,5 +96,10 @@ return this; } + + public ScanAssembliesExpression With<T>() where T : ITypeScanner, new() + { + return With(new T()); + } } } \ No newline at end of file Modified: trunk/Source/StructureMap/Graph/ITypeScanner.cs =================================================================== --- trunk/Source/StructureMap/Graph/ITypeScanner.cs 2008-06-01 23:59:11 UTC (rev 114) +++ trunk/Source/StructureMap/Graph/ITypeScanner.cs 2008-06-02 03:02:16 UTC (rev 115) @@ -23,7 +23,7 @@ } } - public static Type FindPluginType(Type concreteType) + public virtual Type FindPluginType(Type concreteType) { string interfaceName = "I" + concreteType.Name; Type[] interfaces = concreteType.GetInterfaces(); Modified: trunk/Source/StructureMap.Testing/Graph/DefaultConventionScanningTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Graph/DefaultConventionScanningTester.cs 2008-06-01 23:59:11 UTC (rev 114) +++ trunk/Source/StructureMap.Testing/Graph/DefaultConventionScanningTester.cs 2008-06-02 03:02:16 UTC (rev 115) @@ -14,8 +14,8 @@ [Test] public void FindPluginType() { - Assert.AreEqual(typeof(IConvention), DefaultConventionScanner.FindPluginType(typeof(Convention))); - Assert.IsNull(DefaultConventionScanner.FindPluginType(this.GetType())); + Assert.AreEqual(typeof(IConvention), new DefaultConventionScanner().FindPluginType(typeof(Convention))); + Assert.IsNull(new DefaultConventionScanner().FindPluginType(this.GetType())); } @@ -46,6 +46,19 @@ Assert.IsInstanceOfType(typeof(Convention), container.GetInstance<IConvention>()); } + + + [Test] + public void Process_to_Container_2() + { + Container container = new Container(delegate(Registry registry) + { + registry.ScanAssemblies().IncludeTheCallingAssembly() + .With<DefaultConventionScanner>(); + }); + + Assert.IsInstanceOfType(typeof(Convention), container.GetInstance<IConvention>()); + } } public interface IConvention{} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |