I'm about to put my head thru this sliding glass door. I can't figure out how to execute the following code in VB.NET to save my life.
private static void InitStructureMap()
{
ObjectFactory.Initialize(x =>
{
x.AddRegistry(new DataAccessRegistry());
x.AddRegistry(new CoreRegistry());
x.AddRegistry(new WebUIRegistry());
x.Scan(scanner =>
{
scanner.Assembly("RPMWare.Core");
scanner.Assembly("RPMWare.Core.DataAccess");
scanner.WithDefaultConventions();
});
});
}
At the moment, it's simply not possible. The current version of VB does not support multiline (or statement) lambdas. Each lambda can only comprise one single expression. The next version of VB will fix that (there simply wasn't enough time in the last release).
In the meantime, you'll have to make do with a delegate:
Private Shared Sub Foobar(x As IInitializationExpression)
x.AddRegistry(New DataAccessRegistry)
x.AddRegistry(New CoreRegistry)
x.AddRegistry(New WebUIRegistry)
x.Scan(AddressOf Barfoo)
End Sub
Private Shared Sub Barfoo(ByVal scanner As IAssemblyScanner)
scanner.Assembly("RPMWare.Core")
scanner.Assembly("RPMWare.Core.DataAccess")
scanner.WithDefaultConventions
End Sub
' … '
ObjectFactory.Initialize(AddressOf Foobar)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With