У меня есть следующий код:
public class MessageEndpoint : IConfigureThisEndpoint, AsA_Server, IWantCustomInitialization
{
private IWindsorContainer _container;
public void Init()
{
_container = new WindsorContainer();
var bus = (IBus)Configure.With()
.CastleWindsorBuilder(_container)
.MsmqTransport()
.PurgeOnStartup(true);
_container.Register(Component.For<IWindsorContainer>().Instance(_container));
_container.Install(FromAssembly.This());
}
}
в другом месте кода, который я использую установщиками windsor, т.е.:
public class StorageConfiginstaller : IWindsorInstaller
{
/// <summary>
/// Performs the installation in the <see cref="T:Castle.Windsor.IWindsorContainer"/>.
/// </summary>
/// <param name="container">The container.</param><param name="store">The configuration store.</param>
public void Install(IWindsorContainer container, IConfigurationStore store)
{
container.Register(Component.For<IStoreEvents>().Instance(BuildEventStore(container.Kernel)).LifeStyle.Singleton);
container.Register(Component.For<IDetectConflicts>().ImplementedBy<ConflictDetector>());
container.Register(Component.For<IRepository>().ImplementedBy<EventStoreRepository>());
container.Register(Component.For<IConstructAggregates>().ImplementedBy<AggregateFactory>());
container.Register(Component.For<IBus>().ImplementedBy<UnicastBus>());
}
private static IStoreEvents BuildEventStore(IKernel container)
{
return Wireup.Init()
.UsingRavenPersistence("EventStore", new DocumentObjectSerializer())
.UsingAsynchronousDispatcher()
.PublishTo(new DelegateMessagePublisher(c => DispatchCommit(container, c)))
.Build();
}
private static void DispatchCommit(IKernel container, Commit commit)
{
var publisher = container.Resolve<IBus>();
publisher.Publish(commit.Events.Select(e => (IMessage)e.Body).ToArray());
}
}
проблема в том, что шина не зарегистрирована в контейнере?Как получить, чтобы автобус был зарегистрирован?
******* обновление ********
это не работает?!
_container = new WindsorContainer();
var c = Configure.With()
.CastleWindsorBuilder(_container)
.MsmqTransport()
.PurgeOnStartup(true);
var bus = _container.Resolve<IBus>();