에 대한 디자인 패턴 질문 :일반 컬렉션, 회원 클래스, 내가 사람이라는 클래스가 VB.NET
Public Class Person
Private PersonID as String
Private Name as String
Private Records as GenericCollection(Of PublicRecord)
Public Sub New(ByVal ID as String)
Me.PersonID = ID
Me.Name = getPersonName(ID)
End Sub
'Get/Sets
End Class
getPersonName는 단순히 설명대로 정확히 수행하는 기능입니다.
Public Class GenericCollection(Of ItemType)
Inherits CollectionBase
' Purpose: Provides a generic collection class from which all other collections
' classes can be inherited if they wish to extend the functionality below.
#Region "Public Methods"
Public Function Add(ByVal NewObject As ItemType) As Integer
Return MyBase.InnerList.Add(NewObject)
End Function
Public Sub New()
MyBase.New()
End Sub
#End Region
#Region "Public Properties"
Default Public Property Item(ByVal Index As Integer) As ItemType
Get
Return CType(MyBase.InnerList(Index), ItemType)
End Get
Set(ByVal value As ItemType)
MyBase.InnerList(Index) = value
End Set
End Property
#End Region
End Class
PublicRecord 클래스는 다음과 같습니다 : 내가 할 수있는 들었다 요구 사항의
Public Class PublicRecord
Private RecordID As String
Private RecordDataOne As String
Private RecordDataTwo As String
Public Sub New()
MyBase.New()
End Sub
'Get/Sets
End Class
하나는 내가의 컬렉션에있는 모든 사람을 잡을 수 있어야한다는 것입니다 다음과 같이 GenericCollection 클래스입니다 그러면 모든 사람이 자신의 기록에있는 Collectinos를 갖게 될 것입니다 ... 기록의 수집에서 특정 데이터 세트를 가져옵니다.
우리는 다음과 같이 말하고 싶습니다 : Person of Collection 내의 각 Person 내부의 Collection of Records로부터 getPersonsOverAge21()을 원합니다.
이것도 가능합니까? 그렇다면 어떻게 작동하는지 설명 할 수 있습니까?
이 어떤 부분을 이해하지 않습니다하지만 당신이 뭔가를 원하는 같은 종류의 소리? 이걸 시도 했니? 당신이 시도한 것을 보여주십시오. –
모든 Person을 GenericCollection (Of Person)으로 가져올 수 있습니다. 나는 GenericCollection (Of Person)을 반복하고 Collection의 각 인덱스에서 getPersonsOverAge21()을 실행해야한다고 가정하고있다. PersonCollection (0) .Records.getPersonsOverAge21() 실제로 반복하지 않고도이 작업을 수행 할 수 있는가? ? – jlrolin