Bonsoir a tous,
Je sollicite votre aide pour un petit problème que je n’arrive pas a résoudre.
J'ai une classe DTOTache qui hérite de DTOBase comme ceci :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 Public MustInherit Class DTOBase Public Sub New() Call Test() End Sub Private Sub Test() Dim attributs() As Object Dim att As DataInfoAttribute Dim propriété As System.Reflection.PropertyInfo Dim attType As Type = GetType(DataInfoAttribute) Dim classType As Type = GetType(DTOTache) For Each propriété In classType.GetProperties attributs = Attribute.GetCustomAttributes(propriété, attType) If attributs.Length > 0 Then att = DirectCast(attributs(0), DataInfoAttribute) Debug.WriteLine("Propriété = " & propriété.Name) Debug.WriteLine("Field Name = " & att.FieldName) Debug.WriteLine("Field Lenght = " & att.FiedLenght) End If Next End Sub End ClassDans DTOBase je fait référence a DTOtache sur cette ligne :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 Public Class DTOTache Inherits DTOBase Public Sub New() End Sub Public Sub New(row As DataRow) End Sub Private _IdTache As Integer <DataInfo("ID_TACHE")> _ Public Property IdTache() As Integer Get Return _IdTache End Get Set(ByVal value As Integer) _IdTache = value End Set End Property End Class
Hors DTOBase doit pouvoir hériter une autre classe que DTOTache, ma question est donc la suivante :
Code : Sélectionner tout - Visualiser dans une fenêtre à part Dim classType As Type = GetType(DTOTache)
Comment je peux faire pour que DTOBase fonctionne avec n'importe quel classe DTOxxx.
Je vous remercie beaucoup de toute l'aide que vous pourrez m'apporter.
Partager