Closed GoogleCodeExporter closed 8 years ago
Interesting ideas. On testing modules with IStartable included:
var builder = new ContainerBuilder();
var container = builder.Build();
var updater = new ContainerBuilder();
updater.RegisterModule<MyModule>();
updater.Update(container);
The container can now be checked for registrations without the IStartables
being initialised. Will look at adding a helper method to get the same
behaviour more directly.
Thanks!
Original comment by nicholas...@gmail.com
on 2 Jul 2011 at 11:49
Ok - now:
builder = new ContainerBuilder();
builder.RegisterModule<MyModule>();
var container = builder.Build(ContainerBuildOptions.IgnoreStartableComponents);
I'll mark this issue as closed, although I think your test harness idea is very
good. I would like to see it available somewhere (perhaps contrib?) where it
might get developed some more before including anything in core.
Thanks again for your always-valuable input!
Nick
Original comment by nicholas...@gmail.com
on 3 Jul 2011 at 12:11
Thanks for looking at it!
But IStartable is only half the problem. More problematic is the code of the
constructors which is invoked while resolve.
Maybe another idea would be to make ContainerBuildOptions.ReturnTypesOnly.
Which dose not returns an instance but the type of the instance instead.
Original comment by lanwin...@gmail.com
on 3 Jul 2011 at 9:01
If you're interested in checking which type would come back from a Resolve()
operation, rather than just using IsRegistered(), you could do something based
on:
IComponentRegistration registration;
container.ComponentRegistry.TryGetRegistration(
new TypedService(typeof(IMyService)),
out registration);
Assert.AreEqual(someType, registration.Activator.LimitType);
Apart from cases where delegate activators are used, this will give you the
precise type that would provide a service, without creating any instances.
Cheers!
Nick
Original comment by nicholas...@gmail.com
on 3 Jul 2011 at 10:18
Original issue reported on code.google.com by
lanwin...@gmail.com
on 23 Jun 2011 at 9:15