How to implement a List of Diffrent Generic Lists
I want to create a Object thet reports all data collisions and it needs to return lists of (diffrent objects) that collide with each other.
The first step was to create a generic interface holding a list(OF T)
like so:
Code:
Public Interface IValidationResult(Of T)
ReadOnly Property ResultList() As IList(Of T)
ReadOnly Property ResultCount() As Integer
End Interface
These lists should be added to a object to hold all colliding issues in seperate Lists... and that's Where I get stuck this code goes wrong because a specification of the Type of IValidationResult like:
IValidationResult(Of Persons)
is needed but I want to add diffrent Hardtyped lists to the object like
A list of Conflicting PersonData:
IValidationResult(Of Persons)
A list of conflicting Securityroles
IValidationResult(Of SecurityRoles)
A list of Conflicting SaldoItems
A list ofIValidationResult(Of SaldoItems)
Code:
Public Interface IValidationResults
ReadOnly Property IsValid() As Boolean
ReadOnly Property ResultLists() As IList(Of IValidationResult)
ReadOnly Property ResultListsCount() As Integer
ReadOnly Property ResultCount(ByVal ListIndex As Integer) As Integer
Sub AddList(ByVal ValidationResult As IValidationResult)
End Interface
How to achieve this goal with strong typed lists wich can be refered so in the code using this error reporting?
Thanks in Advance
Re: How to implement a List of Diffrent Generic Lists
I, for one, don't really understand what you're asking.
Re: How to implement a List of Diffrent Generic Lists
Goal:
you have severalkind of datacollisions that can occur if you add a piece of data to a Webbased database.
You want to resolve these collisionsin the userinterface.
To do so I came up with a principal solution that was like this:
The dataprovider returns an object called ValidationVioaltionResults with a list of Objects called ValidationVioaltionResult (<- No s at the end)
The ValidationVioaltionResult (<- No s at the end) contains:
- A message Decribing the kind of collision that occured
- A list with
1 the item you want to add
and all items that collided with for this type of collision
The colliding objects can be of diffrent Types. So a generic List needs to be placed in the The ValidationVioaltionResult.List (<- No s at the end)
The challenge I need to adress is either:
-how can I do this without losing the type Store the Type of the list(of T)
in a propperty so i can cast it back to the correct Type in the userinterface
Or
-retreive the Type of this list again so I can Cast The List(Of T)
back into a List(Of Person) for instance.