Permalink
Browse files

Merge branch 'master' of github.com:mookid8000/Rebus

  • Loading branch information...
2 parents 6d1e636 + 5a12fdc commit 32070e49c36fd5cce37aa300708ca176ddfdbf01 @mookid8000 mookid8000 committed Oct 9, 2012
@@ -39,6 +39,7 @@ public void SaveBusInstances(IBus bus, IAdvancedBus advancedBus)
var builder = new ContainerBuilder();
builder.RegisterInstance(bus).As<IBus>();
builder.RegisterInstance(advancedBus).As<IAdvancedBus>();
+ builder.Register(a => MessageContext.GetCurrent()).InstancePerDependency();
builder.Update(container);
}
}
@@ -51,7 +51,8 @@ public void SaveBusInstances(IBus bus, IAdvancedBus advancedBus)
.Instance(advancedBus),
Component.For<IMessageContext>()
- .UsingFactoryMethod(k => MessageContext.GetCurrent()),
+ .UsingFactoryMethod(k => MessageContext.GetCurrent())
+ .LifestyleTransient(),
Component.For<InstanceDisposer>()
);
@@ -33,6 +33,7 @@ public void SaveBusInstances(IBus bus, IAdvancedBus advancedBus)
{
kernel.Bind<IBus>().ToConstant(bus).InSingletonScope().Named("bus");
kernel.Bind<IAdvancedBus>().ToConstant(advancedBus).InSingletonScope().Named("advancedBus");
+ kernel.Bind<IMessageContext>().ToMethod(k => MessageContext.GetCurrent()).InTransientScope().Named("messageContext");
// We need to ensure that the kernel have resolved the interfaces once to make it control their lifetime
kernel.Get<IBus>();
@@ -40,6 +40,7 @@ public void SaveBusInstances(IBus bus, IAdvancedBus advancedBus)
{
x.For<IBus>().Singleton().Add(bus);
x.For<IAdvancedBus>().Singleton().Add(advancedBus);
+ x.For<IMessageContext>().Transient().Use(MessageContext.GetCurrent);
});
}
}
@@ -33,6 +33,7 @@ public void SaveBusInstances(IBus bus, IAdvancedBus advancedBus)
{
unityContainer.RegisterInstance(typeof(IBus), bus);
unityContainer.RegisterInstance(typeof(IAdvancedBus), advancedBus);
+ unityContainer.RegisterType<IMessageContext>(new InjectionFactory(c => MessageContext.GetCurrent()));
}
}
}
@@ -12,9 +12,15 @@ public class BuiltinContainerAdapter : IContainerAdapter, IDisposable
{
readonly SimpleHandlerActivator handlerActivator = new SimpleHandlerActivator();
- public IBus Bus { get; set; }
+ /// <summary>
+ /// Use this property to access the bus instance
+ /// </summary>
+ public IBus Bus { get; internal set; }
- public IAdvancedBus AdvancedBus { get; set; }
+ /// <summary>
+ /// Use this property to access the advanced bus, which is an ordinary bus plus some advanced operations
+ /// </summary>
+ public IAdvancedBus AdvancedBus { get; internal set; }
/// <summary>
/// Registers the given handler type. It is assumed that the type registered has a public

0 comments on commit 32070e4

Please sign in to comment.