|
From: <jer...@us...> - 2010-02-04 02:42:39
|
Revision: 334
http://structuremap.svn.sourceforge.net/structuremap/?rev=334&view=rev
Author: jeremydmiller
Date: 2010-02-04 02:23:48 +0000 (Thu, 04 Feb 2010)
Log Message:
-----------
Copied some methods to a new name and obsoleted the old with EnrichWith --> EnrichAllWith and OnCreation --> OnCreationForAll()
Modified Paths:
--------------
trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs
Modified: trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs 2010-02-04 01:24:52 UTC (rev 333)
+++ trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs 2010-02-04 02:23:48 UTC (rev 334)
@@ -120,6 +120,16 @@
return TheDefault.Is.ConstructedBy(func);
}
+ /// <summary>
+ /// Shorthand to say TheDefault.Is.ConstructedBy(func)
+ /// </summary>
+ /// <param name="func"></param>
+ /// <returns></returns>
+ public LambdaInstance<PLUGINTYPE> Use(Func<PLUGINTYPE> func)
+ {
+ return TheDefault.Is.ConstructedBy(func);
+ }
+
public void Use(Instance instance)
{
TheDefault.IsThis(instance);
@@ -187,6 +197,7 @@
/// </summary>
/// <param name="handler"></param>
/// <returns></returns>
+ [Obsolete("Change to OnCreationForAll")]
public CreatePluginFamilyExpression<PLUGINTYPE> OnCreation(Action<PLUGINTYPE> handler)
{
_children.Add(
@@ -210,7 +221,37 @@
return this;
}
+
/// <summary>
+ /// Register an Action to run against any object of this PluginType immediately after
+ /// it is created, but before the new object is passed back to the caller
+ /// </summary>
+ /// <param name="handler"></param>
+ /// <returns></returns>
+ public CreatePluginFamilyExpression<PLUGINTYPE> OnCreationForAll(Action<PLUGINTYPE> handler)
+ {
+ _children.Add(
+ graph =>
+ {
+ Func<object, object> function = target =>
+ {
+ handler((PLUGINTYPE)target);
+ return target;
+ };
+
+ var interceptor = new PluginTypeInterceptor(typeof(PLUGINTYPE), (c, o) =>
+ {
+ handler((PLUGINTYPE)o);
+ return o;
+ });
+
+ graph.InterceptorLibrary.AddInterceptor(interceptor);
+ });
+
+ return this;
+ }
+
+ /// <summary>
/// Adds an Interceptor to only this PluginType
/// </summary>
/// <param name="interceptor"></param>
@@ -234,6 +275,7 @@
/// </summary>
/// <param name="handler"></param>
/// <returns></returns>
+ [Obsolete("Change to OnCreationForAll")]
public CreatePluginFamilyExpression<PLUGINTYPE> OnCreation(Action<IContext, PLUGINTYPE> handler)
{
_children.Add(
@@ -253,7 +295,33 @@
return this;
}
+
/// <summary>
+ /// Register an Action to run against any object of this PluginType immediately after
+ /// it is created, but before the new object is passed back to the caller
+ /// </summary>
+ /// <param name="handler"></param>
+ /// <returns></returns>
+ public CreatePluginFamilyExpression<PLUGINTYPE> OnCreationForAll(Action<IContext, PLUGINTYPE> handler)
+ {
+ _children.Add(
+ graph =>
+ {
+ Func<IContext, object, object> function = (c, o) =>
+ {
+ handler(c, (PLUGINTYPE)o);
+ return o;
+ };
+
+ var interceptor = new PluginTypeInterceptor(typeof(PLUGINTYPE), function);
+
+ graph.InterceptorLibrary.AddInterceptor(interceptor);
+ });
+
+ return this;
+ }
+
+ /// <summary>
/// Register a Func to run against any object of this PluginType immediately after it is created,
/// but before the new object is passed back to the caller. Unlike <see cref="OnCreation(Action{PLUGINTYPE})">OnCreation()</see>,
/// EnrichWith() gives the the ability to return a different object. Use this method for runtime AOP
@@ -261,6 +329,7 @@
/// </summary>
/// <param name="handler"></param>
/// <returns></returns>
+ [Obsolete("Change to EnrichAllWith() -- eliminates confusion")]
public CreatePluginFamilyExpression<PLUGINTYPE> EnrichWith(EnrichmentHandler<PLUGINTYPE> handler)
{
_children.Add(
@@ -277,12 +346,35 @@
/// <summary>
/// Register a Func to run against any object of this PluginType immediately after it is created,
+ /// but before the new object is passed back to the caller. Unlike <see cref="OnCreation(Action{PLUGINTYPE})">OnCreation()</see>,
+ /// EnrichWith() gives the the ability to return a different object. Use this method for runtime AOP
+ /// scenarios or to return a decorator.
+ /// </summary>
+ /// <param name="handler"></param>
+ /// <returns></returns>
+ public CreatePluginFamilyExpression<PLUGINTYPE> EnrichAllWith(EnrichmentHandler<PLUGINTYPE> handler)
+ {
+ _children.Add(
+ graph =>
+ {
+ Func<IContext, object, object> function = (context, target) => handler((PLUGINTYPE)target);
+
+ var interceptor = new PluginTypeInterceptor(typeof(PLUGINTYPE), function);
+ graph.InterceptorLibrary.AddInterceptor(interceptor);
+ });
+
+ return this;
+ }
+
+ /// <summary>
+ /// Register a Func to run against any object of this PluginType immediately after it is created,
/// but before the new object is passed back to the caller. Unlike <see cref="OnCreation(Action{IContext,PLUGINTYPE})">OnCreation()</see>,
/// EnrichWith() gives the the ability to return a different object. Use this method for runtime AOP
/// scenarios or to return a decorator.
/// </summary>
/// <param name="handler"></param>
/// <returns></returns>
+ [Obsolete("Change to EnrichAllWith -- it's to avoid confusion")]
public CreatePluginFamilyExpression<PLUGINTYPE> EnrichWith(ContextEnrichmentHandler<PLUGINTYPE> handler)
{
_children.Add(
@@ -296,7 +388,30 @@
return this;
}
+
/// <summary>
+ /// Register a Func to run against any object of this PluginType immediately after it is created,
+ /// but before the new object is passed back to the caller. Unlike <see cref="OnCreation(Action{IContext,PLUGINTYPE})">OnCreation()</see>,
+ /// EnrichWith() gives the the ability to return a different object. Use this method for runtime AOP
+ /// scenarios or to return a decorator.
+ /// </summary>
+ /// <param name="handler"></param>
+ /// <returns></returns>
+ public CreatePluginFamilyExpression<PLUGINTYPE> EnrichAllWith(ContextEnrichmentHandler<PLUGINTYPE> handler)
+ {
+ _children.Add(
+ graph =>
+ {
+ var interceptor = new PluginTypeInterceptor(typeof(PLUGINTYPE),
+ (c, o) => handler(c, (PLUGINTYPE)o));
+ graph.InterceptorLibrary.AddInterceptor(interceptor);
+ });
+
+ return this;
+ }
+
+
+ /// <summary>
/// Shortcut method to add an additional Instance to this Plugin Type
/// as just a Concrete Type. This will only work if the Concrete Type
/// has no primitive constructor or mandatory Setter arguments.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|