0

継承するクラスを作成し、ベースプロパティアイテムをシャドウBindingList(of T)するプロパティを次のように追加しました Item(indx as Integer)

<System.Reflection.DefaultMember("Item")> _
Public Class Unity(Of T As {New, Entity})
    Inherits BindingList(Of T)
    Implements IUnity

    Public Property Item(ByVal indx As Integer) As T
        Get
            If indx >= Me.Count Then
                Throw New ArgumentOutOfRangeException("index")
            End If
            If Not MyBase.Item(indx)._IsLoaded Then InitDataOfItemsInPage(indx)
            Return MyBase.Item(indx)
        End Get
        Set(ByVal value As T)
            MyBase.Item(indx) = value
        End Set
    End Property

    ......
End Class

今、私がアイテムにアクセスしようとすると、myUnity.Item(1)すべてを書くことはうまくいきます。コードはプロパティItemに移動し、実行する必要があることを実行してmyEntityを返します。しかし、私が書くmyUnity(1)と、プロパティアイテムを通過せずにmyEntityを取得します。理由を知っている人はいますか?

4

1 に答える 1

0

Unity(...) クラスの DefaultMemberAttribute の前に、BindingList(of T) の「デフォルト プロパティ項目」が優先されるようです。どうしてか分かりません。

Default Property Item(ByVal indx As Integer) As T 代わりに 正常に<DefaultMember>(...) 動作します。

于 2011-04-05T19:48:28.983 に答える