I would very much like to be able to programmatically create Public variables in Visual Basic. What I'm writing is intended to extend the language; specifically, I'm working out how to add scientific units as types, e.g., allowing computation to be done on feet, meters, etc.
A simple example might make this clearer. I'd like to have code that, given the base unit "meter", creates types that represent meters, millimeters, kilometers, etc. - easy to compute the names, and I'd rather do that programmatically than have to explicitly list them all as Public variables. In the worst case I suppose I could write code to write out VB code as a text file, then bring that in later, by hand, as a module. I'd much rather dynamically create those names, as I could generate only those unit system(s) a given programmer is intending to use, rather than having modules for any units system a programmer might possibly use.
Ideally when I'm doing that I could programmatically detect if there is already an existing public variable before I try to create one. When I do create one I want to assign a value to the variable which appropriately references the base unit.
Is this sort of thing possible with Reflection?
Aucun commentaire:
Enregistrer un commentaire