I've setup my class to inherit from ICustomTypeDescriptor
I've also then setup this method for the GetProperties implementation for the inheritance.
Public Class POSTerminal
Inherits BasePacket
Implements ICustomTypeDescriptor
Public Function GetProperties(ByVal attributes() As System.Attribute) As System.ComponentModel.PropertyDescriptorCollection Implements System.ComponentModel.ICustomTypeDescriptor.GetProperties
Dim pdC As PropertyDescriptorCollection
pdC = TypeDescriptor.GetProperties(Me, True)
Dim addlist As New List(Of PropertyDescriptor)
For Each pd As PropertyDescriptor In pdC
If String.Equals(pd.Name, "Code", StringComparison.OrdinalIgnoreCase) Then
If Not mIsNew Then
addlist.Add(New ReadonlyIntegerPropertyDescriptor(pd, mCode))
Else
addlist.Add(pd)
End If
Else
addlist.Add(pd)
End If
Next
Return New PropertyDescriptorCollection(addlist.ToArray, True)
End Function
I then have my ReadonlyProperty descriptor class.
it's all working, but I'd just like to check is this the way to do it, or is there a cleaner way?