/// <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">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="func"></param> /// <returns></returns> public GenericFamilyExpression EnrichWith(Func <IContext, object, object> func) { _registry.addExpression(graph => { var interceptor = new PluginTypeInterceptor(_pluginType, func); 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="OnCreationForAll">OnCreationForAll()</see>, /// EnrichAllWith() gives the the ability to return a different object. Use this method for runtime AOP /// scenarios or to return a decorator. /// </summary> /// <param name="func"></param> /// <returns></returns> public GenericFamilyExpression EnrichAllWith(Func <object, object> func) { _registry.alter = graph => { var interceptor = new PluginTypeInterceptor(_pluginType, (c, o) => func(o)); 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> 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> /// Adds an Interceptor to only this PluginType /// </summary> /// <param name="interceptor"></param> /// <returns></returns> public CreatePluginFamilyExpression <PLUGINTYPE> InterceptWith(InstanceInterceptor interceptor) { _children.Add( graph => { var typeInterceptor = new PluginTypeInterceptor(typeof(PLUGINTYPE), (c, o) => interceptor.Process(o, c)); graph.InterceptorLibrary.AddInterceptor(typeInterceptor); }); 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 /// 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 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 <TPluginType> OnCreationForAll(Action <TPluginType> handler) { _children.Add( graph => { var interceptor = new PluginTypeInterceptor(typeof(TPluginType), (c, o) => { handler((TPluginType)o); return(o); }); graph.InterceptorLibrary.AddInterceptor(interceptor); }); 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); }
public CreatePluginFamilyExpression <PLUGINTYPE> OnCreation(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); }