The Inner Drive Extensible Architecture™—the Idea™
The Idea™ has a full library of measurement conversions that you can use with no additional setup. This demo shows how it works:
How this works
Each of the principal types of measurement—area, length, speed, etc.—is a distinct .NET structure. This means that the compiler, not the developer, controls what kind of measurements are possible for a particular phenomenon.
However, all of the built-in measurement structures implement IMeasurable, which defines a number of properties and methods useful for a generic converter like this one.
The framework also defines an abstract Unit class, and a collection of concrete measurement units that derive from it. Each contains its own list of conversion factors, meaning that measurements can convert directly to other measurements without going through an intermediary; and the conversion framework is completely extensible, since new Unit classes can simply define their own conversion list.
Converting measurements becomes trivial in most cases:
Length meters = new Length(3000d); // defaults to meters Length feet = meters.ConvertTo(typeof(Foot)); // feet.ToString("0.0000") yields "9842.5197 ft."
In version 4.1, we added fluent instantiation to make your code even clearer:
var km = 3000d.Kilometers(); // km.ToString("0.0000") yields "3000.0000 km"
var psi = new ForceOverArea(new Pound(), new InchSquare()); var atmospheres = pressure.ConvertTo(typeof(Atmosphere));
(Of course, fluent is easier:)
var pressure = (29.92d).PSI();
Inner Drive Extensible Architecture - Quantitative Bases and classes to support quantity, measurement, and unit conversion Version 5.0.8597.0 Release CLR 7.0.8 7/15/2023 3:37 PM Copyright ©2023 Inner Drive Technology. All rights reserved. Portions Copyright ©1986-2023 David Braverman. inner-drive.com The public-facing website for Inner Drive Technology Version 2.1.8600.0 Release CLR 7.0.8 7/18/2023 10:23 PM Copyright ©2023 Inner Drive Technology. All rights reserved. Portions Copyright ©1986-2023 David Braverman.