From: <jer...@us...> - 2009-12-05 18:40:48
|
Revision: 277 http://structuremap.svn.sourceforge.net/structuremap/?rev=277&view=rev Author: jeremydmiller Date: 2009-12-05 18:40:41 +0000 (Sat, 05 Dec 2009) Log Message: ----------- convenience method on GenericFamilyExpression that I needed for FubuMVC Modified Paths: -------------- trunk/Source/StructureMap/Configuration/DSL/Expressions/GenericFamilyExpression.cs Modified: trunk/Source/StructureMap/Configuration/DSL/Expressions/GenericFamilyExpression.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/Expressions/GenericFamilyExpression.cs 2009-12-04 23:00:27 UTC (rev 276) +++ trunk/Source/StructureMap/Configuration/DSL/Expressions/GenericFamilyExpression.cs 2009-12-05 18:40:41 UTC (rev 277) @@ -85,7 +85,7 @@ } - private GenericFamilyExpression add(Instance instance) + public GenericFamilyExpression Add(Instance instance) { return alterAndContinue(family => family.AddInstance(instance)); } @@ -176,9 +176,11 @@ /// <returns></returns> public GenericFamilyExpression AddConcreteType(Type concreteType) { - return add(new ConfiguredInstance(concreteType)); + var instance = new ConfiguredInstance(concreteType); + return Add(instance); } + /// <summary> /// Shortcut method to add an additional Instance to this Plugin Type /// as just a Concrete Type by a specified name. You can also chain other declarations after @@ -189,7 +191,7 @@ /// <returns></returns> public GenericFamilyExpression AddConcreteType(Type concreteType, string instanceName) { - return add(new ConfiguredInstance(concreteType).WithName(instanceName)); + return Add(new ConfiguredInstance(concreteType).WithName(instanceName)); } } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2009-12-26 20:51:14
|
Revision: 303 http://structuremap.svn.sourceforge.net/structuremap/?rev=303&view=rev Author: jeremydmiller Date: 2009-12-26 20:51:05 +0000 (Sat, 26 Dec 2009) Log Message: ----------- adding more capabilities to the GenericFamilyExpression to bring it up to par with the strong typed version Modified Paths: -------------- trunk/Source/StructureMap/Configuration/DSL/Expressions/GenericFamilyExpression.cs Modified: trunk/Source/StructureMap/Configuration/DSL/Expressions/GenericFamilyExpression.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/Expressions/GenericFamilyExpression.cs 2009-12-26 20:31:30 UTC (rev 302) +++ trunk/Source/StructureMap/Configuration/DSL/Expressions/GenericFamilyExpression.cs 2009-12-26 20:51:05 UTC (rev 303) @@ -67,6 +67,23 @@ return TheDefaultIsConcreteType(concreteType); } + + public LambdaInstance<object> Use(Func<IContext, object> func) + { + var instance = new LambdaInstance<object>(func); + Use(instance); + + return instance; + } + + public LambdaInstance<object> Add(Func<IContext, object> func) + { + var instance = new LambdaInstance<object>(func); + Add(instance); + + return instance; + } + /// <summary> /// Shortcut to add a value by type /// </summary> @@ -200,6 +217,45 @@ } /// <summary> + /// Convenience method to mark a PluginFamily as a Singleton + /// </summary> + /// <returns></returns> + public GenericFamilyExpression Singleton() + { + return LifecycleIs(InstanceScope.Singleton); + } + + + /// <summary> + /// Convenience method to mark a PluginFamily as a Hybrid lifecycle + /// </summary> + /// <returns></returns> + public GenericFamilyExpression HybridHttpOrThreadLocalScoped() + { + return LifecycleIs(InstanceScope.Hybrid); + } + + /// <summary> + /// Convenience method to mark a PluginFamily as HttpContext scoped + /// </summary> + /// <returns></returns> + public GenericFamilyExpression HttpContextScoped() + { + return LifecycleIs(InstanceScope.HttpContext); + } + + /// <summary> + /// + /// </summary> + /// <param name="lifecycle"></param> + /// <returns></returns> + public GenericFamilyExpression LifecycleIs(InstanceScope lifecycle) + { + return alterAndContinue(family => family.SetScopeTo(lifecycle)); + } + + + /// <summary> /// Shortcut method to add an additional Instance to this Plugin Type /// as just a Concrete Type. You can also chain other declarations after /// this method to add constructor and setter arguments This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |