I would create a custom attribute for methods that define a unit that a method can convert to and from. Then your converter function can extract the device from the converted elements and use reflection to find these classes with conversion methods that convert to / from these units.
You need the basic unit of measurement that you use to convert to / from methods. For instance. select the metric, and then all the transforms are converted to / from the metric to / from the second block. Then, to go from block A to block B, you convert from A to metric, then convert to B from metric, using the A and B converters selected using reflection.
Of course, since you donโt provide too many details on your request, itโs hard to say what exactly you are trying to do is โguessโ the design. :)
source share