Skip to content

Instantly share code, notes, and snippets.

@msciborski
Created June 24, 2020 17:48
Show Gist options
  • Save msciborski/4b1fe588da1a0f12dcaaa5e55154b0ba to your computer and use it in GitHub Desktop.
Save msciborski/4b1fe588da1a0f12dcaaa5e55154b0ba to your computer and use it in GitHub Desktop.
builder.Register<SenderFactory>(c =>
{
var context = c.Resolve<IComponentContext>();
return (client) =>
{
var sender = context.Resolve<IEnumerable<ISender>>()
.Select(s => new
{
Metadata = (ClientMetadataAttribute) Attribute.GetCustomAttribute(s.GetType(),
typeof(ClientMetadataAttribute)),
Value = s,
})
.First(s => s.Metadata.Client == client)
.Value;
return sender;
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment