VB.Net中的Structuremap(WebForms)

VB.Net中的Structuremap(WebForms),vb.net,structuremap,ioc-container,webforms,Vb.net,Structuremap,Ioc Container,Webforms,我正在尝试将StructureMap连接到现有的webforms应用程序。 因为是webforms,所以我必须使用Setter注入,这并不理想,但总比什么都没有好 我要说的是翻译成VB(我实际上是一个C#dev,目前在VB商店工作)。我已经编写了一个自定义扫描仪,它在C#中工作得很好,但我完全被如何将其翻译成VB所困扰 原来的C#看起来像这样: public void Process(Type type, PluginGraph graph) { if (type.IsInterface

我正在尝试将StructureMap连接到现有的webforms应用程序。 因为是webforms,所以我必须使用Setter注入,这并不理想,但总比什么都没有好

我要说的是翻译成VB(我实际上是一个C#dev,目前在VB商店工作)。我已经编写了一个自定义扫描仪,它在C#中工作得很好,但我完全被如何将其翻译成VB所困扰

原来的C#看起来像这样:

public void Process(Type type, PluginGraph graph)
{
    if (type.IsInterface)
    {
        graph.Configure(x => x.SetAllProperties(
                y => y.TypeMatches(
                    z => z == type)));
    }
}
在VB中我能得到的最接近的结果是:

Public Sub Process(ByVal type As Type, ByVal graph As PluginGraph) Implements ITypeScanner.Process

    If type.IsInterface Then

        graph.Configure(Function(x) _
                            x.SetAllProperties(Function(y) _
                                y.TypeMatches(Function(z) _
                                    return z Is type _
                                ) _
                            ) _
                        )

    End If

End Sub
我希望reflector能够帮助我,但这带来了与我类似的代码,也不会编译


那么,翻译是什么呢?

是的,在VB.Net 9.0中,这将是一个大问题

像这样丑陋的东西

Private Sub configure(ByVal type As Type, ByVal graph As PluginGraph)
            If type.IsInterface Then
                graph.Configure(Function(x) setproperties(x, type))
            End If
        End Sub

        Private Function setproperties(ByVal x As Registry, ByVal type As Type) As Boolean
            x.SetAllProperties(Function(y) setTypeMatches(y, type))
            Return True
        End Function

        Private Function setTypeMatches(ByVal y As SetterConvention, ByVal type As Type) As Boolean
            y.TypeMatches(Function(z) returnType(z, type))
            Return True
        End Function

        Private Function returnType(ByVal z As Type, ByVal type As Type) As Boolean
            Return z Is type
        End Function

或者你可以等待VB.Net 10,在那里它会更容易。

这就是我要说的。啊,再过几个月我就可以在办公室使用VS2010了。