Reflecting Attributes

Attributes are read using Reflection. The CustomAttributeDemo.sln file contains several example projects that use ControlHintAttribute. Several classes in the UserInterfaceGenerator.vbproj project are capable of generating custom user interfaces. (There are two flavors: WindowsInterfaceGenerator creates a Windows Forms user interface, and WebInterfaceGenerator creates a Web Forms user interface.) Listing 5.8 contains the implementation of ExWindowsUserInterface, taking into account the possibility that the control has the ControlHintAttribute applied. ExWindowsUserInterfaceGenerator inherits from WindowsUserInterfaceGenerator, which in turn implements the IUserInterfaceGenerator interface.

Listing 5.8. Creating a Custom ...

Get Visual Basic® .NET Power Coding now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.