So I have the following code in C#:
public Container ConfigureSimpleInjector(IAppBuilder app)
{
var container = new Container();
container.Options.DefaultScopedLifestyle = new AsyncScopedLifestyle();
container.RegisterPackages();
app.Use(async (context, next) =>
{
using (AsyncScopedLifestyle.BeginScope(container))
{
await next();
}
});
container.Verify();
return container;
}
The app.Use()
is defined as Owin.AppBuilderUserExtensions.Use()
and looks like this:
public static IAppBuilder Use(this IAppBuilder app, Func<IOwinContext, Func<Task>, Task> handler);
The VB equivalent is as follows:
Public Function ConfigureSimpleInjector(app As IAppBuilder) As Container
Dim container = New Container()
container.Options.DefaultScopedLifestyle = New AsyncScopedLifestyle()
container.RegisterPackages()
app.Use(Async Sub(context, [next])
Using AsyncScopedLifestyle.BeginScope(container)
Await [next]()
End Using
End Sub)
container.Verify()
Return container
End Function
For some reason, in the VB version, the app.Use()
doesn't use the extension function that's available and simply uses IAppBuilder.Use()
instead, as follows:
Function Use(middleware As Object, ParamArray args() As Object) As IAppBuilder
Why does the VB code not use the same extension function that C# does and how can I make it use that?
Edit
For clarity, the extension methods are not my own. They are from the Owin 3rd party library. So there is no option of renaming the extension methods.