From: <jer...@us...> - 2009-12-23 19:37:00
|
Revision: 283 http://structuremap.svn.sourceforge.net/structuremap/?rev=283&view=rev Author: jeremydmiller Date: 2009-12-23 19:36:53 +0000 (Wed, 23 Dec 2009) Log Message: ----------- added more convenience methods to the generic family expression Modified Paths: -------------- trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs trunk/Source/StructureMap/Configuration/DSL/Expressions/GenericFamilyExpression.cs trunk/Source/StructureMap/Configuration/DSL/Expressions/InstanceExpression.cs trunk/Source/StructureMap.DebuggerVisualizers.Testing/Program.cs trunk/Source/StructureMap.Testing/Diagnostics/DoctorTester.cs trunk/Source/StructureMap.Testing/Examples/Interception.cs trunk/Source/StructureMap.Testing/Examples/RegisteringWithTheAPI.cs trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj Added Paths: ----------- trunk/Source/StructureMap.Testing/Bugs/AddValueDirectlyWithGenericUsage.cs Modified: trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs 2009-12-21 23:11:23 UTC (rev 282) +++ trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs 2009-12-23 19:36:53 UTC (rev 283) @@ -81,6 +81,7 @@ /// </summary> /// <typeparam name="CONCRETETYPE"></typeparam> /// <returns></returns> + [Obsolete("Prefer the usage For<ISomething>().Use<Something>()")] public CreatePluginFamilyExpression<PLUGINTYPE> TheDefaultIsConcreteType<CONCRETETYPE>() where CONCRETETYPE : PLUGINTYPE { Modified: trunk/Source/StructureMap/Configuration/DSL/Expressions/GenericFamilyExpression.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/Expressions/GenericFamilyExpression.cs 2009-12-21 23:11:23 UTC (rev 282) +++ trunk/Source/StructureMap/Configuration/DSL/Expressions/GenericFamilyExpression.cs 2009-12-23 19:36:53 UTC (rev 283) @@ -67,6 +67,19 @@ return TheDefaultIsConcreteType(concreteType); } + /// <summary> + /// Shortcut to add a value by type + /// </summary> + /// <param name="value"></param> + /// <returns></returns> + public LiteralInstance Use(object value) + { + var instance = new LiteralInstance(value); + Use(instance); + + return instance; + } + /// <summary> /// Shortcut method to add an additional Instance to this Plugin Type Modified: trunk/Source/StructureMap/Configuration/DSL/Expressions/InstanceExpression.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/Expressions/InstanceExpression.cs 2009-12-21 23:11:23 UTC (rev 282) +++ trunk/Source/StructureMap/Configuration/DSL/Expressions/InstanceExpression.cs 2009-12-23 19:36:53 UTC (rev 283) @@ -103,6 +103,7 @@ /// </summary> /// <typeparam name="PLUGGEDTYPE"></typeparam> /// <returns></returns> + [Obsolete("Favor For<ISomething>().Use<Something>()")] SmartInstance<PLUGGEDTYPE> OfConcreteType<PLUGGEDTYPE>() where PLUGGEDTYPE : T; /// <summary> @@ -112,6 +113,7 @@ /// </summary> /// <param name="type"></param> /// <returns></returns> + [Obsolete("Favor For<ISomething>().Use(typeof(Something))")] ConfiguredInstance OfConcreteType(Type type); /// <summary> @@ -120,6 +122,7 @@ /// </summary> /// <param name="func"></param> /// <returns></returns> + [Obsolete("Prefer For<T>().Use(Func<T> func) or For<T>().Add(Func<T> func)")] ConstructorInstance<T> ConstructedBy(Func<T> func); /// <summary> Modified: trunk/Source/StructureMap.DebuggerVisualizers.Testing/Program.cs =================================================================== --- trunk/Source/StructureMap.DebuggerVisualizers.Testing/Program.cs 2009-12-21 23:11:23 UTC (rev 282) +++ trunk/Source/StructureMap.DebuggerVisualizers.Testing/Program.cs 2009-12-23 19:36:53 UTC (rev 283) @@ -1,4 +1,4 @@ -using System.Diagnostics; +using System.Diagnostics; using System.Windows.Forms; namespace StructureMap.DebuggerVisualizers.Testing Added: trunk/Source/StructureMap.Testing/Bugs/AddValueDirectlyWithGenericUsage.cs =================================================================== --- trunk/Source/StructureMap.Testing/Bugs/AddValueDirectlyWithGenericUsage.cs (rev 0) +++ trunk/Source/StructureMap.Testing/Bugs/AddValueDirectlyWithGenericUsage.cs 2009-12-23 19:36:53 UTC (rev 283) @@ -0,0 +1,23 @@ +using NUnit.Framework; +using StructureMap.Testing.Widget; + +namespace StructureMap.Testing.Bugs +{ + [TestFixture] + public class AddValueDirectlyWithGenericUsage + { + [SetUp] + public void SetUp() + { + } + + [Test] + public void should_be_able_to_resolve_from_the_generic_family_expression() + { + var widget = new AWidget(); + var container = new Container(x => x.For(typeof (IWidget)).Use(widget).WithName("mine")); + + container.GetInstance<IWidget>("mine").ShouldBeTheSameAs(widget); + } + } +} \ No newline at end of file Modified: trunk/Source/StructureMap.Testing/Diagnostics/DoctorTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Diagnostics/DoctorTester.cs 2009-12-21 23:11:23 UTC (rev 282) +++ trunk/Source/StructureMap.Testing/Diagnostics/DoctorTester.cs 2009-12-23 19:36:53 UTC (rev 283) @@ -1,4 +1,4 @@ -using System; +using System; using System.Diagnostics; using System.IO; using System.Reflection; Modified: trunk/Source/StructureMap.Testing/Examples/Interception.cs =================================================================== --- trunk/Source/StructureMap.Testing/Examples/Interception.cs 2009-12-21 23:11:23 UTC (rev 282) +++ trunk/Source/StructureMap.Testing/Examples/Interception.cs 2009-12-23 19:36:53 UTC (rev 283) @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices.ComTypes; Modified: trunk/Source/StructureMap.Testing/Examples/RegisteringWithTheAPI.cs =================================================================== --- trunk/Source/StructureMap.Testing/Examples/RegisteringWithTheAPI.cs 2009-12-21 23:11:23 UTC (rev 282) +++ trunk/Source/StructureMap.Testing/Examples/RegisteringWithTheAPI.cs 2009-12-23 19:36:53 UTC (rev 283) @@ -1,4 +1,4 @@ -using StructureMap.Configuration.DSL; +using StructureMap.Configuration.DSL; namespace StructureMap.Testing.Examples { Modified: trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj =================================================================== --- trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj 2009-12-21 23:11:23 UTC (rev 282) +++ trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj 2009-12-23 19:36:53 UTC (rev 283) @@ -178,6 +178,7 @@ <Compile Include="AutoMocking\RhinoMockRepositoryProxyTester.cs" /> <Compile Include="AutoWiringExamples.cs" /> <Compile Include="BidirectionalDependencies.cs" /> + <Compile Include="Bugs\AddValueDirectlyWithGenericUsage.cs" /> <Compile Include="Bugs\BuildUpBug.cs" /> <Compile Include="Bugs\FillAllPropertiesShouldWorkForAlreadyConfiguredPluginsBug.cs" /> <Compile Include="Bugs\HttpSessionNullRefBug.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |