私は2つのクラスCustomerService class
とCellphoneCustomerService
クラスを持っています。CellphoneCustomerServic
クラスから派生したCustomerService
クラス。クラスは、クラスのプロパティをCellphoneCustomerService
シャドウします。CustomerRepository
CustomerService
Public Class CustomerService
<Microsoft.Practices.Unity.Dependency()> _
Public Property CustomerRepository as ISQLRepository
Set (Byval value As SQLRepository)
_customerRepository = value
End Set
Get
Return _customerRepository
End Get
End Property
Public Sub Save(Byval Cust As Customer)
Me.CustomerRepository.Save(object)
End Sub
Public Function GetAllCustomers(Byval Query As String) As Customer
Me.CustomerRepository.GetAllCustomer(Byval Query As String)
End Sub
Public Function GetCustomer(Byval ID As Integer)
Me.CustomerRepository.GetCustomer(object)
End Sub
End Class
Public Class CellphoneCustomerService
Inherits CustomerService
<Microsoft.Practices.Unity.Dependency()> _
Public Shadow Property CustomerRepository As IOracleRepository
Set (Byval value As OracleRepository)
_customerRepository = value
End Set
Get
Return _customerRepository
End Get
End Property
End Class
このコードに関する私の問題は、CellphoneCustomerService
クラスのインスタンスを作成し、Save メソッド、GetAllCustomers
およびGetCustomer
関数を使用するときに、派生クラスCustomerRepository
のシャドウ プロパティではなく、基本クラスのプロパティを引き続き使用することです。CustomerRepository
私がする必要があるのは、オブジェクトが のCellphoneCustomerService
場合、基本クラスはクラスのシャドウCustomerRepository
プロパティを使用する必要CellphoneCustomerService
がありますが、オブジェクトがCustomerService
クラスの場合は独自のCustomerRepository
プロパティを使用します。