Every sample that I’ve seen for nServiceBus has used concrete class for IOC property injection. How do I register an interface? In the sample below, how do I register ISmtpClient to return SmtpClientProxy (a concrete class that I’ve created)?
public class EmailNotificationMessageHandler : IHandleMessages<EmailNotificationMessage>
{
public ISmtpClient Smtp { get; set; }
public void Handle(EmailNotificationMessage message)
{
//this.Smtp = new SmtpClient("localhost", 25);
this.Smtp.SendAsync(message.FromAddress, message.ToAddress, message.Subject, message.Body, message.Id);
}
}
My configuration looks like this, but I don’t see how to the concrete type (I don’t want a Singleton)
Configure.With().CastleWindsorBuilder().JsonSerializer();
Configure.Instance.Configurer.ConfigureComponent<ISmtpClient>(DependencyLifecycle.InstancePerCall);
Also, is there a way to get access to the actual container (Windsor in my case) to do any other registration stuff that I want?
You can pass nServiceBus the container to use and you can reference it after: