decorator: search idea's for implementation

14 views
Skip to first unread message

dsfre...@gmail.com

unread,
Sep 10, 2015, 9:02:17 AM9/10/15
to Autofac
Hi,

Currently we have ICommandHandlers implementations which we register keybased. Like
containerBuilder.RegisterType(commandHandlerType)
.Keyed<ICommandHandler>(commandType);

Next we have a factory function which is registered like this:

containerBuilder.Register<Func<ICommand, Owned<ICommandHandler>>>(c =>
{
var context = c.Resolve<IComponentContext>();

return command => context.IsRegisteredWithKey<Owned<ICommandHandler>>(command.GetType())
? context.ResolveKeyed<Owned<ICommandHandler>>(command.GetType())
: null;
});


Now, if we want to use the decorator functionality (http://docs.autofac.org/en/latest/advanced/adapters-decorators.html#decorators) in autofac to add for example transactionsupport or anything else which can be done using a decorator...
How can be perform this without changing the signature of our factory function (we want to keep Func<ICommand, Owned<ICommandHandler>?

Thanks on advance

Travis Illig

unread,
Sep 11, 2015, 10:25:58 AM9/11/15
to Autofac
It appears you've cross-posted this to StackOverflow so people interested in answering this question should follow up there.

In the future, please don't cross-post questions. More folks monitor StackOverflow than the discussion forum and cross-posting wastes time on duplicate answers.
Reply all
Reply to author
Forward
0 new messages