public static double ConvertToSquareMetre(double d, string unitMeasure) {
            Unit square_meter = new Unit("square meter").CanBeAbbreviated("m2", "m^2");
            Unit acre = new Unit("acre");
            Unit are = new Unit("are").CanBeAbbreviated("a");
            Unit barn = new Unit("barn").CanBeAbbreviated("b");
            Unit circular_mil = new Unit("circular mil");
            Unit square_millimeter = new Unit("square millimeter").CanBeAbbreviated("mm2", "mm^2");
            Unit foot_to_the_fourth_power = new Unit("foot to the fourth power").CanBeAbbreviated("ft4", "ft^4");
            Unit meter_to_the_fourth_power = new Unit("meter to the fourth power").CanBeAbbreviated("m4", "m^4");
            Unit hectare = new Unit("hectare").CanBeAbbreviated("ha");
            Unit inch_to_the_fourth_power = new Unit("inch to the fourth power").CanBeAbbreviated("in4", "in^4");
            Unit square_foot = new Unit("square foot").CanBeAbbreviated("ft2", "ft^2");
            Unit square_inch = new Unit("square inch").CanBeAbbreviated("in2", "in^2");
            Unit square_centimeter = new Unit("square centimeter").CanBeAbbreviated("cm2", "cm^2");
            Unit square_mile = new Unit("square mile").CanBeAbbreviated("mi2", "mi^2");
            Unit square_kilometer = new Unit("square kilometer").CanBeAbbreviated("km2", "km^2");
            Unit square_yard = new Unit("square yard ").CanBeAbbreviated("yd2", "yd^2");

            ConversionGraph system = new ConversionGraph();
            system.AddConversion(
                Conversions.From(acre).To(square_meter).MultiplyBy((decimal)4.046873E+03),
                Conversions.From(are).To(square_meter).MultiplyBy((decimal)1.0E+02),
                Conversions.From(barn).To(square_meter).MultiplyBy((decimal)1.0E-28),
                Conversions.From(circular_mil).To(square_meter).MultiplyBy((decimal)5.067075E-10),
                Conversions.From(circular_mil).To(square_millimeter).MultiplyBy((decimal)5.067075E-04),
                Conversions.From(foot_to_the_fourth_power).To(meter_to_the_fourth_power).MultiplyBy((decimal)8.630975E-03),
                Conversions.From(hectare).To(square_meter).MultiplyBy((decimal)1.0E+04),
                Conversions.From(inch_to_the_fourth_power).To(meter_to_the_fourth_power).MultiplyBy((decimal)4.162314E-07),
                Conversions.From(square_foot).To(square_meter).MultiplyBy((decimal)9.290304E-02),
                Conversions.From(square_inch).To(square_meter).MultiplyBy((decimal)6.4516E-04),
                Conversions.From(square_inch).To(square_centimeter).MultiplyBy((decimal)6.4516E+00),
                Conversions.From(square_mile).To(square_meter).MultiplyBy((decimal)2.589988E+06),
                Conversions.From(square_mile).To(square_kilometer).MultiplyBy((decimal)2.589988E+00),
                Conversions.From(square_yard).To(square_meter).MultiplyBy((decimal)8.361274E-01));

            Measurement measurement = new Measurement(unitMeasure, (decimal)d);
            return (double)system.Convert(measurement, square_meter);
        }
        public static double ConvertToMetre(double d, string unitMeasure) {
            Unit meter = new Unit("meter").IsAlsoCalled("metre").CanBeAbbreviated("m");
            Unit angstrom = new Unit("ångström").CanBeAbbreviated("Å");
            Unit nanometer = new Unit("nanometer").CanBeAbbreviated("nm");
            Unit astronomical_unit = new Unit("astronomical unit").CanBeAbbreviated("ua");
            Unit chain = new Unit("chain").CanBeAbbreviated("ch");
            Unit fathom = new Unit("fathom");
            Unit femtometer = new Unit("femtometer").CanBeAbbreviated("fm");
            Unit fermi = new Unit("fermi");
            Unit foot = new Unit("foot").CanBeAbbreviated("ft");
            Unit inch = new Unit("inch").CanBeAbbreviated("in");
            Unit light_year = new Unit("light year").CanBeAbbreviated("l. y.");
            Unit microinch = new Unit("microinch");
            Unit micrometer = new Unit("micrometer").CanBeAbbreviated("μm");
            Unit micron = new Unit("micron").CanBeAbbreviated("μ");
            Unit mil = new Unit("mil");
            Unit mile = new Unit("mile").CanBeAbbreviated("mi");
            Unit kilometer = new Unit("kilometer").CanBeAbbreviated("km");
            Unit parsec = new Unit("parsec").CanBeAbbreviated("pc");
            Unit pica = new Unit("pica");
            Unit millimeter = new Unit("millimeter").CanBeAbbreviated("mm");
            Unit point = new Unit("point");
            Unit rod = new Unit("rod").CanBeAbbreviated("rd");
            Unit yard = new Unit("yard").CanBeAbbreviated("yd");

            ConversionGraph system = new ConversionGraph();
            system.AddConversion(
                Conversions.From(angstrom).To(meter).MultiplyBy((decimal)1.0E-10),
                Conversions.From(angstrom).To(nanometer).MultiplyBy((decimal)1.0E-01),
                Conversions.From(astronomical_unit).To(meter).MultiplyBy((decimal)1.495979E+11),
                Conversions.From(chain).To(meter).MultiplyBy((decimal)2.011684E+1),
                Conversions.From(fathom).To(meter).MultiplyBy((decimal)1.828804E+00),
                Conversions.From(fermi).To(meter).MultiplyBy((decimal)1.0E-15),
                Conversions.From(fermi).To(femtometer).MultiplyBy((decimal)1.0E+00),
                Conversions.From(foot).To(meter).MultiplyBy((decimal)3.048E-01),
                Conversions.From(inch).To(meter).MultiplyBy((decimal)2.54E-02),
                Conversions.From(light_year).To(meter).MultiplyBy((decimal)9.46073E+15),
                Conversions.From(microinch).To(meter).MultiplyBy((decimal)2.54E-08),
                Conversions.From(microinch).To(micrometer).MultiplyBy((decimal)2.54E-02),

                Conversions.From(micron).To(meter).MultiplyBy((decimal)1.0E-06),
                Conversions.From(micron).To(micrometer).MultiplyBy((decimal)1.0E+00),
                Conversions.From(mil).To(meter).MultiplyBy((decimal)2.54E-05),
                Conversions.From(mil).To(millimeter).MultiplyBy((decimal)2.54E-02),
                Conversions.From(mile).To(meter).MultiplyBy((decimal)1.609344E+03),
                Conversions.From(mile).To(kilometer).MultiplyBy((decimal)1.609344E+00),
                Conversions.From(parsec).To(meter).MultiplyBy((decimal)3.085678E+16),
                Conversions.From(pica).To(meter).MultiplyBy((decimal)4.233333E-03),
                Conversions.From(pica).To(millimeter).MultiplyBy((decimal)4.233333E+00),
                Conversions.From(point).To(meter).MultiplyBy((decimal)3.527778E-04),
                Conversions.From(point).To(millimeter).MultiplyBy((decimal)3.527778E-01),
                Conversions.From(rod).To(meter).MultiplyBy((decimal)5.029210E+00),
                Conversions.From(yard).To(meter).MultiplyBy((decimal)9.144E-01));

            Measurement measurement = new Measurement(unitMeasure, (decimal)d);
            return (double)system.Convert(measurement, meter);
        }
Example #3
0
 public static Tuple <Measurement, Measurement> In(this Measurement source, Unit target)
 {
     return(new Tuple <Measurement, Measurement>(source, One(target)));
 }
Example #4
0
 public static Conversion To(this Measurement source, Unit unit)
 {
     return(new Conversion(source.Unit, unit));
 }
 public decimal Convert(Measurement source, string target)
 {
     return(Convert(source, new Unit(target)));
 }
 public Unit FindVertex(Measurement measurement)
 {
     return(FindVertex(measurement.Unit));
 }